@@ -81,108 +81,6 @@ void ImGui::ShowUserGuide()
81
81
" Use +- to subtract.\n " );
82
82
}
83
83
84
- void ImGui::ShowStyleEditor (ImGuiStyle* ref)
85
- {
86
- ImGuiStyle& style = ImGui::GetStyle ();
87
-
88
- const ImGuiStyle def; // Default style
89
- if (ImGui::Button (" Revert Style" ))
90
- style = ref ? *ref : def;
91
- if (ref)
92
- {
93
- ImGui::SameLine ();
94
- if (ImGui::Button (" Save Style" ))
95
- *ref = style;
96
- }
97
-
98
- ImGui::PushItemWidth (ImGui::GetWindowWidth () * 0 .55f );
99
-
100
- if (ImGui::TreeNode (" Rendering" ))
101
- {
102
- ImGui::Checkbox (" Anti-aliased lines" , &style.AntiAliasedLines );
103
- ImGui::Checkbox (" Anti-aliased shapes" , &style.AntiAliasedShapes );
104
- ImGui::TreePop ();
105
- }
106
-
107
- if (ImGui::TreeNode (" Sizes" ))
108
- {
109
- ImGui::SliderFloat (" Alpha" , &style.Alpha , 0 .20f , 1 .0f , " %.2f" ); // Not exposing zero here so user doesn't "lose" the UI. But application code could have a toggle to switch between zero and non-zero.
110
- ImGui::SliderFloat2 (" WindowPadding" , (float *)&style.WindowPadding , 0 .0f , 20 .0f , " %.0f" );
111
- ImGui::SliderFloat (" WindowRounding" , &style.WindowRounding , 0 .0f , 16 .0f , " %.0f" );
112
- ImGui::SliderFloat (" ChildWindowRounding" , &style.ChildWindowRounding , 0 .0f , 16 .0f , " %.0f" );
113
- ImGui::SliderFloat2 (" FramePadding" , (float *)&style.FramePadding , 0 .0f , 20 .0f , " %.0f" );
114
- ImGui::SliderFloat (" FrameRounding" , &style.FrameRounding , 0 .0f , 16 .0f , " %.0f" );
115
- ImGui::SliderFloat2 (" ItemSpacing" , (float *)&style.ItemSpacing , 0 .0f , 20 .0f , " %.0f" );
116
- ImGui::SliderFloat2 (" ItemInnerSpacing" , (float *)&style.ItemInnerSpacing , 0 .0f , 20 .0f , " %.0f" );
117
- ImGui::SliderFloat2 (" TouchExtraPadding" , (float *)&style.TouchExtraPadding , 0 .0f , 10 .0f , " %.0f" );
118
- ImGui::SliderFloat (" IndentSpacing" , &style.IndentSpacing , 0 .0f , 30 .0f , " %.0f" );
119
- ImGui::SliderFloat (" ScrollbarWidth" , &style.ScrollbarWidth , 1 .0f , 20 .0f , " %.0f" );
120
- ImGui::SliderFloat (" ScrollbarRounding" , &style.ScrollbarRounding , 0 .0f , 16 .0f , " %.0f" );
121
- ImGui::SliderFloat (" GrabMinSize" , &style.GrabMinSize , 1 .0f , 20 .0f , " %.0f" );
122
- ImGui::SliderFloat (" GrabRounding" , &style.GrabRounding , 0 .0f , 16 .0f , " %.0f" );
123
- ImGui::TreePop ();
124
- }
125
-
126
- if (ImGui::TreeNode (" Colors" ))
127
- {
128
- static int output_dest = 0 ;
129
- static bool output_only_modified = false ;
130
- if (ImGui::Button (" Output Colors" ))
131
- {
132
- if (output_dest == 0 )
133
- ImGui::LogToClipboard ();
134
- else
135
- ImGui::LogToTTY ();
136
- ImGui::LogText (" ImGuiStyle& style = ImGui::GetStyle();" IM_NEWLINE);
137
- for (int i = 0 ; i < ImGuiCol_COUNT; i++)
138
- {
139
- const ImVec4& col = style.Colors [i];
140
- const char * name = ImGui::GetStyleColName (i);
141
- if (!output_only_modified || memcmp (&col, (ref ? &ref->Colors [i] : &def.Colors [i]), sizeof (ImVec4)) != 0 )
142
- ImGui::LogText (" style.Colors[ImGuiCol_%s]%*s= ImVec4(%.2ff, %.2ff, %.2ff, %.2ff);" IM_NEWLINE, name, 22 - strlen (name), " " , col.x , col.y , col.z , col.w );
143
- }
144
- ImGui::LogFinish ();
145
- }
146
- ImGui::SameLine (); ImGui::PushItemWidth (120 ); ImGui::Combo (" ##output_type" , &output_dest, " To Clipboard\0 To TTY" ); ImGui::PopItemWidth ();
147
- ImGui::SameLine (); ImGui::Checkbox (" Only Modified Fields" , &output_only_modified);
148
-
149
- static ImGuiColorEditMode edit_mode = ImGuiColorEditMode_RGB;
150
- ImGui::RadioButton (" RGB" , &edit_mode, ImGuiColorEditMode_RGB);
151
- ImGui::SameLine ();
152
- ImGui::RadioButton (" HSV" , &edit_mode, ImGuiColorEditMode_HSV);
153
- ImGui::SameLine ();
154
- ImGui::RadioButton (" HEX" , &edit_mode, ImGuiColorEditMode_HEX);
155
- // ImGui::Text("Tip: Click on colored square to change edit mode.");
156
-
157
- static ImGuiTextFilter filter;
158
- filter.Draw (" Filter colors" , 200 );
159
-
160
- ImGui::BeginChild (" #colors" , ImVec2 (0 , 300 ), true );
161
- ImGui::PushItemWidth (-160 );
162
- ImGui::ColorEditMode (edit_mode);
163
- for (int i = 0 ; i < ImGuiCol_COUNT; i++)
164
- {
165
- const char * name = ImGui::GetStyleColName (i);
166
- if (!filter.PassFilter (name))
167
- continue ;
168
- ImGui::PushID (i);
169
- ImGui::ColorEdit4 (name, (float *)&style.Colors [i], true );
170
- if (memcmp (&style.Colors [i], (ref ? &ref->Colors [i] : &def.Colors [i]), sizeof (ImVec4)) != 0 )
171
- {
172
- ImGui::SameLine (); if (ImGui::Button (" Revert" )) style.Colors [i] = ref ? ref->Colors [i] : def.Colors [i];
173
- if (ref) { ImGui::SameLine (); if (ImGui::Button (" Save" )) ref->Colors [i] = style.Colors [i]; }
174
- }
175
- ImGui::PopID ();
176
- }
177
- ImGui::PopItemWidth ();
178
- ImGui::EndChild ();
179
-
180
- ImGui::TreePop ();
181
- }
182
-
183
- ImGui::PopItemWidth ();
184
- }
185
-
186
84
// Demonstrate most ImGui features (big function!)
187
85
void ImGui::ShowTestWindow (bool * opened)
188
86
{
@@ -1468,6 +1366,108 @@ void ImGui::ShowTestWindow(bool* opened)
1468
1366
ImGui::End ();
1469
1367
}
1470
1368
1369
+ void ImGui::ShowStyleEditor (ImGuiStyle* ref)
1370
+ {
1371
+ ImGuiStyle& style = ImGui::GetStyle ();
1372
+
1373
+ const ImGuiStyle def; // Default style
1374
+ if (ImGui::Button (" Revert Style" ))
1375
+ style = ref ? *ref : def;
1376
+ if (ref)
1377
+ {
1378
+ ImGui::SameLine ();
1379
+ if (ImGui::Button (" Save Style" ))
1380
+ *ref = style;
1381
+ }
1382
+
1383
+ ImGui::PushItemWidth (ImGui::GetWindowWidth () * 0 .55f );
1384
+
1385
+ if (ImGui::TreeNode (" Rendering" ))
1386
+ {
1387
+ ImGui::Checkbox (" Anti-aliased lines" , &style.AntiAliasedLines );
1388
+ ImGui::Checkbox (" Anti-aliased shapes" , &style.AntiAliasedShapes );
1389
+ ImGui::TreePop ();
1390
+ }
1391
+
1392
+ if (ImGui::TreeNode (" Sizes" ))
1393
+ {
1394
+ ImGui::SliderFloat (" Alpha" , &style.Alpha , 0 .20f , 1 .0f , " %.2f" ); // Not exposing zero here so user doesn't "lose" the UI. But application code could have a toggle to switch between zero and non-zero.
1395
+ ImGui::SliderFloat2 (" WindowPadding" , (float *)&style.WindowPadding , 0 .0f , 20 .0f , " %.0f" );
1396
+ ImGui::SliderFloat (" WindowRounding" , &style.WindowRounding , 0 .0f , 16 .0f , " %.0f" );
1397
+ ImGui::SliderFloat (" ChildWindowRounding" , &style.ChildWindowRounding , 0 .0f , 16 .0f , " %.0f" );
1398
+ ImGui::SliderFloat2 (" FramePadding" , (float *)&style.FramePadding , 0 .0f , 20 .0f , " %.0f" );
1399
+ ImGui::SliderFloat (" FrameRounding" , &style.FrameRounding , 0 .0f , 16 .0f , " %.0f" );
1400
+ ImGui::SliderFloat2 (" ItemSpacing" , (float *)&style.ItemSpacing , 0 .0f , 20 .0f , " %.0f" );
1401
+ ImGui::SliderFloat2 (" ItemInnerSpacing" , (float *)&style.ItemInnerSpacing , 0 .0f , 20 .0f , " %.0f" );
1402
+ ImGui::SliderFloat2 (" TouchExtraPadding" , (float *)&style.TouchExtraPadding , 0 .0f , 10 .0f , " %.0f" );
1403
+ ImGui::SliderFloat (" IndentSpacing" , &style.IndentSpacing , 0 .0f , 30 .0f , " %.0f" );
1404
+ ImGui::SliderFloat (" ScrollbarWidth" , &style.ScrollbarWidth , 1 .0f , 20 .0f , " %.0f" );
1405
+ ImGui::SliderFloat (" ScrollbarRounding" , &style.ScrollbarRounding , 0 .0f , 16 .0f , " %.0f" );
1406
+ ImGui::SliderFloat (" GrabMinSize" , &style.GrabMinSize , 1 .0f , 20 .0f , " %.0f" );
1407
+ ImGui::SliderFloat (" GrabRounding" , &style.GrabRounding , 0 .0f , 16 .0f , " %.0f" );
1408
+ ImGui::TreePop ();
1409
+ }
1410
+
1411
+ if (ImGui::TreeNode (" Colors" ))
1412
+ {
1413
+ static int output_dest = 0 ;
1414
+ static bool output_only_modified = false ;
1415
+ if (ImGui::Button (" Output Colors" ))
1416
+ {
1417
+ if (output_dest == 0 )
1418
+ ImGui::LogToClipboard ();
1419
+ else
1420
+ ImGui::LogToTTY ();
1421
+ ImGui::LogText (" ImGuiStyle& style = ImGui::GetStyle();" IM_NEWLINE);
1422
+ for (int i = 0 ; i < ImGuiCol_COUNT; i++)
1423
+ {
1424
+ const ImVec4& col = style.Colors [i];
1425
+ const char * name = ImGui::GetStyleColName (i);
1426
+ if (!output_only_modified || memcmp (&col, (ref ? &ref->Colors [i] : &def.Colors [i]), sizeof (ImVec4)) != 0 )
1427
+ ImGui::LogText (" style.Colors[ImGuiCol_%s]%*s= ImVec4(%.2ff, %.2ff, %.2ff, %.2ff);" IM_NEWLINE, name, 22 - strlen (name), " " , col.x , col.y , col.z , col.w );
1428
+ }
1429
+ ImGui::LogFinish ();
1430
+ }
1431
+ ImGui::SameLine (); ImGui::PushItemWidth (120 ); ImGui::Combo (" ##output_type" , &output_dest, " To Clipboard\0 To TTY" ); ImGui::PopItemWidth ();
1432
+ ImGui::SameLine (); ImGui::Checkbox (" Only Modified Fields" , &output_only_modified);
1433
+
1434
+ static ImGuiColorEditMode edit_mode = ImGuiColorEditMode_RGB;
1435
+ ImGui::RadioButton (" RGB" , &edit_mode, ImGuiColorEditMode_RGB);
1436
+ ImGui::SameLine ();
1437
+ ImGui::RadioButton (" HSV" , &edit_mode, ImGuiColorEditMode_HSV);
1438
+ ImGui::SameLine ();
1439
+ ImGui::RadioButton (" HEX" , &edit_mode, ImGuiColorEditMode_HEX);
1440
+ // ImGui::Text("Tip: Click on colored square to change edit mode.");
1441
+
1442
+ static ImGuiTextFilter filter;
1443
+ filter.Draw (" Filter colors" , 200 );
1444
+
1445
+ ImGui::BeginChild (" #colors" , ImVec2 (0 , 300 ), true );
1446
+ ImGui::PushItemWidth (-160 );
1447
+ ImGui::ColorEditMode (edit_mode);
1448
+ for (int i = 0 ; i < ImGuiCol_COUNT; i++)
1449
+ {
1450
+ const char * name = ImGui::GetStyleColName (i);
1451
+ if (!filter.PassFilter (name))
1452
+ continue ;
1453
+ ImGui::PushID (i);
1454
+ ImGui::ColorEdit4 (name, (float *)&style.Colors [i], true );
1455
+ if (memcmp (&style.Colors [i], (ref ? &ref->Colors [i] : &def.Colors [i]), sizeof (ImVec4)) != 0 )
1456
+ {
1457
+ ImGui::SameLine (); if (ImGui::Button (" Revert" )) style.Colors [i] = ref ? ref->Colors [i] : def.Colors [i];
1458
+ if (ref) { ImGui::SameLine (); if (ImGui::Button (" Save" )) ref->Colors [i] = style.Colors [i]; }
1459
+ }
1460
+ ImGui::PopID ();
1461
+ }
1462
+ ImGui::PopItemWidth ();
1463
+ ImGui::EndChild ();
1464
+
1465
+ ImGui::TreePop ();
1466
+ }
1467
+
1468
+ ImGui::PopItemWidth ();
1469
+ }
1470
+
1471
1471
static void ShowExampleAppMainMenuBar ()
1472
1472
{
1473
1473
if (ImGui::BeginMainMenuBar ())
0 commit comments