@@ -29,13 +29,12 @@ bool reshade::gui::widgets::path_list(const char *label, std::vector<std::filesy
2929 const size_t buf_len = paths[i].u8string ().copy (buf, sizeof (buf) - 1 );
3030 buf[buf_len] = ' \0 ' ;
3131
32- ImGui::PushItemWidth (ImGui::GetWindowContentRegionWidth () - (button_spacing + button_size));
32+ ImGui::SetNextItemWidth (ImGui::GetWindowContentRegionWidth () - (button_spacing + button_size));
3333 if (ImGui::InputText (" ##path" , buf, sizeof (buf)))
3434 {
3535 res = true ;
3636 paths[i] = std::filesystem::u8path (buf);
3737 }
38- ImGui::PopItemWidth ();
3938
4039 ImGui::SameLine (0 , button_spacing);
4140 if (ImGui::Button (ICON_FK_MINUS, ImVec2 (button_size, 0 )))
@@ -102,14 +101,13 @@ bool reshade::gui::widgets::file_dialog(const char *name, std::filesystem::path
102101 const size_t buf_len = parent_path.u8string ().copy (buf, sizeof (buf) - 1 );
103102 buf[buf_len] = ' \0 ' ;
104103
105- ImGui::PushItemWidth (width);
104+ ImGui::SetNextItemWidth (width);
106105 if (ImGui::InputText (" ##path" , buf, sizeof (buf)))
107106 {
108107 path = std::filesystem::u8path (buf);
109108 if (path.has_stem () && std::filesystem::is_directory (path, ec))
110109 path += std::filesystem::path::preferred_separator;
111110 }
112- ImGui::PopItemWidth ();
113111
114112 if (ImGui::IsItemActivated ())
115113 ImGui::GetCurrentContext ()->InputTextState .ClearSelection ();
@@ -189,10 +187,9 @@ bool reshade::gui::widgets::file_dialog(const char *name, std::filesystem::path
189187 const size_t buf_len = path_name.u8string ().copy (buf, sizeof (buf) - 1 );
190188 buf[buf_len] = ' \0 ' ;
191189
192- ImGui::PushItemWidth (width - (2 * (80 + ImGui::GetStyle ().ItemSpacing .x )));
190+ ImGui::SetNextItemWidth (width - (2 * (80 + ImGui::GetStyle ().ItemSpacing .x )));
193191 if (ImGui::InputText (" ##name" , buf, sizeof (buf)))
194192 path = path.parent_path () / buf;
195- ImGui::PopItemWidth ();
196193 }
197194
198195 ImGui::SameLine ();
@@ -260,20 +257,18 @@ bool reshade::gui::widgets::font_input_box(const char *name, std::filesystem::pa
260257 ImGui::BeginGroup ();
261258 ImGui::PushID (name);
262259
263- ImGui::PushItemWidth (ImGui::CalcItemWidth () - spacing - 80 );
260+ ImGui::SetNextItemWidth (ImGui::CalcItemWidth () - spacing - 80 );
264261 if (file_input_box (" ##font" , path, dialog_path, { L" .ttf" }))
265262 res = true ;
266- ImGui::PopItemWidth ();
267263
268264 // Reset to the default font name if path is empty
269265 if (path.empty ())
270266 path = L" ProggyClean.ttf" ;
271267
272268 ImGui::SameLine (0 , spacing);
273- ImGui::PushItemWidth (80 );
269+ ImGui::SetNextItemWidth (80 );
274270 if (ImGui::SliderInt (" ##size" , &size, 8 , 32 ))
275271 res = true ;
276- ImGui::PopItemWidth ();
277272
278273 ImGui::PopID ();
279274
@@ -318,15 +313,14 @@ bool reshade::gui::widgets::file_input_box(const char *name, std::filesystem::pa
318313 const size_t buf_len = path.u8string ().copy (buf, sizeof (buf) - 1 );
319314 buf[buf_len] = ' \0 ' ; // Null-terminate string
320315
321- ImGui::PushItemWidth (ImGui::CalcItemWidth () - (button_spacing + button_size));
316+ ImGui::SetNextItemWidth (ImGui::CalcItemWidth () - (button_spacing + button_size));
322317 if (ImGui::InputText (" ##path" , buf, sizeof (buf), ImGuiInputTextFlags_EnterReturnsTrue))
323318 {
324319 dialog_path = std::filesystem::u8path (buf);
325320 // Succeed only if extension matches
326321 if (std::find (exts.begin (), exts.end (), dialog_path.extension ()) != exts.end () || dialog_path.empty ())
327322 path = dialog_path, res = true ;
328323 }
329- ImGui::PopItemWidth ();
330324
331325 ImGui::SameLine (0 , button_spacing);
332326 if (ImGui::Button (ICON_FK_FOLDER_OPEN, ImVec2 (button_size, 0 )))
@@ -364,10 +358,9 @@ bool reshade::gui::widgets::directory_input_box(const char *name, std::filesyste
364358 const size_t buf_len = path.u8string ().copy (buf, sizeof (buf) - 1 );
365359 buf[buf_len] = ' \0 ' ; // Null-terminate string
366360
367- ImGui::PushItemWidth (ImGui::CalcItemWidth () - (button_spacing + button_size));
361+ ImGui::SetNextItemWidth (ImGui::CalcItemWidth () - (button_spacing + button_size));
368362 if (ImGui::InputText (" ##path" , buf, sizeof (buf)))
369363 path = std::filesystem::u8path (buf), res = true ;
370- ImGui::PopItemWidth ();
371364
372365 ImGui::SameLine (0 , button_spacing);
373366 if (ImGui::Button (ICON_FK_FOLDER_OPEN, ImVec2 (button_size, 0 )))
@@ -452,8 +445,7 @@ bool reshade::gui::widgets::list_with_buttons(const char *label, const std::stri
452445 const float button_spacing = ImGui::GetStyle ().ItemInnerSpacing .x ;
453446 const ImVec2 hover_pos = ImGui::GetCursorScreenPos () + ImVec2 (0 , button_size);
454447
455- ImGui::PushItemWidth (ImGui::CalcItemWidth () - (button_spacing * 2 + button_size * 2 ));
456-
448+ ImGui::SetNextItemWidth (ImGui::CalcItemWidth () - (button_spacing * 2 + button_size * 2 ));
457449 if (ImGui::BeginCombo (" ##v" , items.size () > static_cast <size_t >(v) && v >= 0 ? items[v].data () : nullptr , ImGuiComboFlags_NoArrowButton))
458450 {
459451 auto it = items.begin ();
@@ -469,8 +461,6 @@ bool reshade::gui::widgets::list_with_buttons(const char *label, const std::stri
469461 ImGui::EndCombo ();
470462 }
471463
472- ImGui::PopItemWidth ();
473-
474464 ImGui::PushItemFlag (ImGuiItemFlags_Disabled, items.empty ());
475465
476466 ImGui::SameLine (0 , button_spacing);
@@ -543,12 +533,9 @@ bool reshade::gui::widgets::combo_with_buttons(const char *label, const std::str
543533 const float button_size = ImGui::GetFrameHeight ();
544534 const float button_spacing = ImGui::GetStyle ().ItemInnerSpacing .x ;
545535
546- ImGui::PushItemWidth (ImGui::CalcItemWidth () - (button_spacing * 2 + button_size * 2 ));
547-
536+ ImGui::SetNextItemWidth (ImGui::CalcItemWidth () - (button_spacing * 2 + button_size * 2 ));
548537 bool modified = ImGui::Combo (" ##v" , &v, items.c_str ());
549538
550- ImGui::PopItemWidth ();
551-
552539 ImGui::PushItemFlag (ImGuiItemFlags_Disabled, num_items == 0 );
553540
554541 ImGui::SameLine (0 , button_spacing);
@@ -584,9 +571,10 @@ static bool drag_with_buttons(const char *label, T *v, int components, T v_speed
584571 ImGui::BeginGroup ();
585572 ImGui::PushID (label);
586573
587- ImGui::PushItemWidth (ImGui::CalcItemWidth () - (button_spacing * 2 + button_size * 2 ));
588- bool value_changed = ImGui::DragScalarN (" ##v" , data_type, v, components, static_cast <float >(v_speed), &v_min, &v_max, format);
589- ImGui::PopItemWidth ();
574+ ImGui::SetNextItemWidth (ImGui::CalcItemWidth () - (button_spacing * 2 + button_size * 2 ));
575+ bool value_changed = (components < 2 ) ?
576+ ImGui::DragScalar (" ##v" , data_type, v, static_cast <float >(v_speed), &v_min, &v_max, format) :
577+ ImGui::DragScalarN (" ##v" , data_type, v, components, static_cast <float >(v_speed), &v_min, &v_max, format);
590578
591579 ImGui::SameLine (0 , button_spacing);
592580 if (ImGui::ButtonEx (" <" , ImVec2 (button_size, 0 ), ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_Repeat) && v[0 ] > v_min)
@@ -646,9 +634,10 @@ static bool slider_with_buttons(const char *label, T *v, int components, T v_spe
646634 ImGui::BeginGroup ();
647635 ImGui::PushID (label);
648636
649- ImGui::PushItemWidth (ImGui::CalcItemWidth () - (button_spacing * 2 + button_size * 2 ));
650- bool value_changed = ImGui::SliderScalarN (" ##v" , data_type, v, components, &v_min, &v_max, format);
651- ImGui::PopItemWidth ();
637+ ImGui::SetNextItemWidth (ImGui::CalcItemWidth () - (button_spacing * 2 + button_size * 2 ));
638+ bool value_changed = (components < 2 ) ?
639+ ImGui::SliderScalar (" ##v" , data_type, v, &v_min, &v_max, format) :
640+ ImGui::SliderScalarN (" ##v" , data_type, v, components, &v_min, &v_max, format);
652641
653642 ImGui::SameLine (0 , button_spacing);
654643 if (ImGui::ButtonEx (" <" , ImVec2 (button_size, 0 ), ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_Repeat) && v[0 ] > v_min)
@@ -707,9 +696,8 @@ bool reshade::gui::widgets::slider_for_alpha_value(const char *label, float *v)
707696 ImGui::BeginGroup ();
708697 ImGui::PushID (label);
709698
710- ImGui::PushItemWidth (ImGui::CalcItemWidth () - button_spacing - button_size);
699+ ImGui::SetNextItemWidth (ImGui::CalcItemWidth () - button_spacing - button_size);
711700 const bool modified = ImGui::SliderFloat (" ##v" , v, 0 .0f , 1 .0f );
712- ImGui::PopItemWidth ();
713701
714702 ImGui::SameLine (0 , button_spacing);
715703 ImGui::ColorButton (" ##preview" , ImVec4 (1 .0f , 1 .0f , 1 .0f , *v), ImGuiColorEditFlags_NoOptions | ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_NoPicker);
0 commit comments