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

This commit is contained in:
Andreas Kling 2019-06-15 17:52:53 +02:00
parent dcbddb4f8c
commit 694b4a64bd
3 changed files with 8 additions and 4 deletions

View file

@ -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()

Binary file not shown.

After

Width:  |  Height:  |  Size: 334 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 333 B