Merge pull request #59468 from EricEzaM/fix-zoom-shortcuts
Fix zoom in/out keyboard shortcuts not working
This commit is contained in:
commit
86a836f9e3
5 changed files with 13 additions and 3 deletions
|
@ -161,13 +161,19 @@ void EditorZoomWidget::_bind_methods() {
|
||||||
ADD_SIGNAL(MethodInfo("zoom_changed", PropertyInfo(Variant::FLOAT, "zoom")));
|
ADD_SIGNAL(MethodInfo("zoom_changed", PropertyInfo(Variant::FLOAT, "zoom")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditorZoomWidget::set_shortcut_context(Node *p_node) const {
|
||||||
|
zoom_minus->set_shortcut_context(p_node);
|
||||||
|
zoom_plus->set_shortcut_context(p_node);
|
||||||
|
zoom_reset->set_shortcut_context(p_node);
|
||||||
|
}
|
||||||
|
|
||||||
EditorZoomWidget::EditorZoomWidget() {
|
EditorZoomWidget::EditorZoomWidget() {
|
||||||
// Zoom buttons
|
// Zoom buttons
|
||||||
zoom_minus = memnew(Button);
|
zoom_minus = memnew(Button);
|
||||||
zoom_minus->set_flat(true);
|
zoom_minus->set_flat(true);
|
||||||
add_child(zoom_minus);
|
add_child(zoom_minus);
|
||||||
zoom_minus->connect("pressed", callable_mp(this, &EditorZoomWidget::_button_zoom_minus));
|
zoom_minus->connect("pressed", callable_mp(this, &EditorZoomWidget::_button_zoom_minus));
|
||||||
zoom_minus->set_shortcut(ED_SHORTCUT("canvas_item_editor/zoom_minus", TTR("Zoom Out"), KeyModifierMask::CMD_OR_CTRL | Key::MINUS));
|
zoom_minus->set_shortcut(ED_SHORTCUT_ARRAY("canvas_item_editor/zoom_minus", TTR("Zoom Out"), { int32_t(KeyModifierMask::CMD_OR_CTRL | Key::MINUS), int32_t(KeyModifierMask::CMD_OR_CTRL | Key::KP_SUBTRACT) }));
|
||||||
zoom_minus->set_shortcut_context(this);
|
zoom_minus->set_shortcut_context(this);
|
||||||
zoom_minus->set_focus_mode(FOCUS_NONE);
|
zoom_minus->set_focus_mode(FOCUS_NONE);
|
||||||
|
|
||||||
|
@ -189,7 +195,7 @@ EditorZoomWidget::EditorZoomWidget() {
|
||||||
zoom_plus->set_flat(true);
|
zoom_plus->set_flat(true);
|
||||||
add_child(zoom_plus);
|
add_child(zoom_plus);
|
||||||
zoom_plus->connect("pressed", callable_mp(this, &EditorZoomWidget::_button_zoom_plus));
|
zoom_plus->connect("pressed", callable_mp(this, &EditorZoomWidget::_button_zoom_plus));
|
||||||
zoom_plus->set_shortcut(ED_SHORTCUT("canvas_item_editor/zoom_plus", TTR("Zoom In"), KeyModifierMask::CMD_OR_CTRL | Key::EQUAL)); // Usually direct access key for PLUS
|
zoom_plus->set_shortcut(ED_SHORTCUT_ARRAY("canvas_item_editor/zoom_plus", TTR("Zoom In"), { int32_t(KeyModifierMask::CMD_OR_CTRL | Key::EQUAL), int32_t(KeyModifierMask::CMD_OR_CTRL | Key::KP_ADD) }));
|
||||||
zoom_plus->set_shortcut_context(this);
|
zoom_plus->set_shortcut_context(this);
|
||||||
zoom_plus->set_focus_mode(FOCUS_NONE);
|
zoom_plus->set_focus_mode(FOCUS_NONE);
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,8 @@ public:
|
||||||
float get_zoom();
|
float get_zoom();
|
||||||
void set_zoom(float p_zoom);
|
void set_zoom(float p_zoom);
|
||||||
void set_zoom_by_increments(int p_increment_count, bool p_integer_only = false);
|
void set_zoom_by_increments(int p_increment_count, bool p_integer_only = false);
|
||||||
|
// Sets the shortcut context for the zoom buttons. By default their context is this EditorZoomWidget control.
|
||||||
|
void set_shortcut_context(Node *p_node) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // EDITOR_ZOOM_WIDGET_H
|
#endif // EDITOR_ZOOM_WIDGET_H
|
||||||
|
|
|
@ -5060,6 +5060,7 @@ CanvasItemEditor::CanvasItemEditor() {
|
||||||
zoom_widget = memnew(EditorZoomWidget);
|
zoom_widget = memnew(EditorZoomWidget);
|
||||||
controls_vb->add_child(zoom_widget);
|
controls_vb->add_child(zoom_widget);
|
||||||
zoom_widget->set_anchors_and_offsets_preset(Control::PRESET_TOP_LEFT, Control::PRESET_MODE_MINSIZE, 2 * EDSCALE);
|
zoom_widget->set_anchors_and_offsets_preset(Control::PRESET_TOP_LEFT, Control::PRESET_MODE_MINSIZE, 2 * EDSCALE);
|
||||||
|
zoom_widget->set_shortcut_context(this);
|
||||||
zoom_widget->connect("zoom_changed", callable_mp(this, &CanvasItemEditor::_update_zoom));
|
zoom_widget->connect("zoom_changed", callable_mp(this, &CanvasItemEditor::_update_zoom));
|
||||||
|
|
||||||
panner.instantiate();
|
panner.instantiate();
|
||||||
|
|
|
@ -533,11 +533,11 @@ TileAtlasView::TileAtlasView() {
|
||||||
panel->set_v_size_flags(SIZE_EXPAND_FILL);
|
panel->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||||
add_child(panel);
|
add_child(panel);
|
||||||
|
|
||||||
// Scrollingsc
|
|
||||||
zoom_widget = memnew(EditorZoomWidget);
|
zoom_widget = memnew(EditorZoomWidget);
|
||||||
add_child(zoom_widget);
|
add_child(zoom_widget);
|
||||||
zoom_widget->set_anchors_and_offsets_preset(Control::PRESET_TOP_LEFT, Control::PRESET_MODE_MINSIZE, 2 * EDSCALE);
|
zoom_widget->set_anchors_and_offsets_preset(Control::PRESET_TOP_LEFT, Control::PRESET_MODE_MINSIZE, 2 * EDSCALE);
|
||||||
zoom_widget->connect("zoom_changed", callable_mp(this, &TileAtlasView::_zoom_widget_changed).unbind(1));
|
zoom_widget->connect("zoom_changed", callable_mp(this, &TileAtlasView::_zoom_widget_changed).unbind(1));
|
||||||
|
zoom_widget->set_shortcut_context(this);
|
||||||
|
|
||||||
button_center_view = memnew(Button);
|
button_center_view = memnew(Button);
|
||||||
button_center_view->set_icon(get_theme_icon(SNAME("CenterView"), SNAME("EditorIcons")));
|
button_center_view->set_icon(get_theme_icon(SNAME("CenterView"), SNAME("EditorIcons")));
|
||||||
|
|
|
@ -831,6 +831,7 @@ GenericTilePolygonEditor::GenericTilePolygonEditor() {
|
||||||
editor_zoom_widget = memnew(EditorZoomWidget);
|
editor_zoom_widget = memnew(EditorZoomWidget);
|
||||||
editor_zoom_widget->set_position(Vector2(5, 5));
|
editor_zoom_widget->set_position(Vector2(5, 5));
|
||||||
editor_zoom_widget->connect("zoom_changed", callable_mp(this, &GenericTilePolygonEditor::_zoom_changed).unbind(1));
|
editor_zoom_widget->connect("zoom_changed", callable_mp(this, &GenericTilePolygonEditor::_zoom_changed).unbind(1));
|
||||||
|
editor_zoom_widget->set_shortcut_context(this);
|
||||||
root->add_child(editor_zoom_widget);
|
root->add_child(editor_zoom_widget);
|
||||||
|
|
||||||
button_center_view = memnew(Button);
|
button_center_view = memnew(Button);
|
||||||
|
|
Loading…
Reference in a new issue