mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:37:35 +00:00
LibGUI: Allow TabWidget tabs to have icons and custom text alignment
This commit is contained in:
parent
2be184f49c
commit
53cb5325ee
2 changed files with 36 additions and 5 deletions
|
@ -68,10 +68,14 @@ public:
|
|||
void remove_tab(Widget& tab) { remove_widget(tab); }
|
||||
|
||||
void set_tab_title(Widget& tab, const StringView& title);
|
||||
void set_tab_icon(Widget& tab, const Gfx::Bitmap*);
|
||||
|
||||
void activate_next_tab();
|
||||
void activate_previous_tab();
|
||||
|
||||
void set_text_alignment(Gfx::TextAlignment alignment) { m_text_alignment = alignment; }
|
||||
Gfx::TextAlignment text_alignment() const { return m_text_alignment; }
|
||||
|
||||
Function<void(Widget&)> on_change;
|
||||
|
||||
protected:
|
||||
|
@ -94,15 +98,16 @@ private:
|
|||
RefPtr<Widget> m_active_widget;
|
||||
|
||||
struct TabData {
|
||||
Gfx::Rect rect(const Gfx::Font&) const;
|
||||
int width(const Gfx::Font&) const;
|
||||
String title;
|
||||
RefPtr<Gfx::Bitmap> icon;
|
||||
Widget* widget { nullptr };
|
||||
};
|
||||
Vector<TabData> m_tabs;
|
||||
TabPosition m_tab_position { TabPosition::Top };
|
||||
int m_hovered_tab_index { -1 };
|
||||
int m_container_padding { 2 };
|
||||
Gfx::TextAlignment m_text_alignment { Gfx::TextAlignment::Center };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue