summaryrefslogtreecommitdiff
path: root/LibGUI/GToolBar.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-03-07 23:01:36 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-03-07 23:01:36 +0100
commit949c98c5af7c6dc943956937bde2620ad487ae0e (patch)
tree2bf60c75ca3b5e49b7b3097f13a986b22dbe2bd5 /LibGUI/GToolBar.cpp
parent054e4caf49d95b9ec6e2d43a0d1acf052bdec58d (diff)
downloadserenity-949c98c5af7c6dc943956937bde2620ad487ae0e.zip
LibGUI: Implement GToolbar separators.
Diffstat (limited to 'LibGUI/GToolBar.cpp')
-rw-r--r--LibGUI/GToolBar.cpp23
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));
}