mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:27:43 +00:00
LibGUI: Implement GToolbar separators.
This commit is contained in:
parent
054e4caf49
commit
949c98c5af
3 changed files with 39 additions and 1 deletions
|
@ -41,10 +41,33 @@ void GToolBar::add_action(Retained<GAction>&& action)
|
|||
m_items.append(move(item));
|
||||
}
|
||||
|
||||
class SeparatorWidget final : public GWidget {
|
||||
public:
|
||||
SeparatorWidget(GWidget* parent)
|
||||
: GWidget(parent)
|
||||
{
|
||||
set_fill_with_background_color(false);
|
||||
set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
||||
set_background_color(Color::White);
|
||||
set_preferred_size({ 8, 20 });
|
||||
}
|
||||
virtual ~SeparatorWidget() override { }
|
||||
|
||||
virtual void paint_event(GPaintEvent& event) override
|
||||
{
|
||||
Painter painter(*this);
|
||||
painter.set_clip_rect(event.rect());
|
||||
painter.translate(rect().center().x() - 1, 0);
|
||||
painter.draw_line({ 0, 0 }, { 0, rect().bottom() }, Color::DarkGray);
|
||||
painter.draw_line({ 1, 0 }, { 1, rect().bottom() }, Color::White);
|
||||
}
|
||||
};
|
||||
|
||||
void GToolBar::add_separator()
|
||||
{
|
||||
auto item = make<Item>();
|
||||
item->type = Item::Separator;
|
||||
new SeparatorWidget(this);
|
||||
m_items.append(move(item));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue