Skip to content

Commit e453351

Browse files
committed
Make button icons smaller, add function to ToolIcon class for setting the mode
1 parent 69c0aac commit e453351

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
@@ -197,6 +197,24 @@ Editor::Editor() :
197197
mode_button->set_help_text(_("Toggle between object and tile mode"));
198198

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

202220
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)