Browse Source

PaintBrush: Make little icons for the pen and bucket tools.

Andreas Kling 6 years ago
parent
commit
694b4a64bd

+ 8 - 4
Applications/PaintBrush/ToolboxWidget.cpp

@@ -4,13 +4,15 @@
 #include "PenTool.h"
 #include <LibGUI/GBoxLayout.h>
 #include <LibGUI/GButton.h>
+#include <SharedGraphics/PNGLoader.h>
 
 class ToolButton final : public GButton {
 public:
     ToolButton(const String& name, GWidget* parent, OwnPtr<Tool>&& tool)
-        : GButton(name, parent)
+        : GButton(parent)
         , m_tool(move(tool))
     {
+        set_tooltip(name);
     }
 
     const Tool& tool() const { return *m_tool; }
@@ -36,13 +38,15 @@ ToolboxWidget::ToolboxWidget(GWidget* parent)
     set_layout(make<GBoxLayout>(Orientation::Vertical));
     layout()->set_margins({ 4, 4, 4, 4 });
 
-    auto add_tool = [&](const StringView& name, OwnPtr<Tool>&& tool) {
+    auto add_tool = [&](const StringView& name, const StringView& icon_name, OwnPtr<Tool>&& tool) {
         auto* button = new ToolButton(name, this, move(tool));
         button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
         button->set_preferred_size({ 0, 32 });
         button->set_checkable(true);
         button->set_exclusive(true);
 
+        button->set_icon(load_png(String::format("/res/icons/paintbrush/%s.png", icon_name.characters())));
+
         button->on_checked = [button](auto checked) {
             if (checked)
                 PaintableWidget::the().set_tool(&button->tool());
@@ -51,8 +55,8 @@ ToolboxWidget::ToolboxWidget(GWidget* parent)
         };
     };
 
-    add_tool("Pen", make<PenTool>());
-    add_tool("Buck", make<BucketTool>());
+    add_tool("Pen", "pen", make<PenTool>());
+    add_tool("Bucket Fill", "bucket", make<BucketTool>());
 }
 
 ToolboxWidget::~ToolboxWidget()

BIN
Base/res/icons/paintbrush/bucket.png


BIN
Base/res/icons/paintbrush/pen.png