Просмотр исходного кода

LibGUI: Implement content_margins for GroupBox

FrHun 3 лет назад
Родитель
Сommit
4955769ab8
2 измененных файлов с 11 добавлено и 0 удалено
  1. 10 0
      Userland/Libraries/LibGUI/GroupBox.cpp
  2. 1 0
      Userland/Libraries/LibGUI/GroupBox.h

+ 10 - 0
Userland/Libraries/LibGUI/GroupBox.cpp

@@ -24,6 +24,16 @@ GroupBox::~GroupBox()
 {
 {
 }
 }
 
 
+Margins GroupBox::content_margins() const
+{
+    return {
+        (!m_title.is_empty() ? font().glyph_height() + 1 /*room for the focus rect*/ : 2),
+        2,
+        2,
+        2
+    };
+}
+
 void GroupBox::paint_event(PaintEvent& event)
 void GroupBox::paint_event(PaintEvent& event)
 {
 {
     Painter painter(*this);
     Painter painter(*this);

+ 1 - 0
Userland/Libraries/LibGUI/GroupBox.h

@@ -17,6 +17,7 @@ public:
 
 
     String title() const { return m_title; }
     String title() const { return m_title; }
     void set_title(const StringView&);
     void set_title(const StringView&);
+    virtual Margins content_margins() const override;
 
 
 protected:
 protected:
     explicit GroupBox(const StringView& title = {});
     explicit GroupBox(const StringView& title = {});