Skip to content

Commit e2d78ae

Browse files
committed
Adding a global style picker - you will like it 😄
1 parent b7fcb0a commit e2d78ae

File tree

1 file changed

+38
-10
lines changed

1 file changed

+38
-10
lines changed

PasImGui_SDL2_OpenGL3_Demo/ImGui_SDL2_OpenGL3_Demo.dpr

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ Var
5656
ShowImPlotDemo: Boolean = False;
5757
ShowImPlotPascalDemo: Boolean = False;
5858
clearColor: ImVec4;
59-
float_value: Single;
6059

6160
Var
6261
ImGuiCtx: PImGuiContext;
@@ -170,28 +169,57 @@ Var
170169
ImGui.End_;
171170
End;
172171
End;
173-
172+
var
173+
GlobalStyleInitalized : Boolean = False;
174+
color_for_text, color_for_head, color_for_area, color_for_body, color_for_pops: ImVec3;
174175
Procedure RenderPascalCode();
175176
Var
176177
Pos: ImVec2;
177-
Begin
178+
begin
179+
if not GlobalStyleInitalized then
180+
begin
181+
color_for_text := ImVec3.New(236.0 / 255.0, 240.0 / 255.0, 241.0 / 255.0);
182+
color_for_head := ImVec3.New(41.0 / 255.0, 128.0 / 255.0, 185.0 / 255.0);
183+
color_for_area := ImVec3.New(57.0 / 255.0, 79.0 / 255.0, 105.0 / 255.0);
184+
color_for_body := ImVec3.New(44.0 / 255.0, 62.0 / 255.0, 80.0 / 255.0);
185+
color_for_pops := ImVec3.New(33.0 / 255.0, 46.0 / 255.0, 60.0 / 255.0);
186+
GlobalStyleInitalized := True;
187+
end;
178188
//draw your scene or simple windows
179189
Pos := ImGui.GetCenterViewPort(ImGui.GetMainViewport());
180190
Pos.y := Pos.y - 160;
181191
ImGui.SetNextWindowPos(Pos, ImGuiCond_FirstUseEver, ImVec2.New(0.5, 0.5));
182192
Begin
183193
ImGui.Begin_('Hello From FreePascal / Delphi', nil, ImGuiWindowFlags_None);
184-
ImGui.Text('This is some useful text', []);
194+
ImGui.Text('This is some useful text');
185195

186-
ImGui.Checkbox('ImGui Demo', @showDemoWindow);
196+
ImGui.Checkbox('ImGui Demo', @showDemoWindow); ImGui.SameLine();
187197
ImGui.Checkbox('ImPlot Demo', @ShowImPlotDemo);
188198
ImGui.Checkbox('ImPlot Pascal Demo', @ShowImPlotPascalDemo);
189199
ImGui.Checkbox('Pascal Node Window', @showNodeWindow);
190200
ImGui.Checkbox('Pascal Demo Window', @showPascalDemoWindow);
191201
ImGui.Checkbox('Another Pascal window', @showAnotherWindow);
192202

193-
ImGui.SliderFloat('Float', @float_value, 0.0, 1.0, '%.3f', ImGuiSliderFlags_None);
194-
ImGui.ColorEdit3('Background color', @clearColor, ImGuiColorEditFlags_None);
203+
ImGui.Spacing();
204+
ImGui.Separator();
205+
ImGui.Text('Global Styling Test');
206+
ImGui.NewLine();
207+
208+
ImGui.ColorEdit3('color_for_text', @color_for_text);
209+
ImGui.ColorEdit3('color_for_head', @color_for_head);
210+
ImGui.ColorEdit3('color_for_area', @color_for_area);
211+
ImGui.ColorEdit3('color_for_body', @color_for_body);
212+
ImGui.ColorEdit3('color_for_pops', @color_for_pops);
213+
214+
//If (ImGui.Button('Apply')) Then
215+
//begin
216+
imgui_easy_theming(color_for_text, color_for_head, color_for_area, color_for_body, color_for_pops);
217+
//end;
218+
219+
ImGui.NewLine();
220+
ImGui.Separator();
221+
222+
ImGui.ColorEdit3('Background color', @clearColor);
195223

196224
If (ImGui.Button('Add')) Then
197225
begin
@@ -233,7 +261,7 @@ Var
233261

234262
Begin
235263
{ TODO: This is here for testing - Remove this later :V }
236-
//DeleteFile('imgui.ini');
264+
//DeleteFile('MyApp.ini');
237265

238266
// Set the Default Alloc & Free to point to Pascal Allocators
239267
igSetAllocatorFunctions(@PasAllocMem, @PasFreeMem, nil);
@@ -337,8 +365,8 @@ Begin
337365

338366
// Load Fonts
339367
//IO^.Fonts^.AddFontDefault();
340-
IO^.Fonts^.AddFontFromFileTTF('../fonts/DroidSans.ttf', 25.0);
341-
IO^.Fonts^.AddFontFromFileTTF('../fonts/JetBrainsMonoNerdFontPropo-Italic.ttf ', 28.0);
368+
IO^.Fonts^.AddFontFromFileTTF('fonts/DroidSans.ttf', 25.0);
369+
IO^.Fonts^.AddFontFromFileTTF('fonts/JetBrainsMonoNerdFontPropo-Italic.ttf ', 28.0);
342370

343371
// Background Color
344372
clearColor.x := 0.45;

0 commit comments

Comments
 (0)