Skip to content

Commit 442ba42

Browse files
committed
Make button icons smaller, add function to ToolIcon class for setting the mode
1 parent 11c4836 commit 442ba42

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

src/editor/button_widget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ ButtonWidget::draw(DrawingContext& context)
4343
LAYER_GUI-5);
4444

4545
if (m_sprite) {
46-
m_sprite->draw(context.color(), m_rect.p1(), LAYER_GUI-5);
46+
m_sprite->draw_scaled(context.color(), m_rect.grown(-4.0f), LAYER_GUI - 5);
4747
}
4848

4949
if (m_grab) {

src/editor/editor.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,24 @@ Editor::Editor() :
196196
mode_button->set_help_text(_("Toggle between object and tile mode"));
197197

198198
m_widgets.insert(m_widgets.begin() + 5, std::move(mode_button));
199+
200+
auto select_mode_mouse_button = std::make_unique<ButtonWidget>(
201+
"images/engine/editor/select-mode0.png", Vector(192, 0), [] {});
202+
select_mode_mouse_button->set_help_text(_("Draw mode (The current tool applies to the tile under the mouse)"));
203+
auto select_mode_area_button = std::make_unique<ButtonWidget>(
204+
"images/engine/editor/select-mode1.png", Vector(224, 0), [] {});
205+
select_mode_area_button->set_help_text(_("Box draw mode (The current tool applies to an area / box drawn with the mouse)"));
206+
auto select_mode_fill_button = std::make_unique<ButtonWidget>(
207+
"images/engine/editor/select-mode2.png", Vector(256, 0), [] {});
208+
select_mode_fill_button->set_help_text(_("Fill mode (The current tool applies to the empty area in the enclosed space that was clicked)"));
209+
auto select_mode_same_button = std::make_unique<ButtonWidget>(
210+
"images/engine/editor/select-mode3.png", Vector(288, 0), [] {});
211+
select_mode_same_button->set_help_text(_("Replace mode (The current tool applies to all tiles that are the same tile as the one under the mouse)"));
212+
213+
m_widgets.insert(m_widgets.begin() + 6, std::move(select_mode_mouse_button));
214+
m_widgets.insert(m_widgets.begin() + 7, std::move(select_mode_area_button));
215+
m_widgets.insert(m_widgets.begin() + 8, std::move(select_mode_fill_button));
216+
m_widgets.insert(m_widgets.begin() + 9, std::move(select_mode_same_button));
199217
}
200218

201219
Editor::~Editor()

src/editor/tool_icon.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,16 @@ ToolIcon::draw(DrawingContext& context)
4545
void
4646
ToolIcon::next_mode()
4747
{
48-
m_mode++;
49-
if (m_mode >= m_surf_count) {
48+
set_mode(m_mode + 1);
49+
}
50+
51+
void
52+
ToolIcon::set_mode(int mode)
53+
{
54+
m_mode = mode;
55+
56+
if (m_mode >= m_surf_count)
57+
{
5058
m_mode = 0;
5159
}
5260
}

src/editor/tool_icon.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class ToolIcon final
3333
void draw(DrawingContext& context);
3434

3535
inline int get_mode() const { return m_mode; }
36+
void set_mode(int mode);
3637

3738
void next_mode();
3839

0 commit comments

Comments
 (0)