mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:27:35 +00:00
LibGUI: Add ability to hide GUI::TabWidget's tab bar
This commit is contained in:
parent
082cd7048e
commit
4ab4de7810
2 changed files with 17 additions and 2 deletions
|
@ -147,6 +147,9 @@ Gfx::Rect TabWidget::container_rect() const
|
|||
|
||||
void TabWidget::paint_event(PaintEvent& event)
|
||||
{
|
||||
if (!m_bar_visible)
|
||||
return;
|
||||
|
||||
Painter painter(*this);
|
||||
painter.add_clip_rect(event.rect());
|
||||
|
||||
|
@ -206,6 +209,14 @@ int TabWidget::uniform_tab_width() const
|
|||
return max(tab_width, minimum_tab_width);
|
||||
}
|
||||
|
||||
void TabWidget::set_bar_visible(bool bar_visible)
|
||||
{
|
||||
m_bar_visible = bar_visible;
|
||||
if (m_active_widget)
|
||||
m_active_widget->set_relative_rect(child_rect_for_size(size()));
|
||||
update_bar();
|
||||
}
|
||||
|
||||
Gfx::Rect TabWidget::button_rect(int index) const
|
||||
{
|
||||
int x_offset = 2;
|
||||
|
@ -346,7 +357,7 @@ void TabWidget::activate_previous_tab()
|
|||
set_active_widget(m_tabs.at(index).widget);
|
||||
}
|
||||
|
||||
void TabWidget::keydown_event(KeyEvent & event)
|
||||
void TabWidget::keydown_event(KeyEvent& event)
|
||||
{
|
||||
if (event.ctrl() && event.key() == Key_Tab) {
|
||||
if (event.shift())
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
const Widget* active_widget() const { return m_active_widget.ptr(); }
|
||||
void set_active_widget(Widget*);
|
||||
|
||||
int bar_height() const { return 21; }
|
||||
int bar_height() const { return m_bar_visible ? 21 : 0; }
|
||||
|
||||
int container_padding() const { return m_container_padding; }
|
||||
void set_container_padding(int padding) { m_container_padding = padding; }
|
||||
|
@ -79,6 +79,9 @@ public:
|
|||
void set_uniform_tabs(bool uniform_tabs) { m_uniform_tabs = uniform_tabs; }
|
||||
int uniform_tab_width() const;
|
||||
|
||||
void set_bar_visible(bool bar_visible);
|
||||
bool is_bar_visible() const { return m_bar_visible; };
|
||||
|
||||
Function<void(Widget&)> on_change;
|
||||
Function<void(Widget&)> on_middle_click;
|
||||
|
||||
|
@ -114,6 +117,7 @@ private:
|
|||
int m_container_padding { 2 };
|
||||
Gfx::TextAlignment m_text_alignment { Gfx::TextAlignment::Center };
|
||||
bool m_uniform_tabs { false };
|
||||
bool m_bar_visible { true };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue