@@ -227,6 +227,9 @@ static void OnRegisterOverlay(reshade::api::effect_runtime* runtime) {
227
227
bool any_change = false ;
228
228
std::string last_section;
229
229
std::string last_group;
230
+ bool open_section = true ;
231
+ bool open_node = false ;
232
+ bool has_indent = false ;
230
233
for (auto * setting : *settings) {
231
234
int styles_pushed = 0 ;
232
235
if (setting->tint .has_value ()) {
@@ -243,7 +246,10 @@ static void OnRegisterOverlay(reshade::api::effect_runtime* runtime) {
243
246
ImGuiCol_Button,
244
247
ImGuiCol_ButtonActive,
245
248
ImGuiCol_ButtonHovered,
246
- ImGuiCol_TextSelectedBg
249
+ ImGuiCol_TextSelectedBg,
250
+ ImGuiCol_Header,
251
+ ImGuiCol_HeaderHovered,
252
+ ImGuiCol_HeaderActive,
247
253
};
248
254
for (const auto style : styles) {
249
255
auto style_rgb = ImGui::GetStyleColorVec4 (style);
@@ -257,115 +263,135 @@ static void OnRegisterOverlay(reshade::api::effect_runtime* runtime) {
257
263
}
258
264
259
265
if (last_section != setting->section ) {
260
- ImGui::SeparatorText (setting->section .c_str ());
261
266
last_section.assign (setting->section );
262
- }
263
267
264
- if (!last_group.empty () && !setting->group .empty () && last_group == setting->group ) {
265
- ImGui::SameLine ();
266
- }
267
- last_group = setting->group ;
268
+ if (open_node) {
269
+ // TreePop will call unindent
270
+ ImGui::Indent ();
271
+ ImGui::TreePop ();
272
+ }
273
+ open_node = ImGui::TreeNodeEx (
274
+ setting->section .c_str (),
275
+ ImGuiTreeNodeFlags_DefaultOpen | ImGuiTreeNodeFlags_SpanFullWidth);
276
+ if (open_node) {
277
+ ImGui::Unindent ();
278
+ }
268
279
269
- const bool is_disabled = preset_index == 0
270
- || (setting->is_enabled != nullptr
271
- && !setting->is_enabled ());
272
- if (is_disabled) {
273
- ImGui::BeginDisabled ();
280
+ open_section = open_node;
274
281
}
275
- bool changed = false ;
276
282
277
- switch (setting->value_type ) {
278
- case SettingValueType::FLOAT:
279
- changed |= ImGui::SliderFloat (
280
- setting->label .c_str (),
281
- &setting->value ,
282
- setting->min ,
283
- setting->max ,
284
- setting->format .c_str ());
285
- break ;
286
- case SettingValueType::INTEGER:
287
- changed |= ImGui::SliderInt (
288
- setting->label .c_str (),
289
- &setting->value_as_int ,
290
- setting->min ,
291
- setting->GetMax (),
292
- setting->labels .empty ()
293
- ? setting->format .c_str ()
294
- : setting->labels .at (setting->value_as_int ).c_str (),
295
- ImGuiSliderFlags_NoInput);
296
- break ;
297
- case SettingValueType::BOOLEAN:
298
- changed |= ImGui::SliderInt (
299
- setting->label .c_str (),
300
- &setting->value_as_int ,
301
- 0 ,
302
- 1 ,
303
- setting->labels .empty ()
304
- ? ((setting->value_as_int == 0 ) ? " Off" : " On" ) // NOLINT(readability-avoid-nested-conditional-operator)
305
- : setting->labels .at (setting->value_as_int ).c_str (),
306
- ImGuiSliderFlags_NoInput);
307
- break ;
308
- case SettingValueType::BUTTON: {
309
- changed |= ImGui::Button (setting->label .c_str ());
283
+ if (open_section) {
284
+ if (!last_group.empty () && !setting->group .empty () && last_group == setting->group ) {
285
+ ImGui::SameLine ();
310
286
}
311
- }
312
- if (changed) {
313
- setting->on_change ();
314
- }
315
- if (!setting->tooltip .empty ()) {
316
- ImGui::SetItemTooltip (" %s" , setting->tooltip .c_str ());
317
- }
318
287
319
- if (preset_index != 0
320
- && setting->can_reset
321
- && setting->value_type != SettingValueType::BUTTON) {
322
- ImGui::SameLine ();
323
- const bool is_using_default = (setting->GetValue () == setting->default_value );
324
- ImGui::BeginDisabled (is_using_default);
325
- ImGui::PushID (&setting->default_value );
326
- if (is_using_default) {
327
- ImGui::PushStyleColor (ImGuiCol_Button, ImVec4 (ImColor::HSV (0 , 0 , 0 .6f )));
328
- ImGui::PushStyleColor (ImGuiCol_ButtonHovered, ImVec4 (ImColor::HSV (0 , 0 , 0 .7f )));
329
- ImGui::PushStyleColor (ImGuiCol_ButtonActive, ImVec4 (ImColor::HSV (0 , 0 , 0 .8f )));
288
+ last_group = setting->group ;
289
+
290
+ const bool is_disabled = preset_index == 0
291
+ || (setting->is_enabled != nullptr
292
+ && !setting->is_enabled ());
293
+ if (is_disabled) {
294
+ ImGui::BeginDisabled ();
330
295
}
331
- auto * font = ImGui::GetFont ();
332
- auto old_scale = font->Scale ;
333
- auto previous_font_size = ImGui::GetFontSize ();
334
- font->Scale *= 0 .75f ;
335
- ImGui::PushFont (font);
336
- auto current_font_size = ImGui::GetFontSize ();
337
-
338
- ImGui::PushStyleVar (ImGuiStyleVar_FrameRounding, current_font_size * 2 );
339
-
340
- ImVec2 cursor_pos = ImGui::GetCursorPos ();
341
- cursor_pos.y += (previous_font_size / 2 .f ) - (current_font_size / 2 .f );
342
- ImGui::SetCursorPos (cursor_pos);
343
-
344
- if (ImGui::Button (reinterpret_cast <const char *>(ICON_FK_UNDO))) {
345
- setting->Set (setting->default_value );
346
- changed = true ;
296
+ bool changed = false ;
297
+
298
+ switch (setting->value_type ) {
299
+ case SettingValueType::FLOAT:
300
+ changed |= ImGui::SliderFloat (
301
+ setting->label .c_str (),
302
+ &setting->value ,
303
+ setting->min ,
304
+ setting->max ,
305
+ setting->format .c_str ());
306
+ break ;
307
+ case SettingValueType::INTEGER:
308
+ changed |= ImGui::SliderInt (
309
+ setting->label .c_str (),
310
+ &setting->value_as_int ,
311
+ setting->min ,
312
+ setting->GetMax (),
313
+ setting->labels .empty ()
314
+ ? setting->format .c_str ()
315
+ : setting->labels .at (setting->value_as_int ).c_str (),
316
+ ImGuiSliderFlags_NoInput);
317
+ break ;
318
+ case SettingValueType::BOOLEAN:
319
+ changed |= ImGui::SliderInt (
320
+ setting->label .c_str (),
321
+ &setting->value_as_int ,
322
+ 0 ,
323
+ 1 ,
324
+ setting->labels .empty ()
325
+ ? ((setting->value_as_int == 0 ) ? " Off" : " On" ) // NOLINT(readability-avoid-nested-conditional-operator)
326
+ : setting->labels .at (setting->value_as_int ).c_str (),
327
+ ImGuiSliderFlags_NoInput);
328
+ break ;
329
+ case SettingValueType::BUTTON: {
330
+ changed |= ImGui::Button (setting->label .c_str ());
331
+ }
332
+ }
333
+ if (changed) {
334
+ setting->on_change ();
335
+ }
336
+ if (!setting->tooltip .empty ()) {
337
+ ImGui::SetItemTooltip (" %s" , setting->tooltip .c_str ());
347
338
}
348
339
349
- if (is_using_default) {
350
- ImGui::PopStyleColor (3 );
340
+ if (preset_index != 0
341
+ && setting->can_reset
342
+ && setting->value_type != SettingValueType::BUTTON) {
343
+ ImGui::SameLine ();
344
+ const bool is_using_default = (setting->GetValue () == setting->default_value );
345
+ ImGui::BeginDisabled (is_using_default);
346
+ ImGui::PushID (&setting->default_value );
347
+ if (is_using_default) {
348
+ ImGui::PushStyleColor (ImGuiCol_Button, ImVec4 (ImColor::HSV (0 , 0 , 0 .6f )));
349
+ ImGui::PushStyleColor (ImGuiCol_ButtonHovered, ImVec4 (ImColor::HSV (0 , 0 , 0 .7f )));
350
+ ImGui::PushStyleColor (ImGuiCol_ButtonActive, ImVec4 (ImColor::HSV (0 , 0 , 0 .8f )));
351
+ }
352
+ auto * font = ImGui::GetFont ();
353
+ auto old_scale = font->Scale ;
354
+ auto previous_font_size = ImGui::GetFontSize ();
355
+ font->Scale *= 0 .75f ;
356
+ ImGui::PushFont (font);
357
+ auto current_font_size = ImGui::GetFontSize ();
358
+
359
+ ImGui::PushStyleVar (ImGuiStyleVar_FrameRounding, current_font_size * 2 );
360
+
361
+ ImVec2 cursor_pos = ImGui::GetCursorPos ();
362
+ cursor_pos.y += (previous_font_size / 2 .f ) - (current_font_size / 2 .f );
363
+ ImGui::SetCursorPos (cursor_pos);
364
+
365
+ if (ImGui::Button (reinterpret_cast <const char *>(ICON_FK_UNDO))) {
366
+ setting->Set (setting->default_value );
367
+ changed = true ;
368
+ }
369
+
370
+ if (is_using_default) {
371
+ ImGui::PopStyleColor (3 );
372
+ }
373
+ font->Scale = old_scale;
374
+ ImGui::PopFont ();
375
+ ImGui::PopStyleVar ();
376
+ ImGui::PopID ();
377
+ ImGui::EndDisabled ();
351
378
}
352
- font->Scale = old_scale;
353
- ImGui::PopFont ();
354
- ImGui::PopStyleVar ();
355
- ImGui::PopID ();
356
- ImGui::EndDisabled ();
357
- }
358
379
359
- if (changed) {
360
- setting->Write ();
361
- any_change = true ;
362
- }
363
- if (is_disabled) {
364
- ImGui::EndDisabled ();
380
+ if (changed) {
381
+ setting->Write ();
382
+ any_change = true ;
383
+ }
384
+ if (is_disabled) {
385
+ ImGui::EndDisabled ();
386
+ }
365
387
}
366
-
367
388
ImGui::PopStyleColor (styles_pushed);
368
389
}
390
+ if (open_node) {
391
+ ImGui::Indent ();
392
+ ImGui::TreePop ();
393
+ }
394
+
369
395
if (!changed_preset && any_change) {
370
396
switch (preset_index) {
371
397
case 1 :
0 commit comments