Explorar el Código

LibGUI: Make Breadcrumbbar resizable below current size

By making proper use of the dynamic layout system, the Breadcrumbbar can
now shrink below its current (grown) size again, while still ensuring
that no icon gets cut off.
FrHun hace 2 años
padre
commit
29a3ff22d7
Se han modificado 1 ficheros con 4 adiciones y 3 borrados
  1. 4 3
      Userland/Libraries/LibGUI/Breadcrumbbar.cpp

+ 4 - 3
Userland/Libraries/LibGUI/Breadcrumbbar.cpp

@@ -109,7 +109,8 @@ void Breadcrumbbar::append_segment(String text, Gfx::Bitmap const* icon, String
     auto button_width = min(button_text_width + icon_width + icon_padding + 16, max_button_width);
     auto button_width = min(button_text_width + icon_width + icon_padding + 16, max_button_width);
     auto shrunken_width = icon_width + icon_padding + (icon ? 4 : 16);
     auto shrunken_width = icon_width + icon_padding + (icon ? 4 : 16);
 
 
-    button.set_fixed_size(button_width, 16 + 8);
+    button.set_max_size(button_width, 16 + 8);
+    button.set_min_size(shrunken_width, 16 + 8);
 
 
     Segment segment { icon, text, data, button_width, shrunken_width, button.make_weak_ptr<GUI::Button>() };
     Segment segment { icon, text, data, button_width, shrunken_width, button.make_weak_ptr<GUI::Button>() };
 
 
@@ -178,11 +179,11 @@ void Breadcrumbbar::relayout()
 
 
     for (auto& segment : m_segments) {
     for (auto& segment : m_segments) {
         if (remaining_width > width() && !segment.button->is_checked()) {
         if (remaining_width > width() && !segment.button->is_checked()) {
-            segment.button->set_fixed_width(segment.shrunken_width);
+            segment.button->set_preferred_width(segment.shrunken_width);
             remaining_width -= (segment.width - segment.shrunken_width);
             remaining_width -= (segment.width - segment.shrunken_width);
             continue;
             continue;
         }
         }
-        segment.button->set_fixed_width(segment.width);
+        segment.button->set_preferred_width(segment.width);
     }
     }
 }
 }