Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TileMapEditor] Improve tool picking usability #28491

Merged
merged 1 commit into from
Apr 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 36 additions & 13 deletions editor/plugins/tile_map_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ void TileMapEditor::_update_button_tool() {
default:
break;
}

if (tool != TOOL_PICKING)
last_tool = tool;
}

void TileMapEditor::_button_tool_select(int p_tool) {
Expand Down Expand Up @@ -949,11 +952,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {

if (mb->get_shift()) {

#ifdef APPLE_STYLE_KEYS
if (mb->get_command())
#else
if (mb->get_control())
#endif
tool = TOOL_RECTANGLE_PAINT;
else
tool = TOOL_LINE_PAINT;
Expand All @@ -964,11 +963,8 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
_update_button_tool();
return true;
}
#ifdef APPLE_STYLE_KEYS

if (mb->get_command()) {
#else
if (mb->get_control()) {
#endif
tool = TOOL_PICKING;
_pick_tile(over_tile);
_update_button_tool();
Expand Down Expand Up @@ -1136,11 +1132,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
_start_undo(TTR("Erase TileMap"));

if (mb->get_shift()) {
#ifdef APPLE_STYLE_KEYS
if (mb->get_command())
#else
if (mb->get_control())
#endif
tool = TOOL_RECTANGLE_ERASE;
else
tool = TOOL_LINE_ERASE;
Expand Down Expand Up @@ -1344,6 +1336,14 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {

if (k.is_valid() && k->is_pressed()) {

if (last_tool == TOOL_NONE && tool == TOOL_PICKING && k->get_scancode() == KEY_SHIFT && k->get_command()) {
// trying to draw a rectangle with the painting tool, so change to the correct tool
tool = last_tool;

CanvasItemEditor::get_singleton()->update_viewport();
_update_button_tool();
}

if (k->get_scancode() == KEY_ESCAPE) {

if (tool == TOOL_PASTING)
Expand Down Expand Up @@ -1448,8 +1448,30 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
CanvasItemEditor::get_singleton()->update_viewport();
return true;
}
}
} else if (k.is_valid()) { // release event

if (tool == TOOL_NONE) {

if (k->get_scancode() == KEY_SHIFT && k->get_command()) {

tool = TOOL_PICKING;
_update_button_tool();
}
} else if (tool == TOOL_PICKING) {

#ifdef APPLE_STYLE_KEYS
if (k->get_scancode() == KEY_META) {
#else
if (k->get_scancode() == KEY_CONTROL) {
akien-mga marked this conversation as resolved.
Show resolved Hide resolved
#endif
// go back to that last tool if KEY_CONTROL was released
tool = last_tool;

CanvasItemEditor::get_singleton()->update_viewport();
_update_button_tool();
}
}
}
return false;
}

Expand Down Expand Up @@ -1923,6 +1945,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
// Tools
paint_button = memnew(ToolButton);
paint_button->set_shortcut(ED_SHORTCUT("tile_map_editor/paint_tile", TTR("Paint Tile"), KEY_P));
paint_button->set_tooltip(TTR("Shift+RMB: Line Draw\nShift+Ctrl+RMB: Rectangle Paint"));
paint_button->connect("pressed", this, "_button_tool_select", make_binds(TOOL_NONE));
paint_button->set_toggle_mode(true);
toolbar->add_child(paint_button);
Expand Down
1 change: 1 addition & 0 deletions editor/plugins/tile_map_editor_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class TileMapEditor : public VBoxContainer {
CheckBox *manual_button;

Tool tool;
Tool last_tool;

bool selection_active;
bool mouse_over;
Expand Down