|
@@ -4,13 +4,15 @@
|
|
#include "PenTool.h"
|
|
#include "PenTool.h"
|
|
#include <LibGUI/GBoxLayout.h>
|
|
#include <LibGUI/GBoxLayout.h>
|
|
#include <LibGUI/GButton.h>
|
|
#include <LibGUI/GButton.h>
|
|
|
|
+#include <SharedGraphics/PNGLoader.h>
|
|
|
|
|
|
class ToolButton final : public GButton {
|
|
class ToolButton final : public GButton {
|
|
public:
|
|
public:
|
|
ToolButton(const String& name, GWidget* parent, OwnPtr<Tool>&& tool)
|
|
ToolButton(const String& name, GWidget* parent, OwnPtr<Tool>&& tool)
|
|
- : GButton(name, parent)
|
|
|
|
|
|
+ : GButton(parent)
|
|
, m_tool(move(tool))
|
|
, m_tool(move(tool))
|
|
{
|
|
{
|
|
|
|
+ set_tooltip(name);
|
|
}
|
|
}
|
|
|
|
|
|
const Tool& tool() const { return *m_tool; }
|
|
const Tool& tool() const { return *m_tool; }
|
|
@@ -36,13 +38,15 @@ ToolboxWidget::ToolboxWidget(GWidget* parent)
|
|
set_layout(make<GBoxLayout>(Orientation::Vertical));
|
|
set_layout(make<GBoxLayout>(Orientation::Vertical));
|
|
layout()->set_margins({ 4, 4, 4, 4 });
|
|
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));
|
|
auto* button = new ToolButton(name, this, move(tool));
|
|
button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
|
button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
|
button->set_preferred_size({ 0, 32 });
|
|
button->set_preferred_size({ 0, 32 });
|
|
button->set_checkable(true);
|
|
button->set_checkable(true);
|
|
button->set_exclusive(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) {
|
|
button->on_checked = [button](auto checked) {
|
|
if (checked)
|
|
if (checked)
|
|
PaintableWidget::the().set_tool(&button->tool());
|
|
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()
|
|
ToolboxWidget::~ToolboxWidget()
|