mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-15 04:13:11 +00:00
PaintBrush: Make little icons for the pen and bucket tools.
This commit is contained in:
parent
dcbddb4f8c
commit
694b4a64bd
|
@ -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
Normal file
BIN
Base/res/icons/paintbrush/bucket.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 334 B |
BIN
Base/res/icons/paintbrush/pen.png
Normal file
BIN
Base/res/icons/paintbrush/pen.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 333 B |
Loading…
Reference in a new issue