diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-03-07 23:01:36 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-03-07 23:01:36 +0100 |
commit | 949c98c5af7c6dc943956937bde2620ad487ae0e (patch) | |
tree | 2bf60c75ca3b5e49b7b3097f13a986b22dbe2bd5 /LibGUI/GToolBar.cpp | |
parent | 054e4caf49d95b9ec6e2d43a0d1acf052bdec58d (diff) | |
download | serenity-949c98c5af7c6dc943956937bde2620ad487ae0e.zip |
LibGUI: Implement GToolbar separators.
Diffstat (limited to 'LibGUI/GToolBar.cpp')
-rw-r--r-- | LibGUI/GToolBar.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/LibGUI/GToolBar.cpp b/LibGUI/GToolBar.cpp index b0de614c33..e052e5fd1c 100644 --- a/LibGUI/GToolBar.cpp +++ b/LibGUI/GToolBar.cpp @@ -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)); } |