mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-02-26 01:14:22 +01:00
Ported: Minor tweaks/polish to the navigation controls to prevent interference:
- Reduce controls size
- Enable opacity on hover to increase visibility
- m4gr3d
f1e6ecd3b5
This commit is contained in:
parent
827638bfe0
commit
ea67b36916
@ -4573,7 +4573,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
|
|||||||
top_right_vbox->set_anchors_and_margins_preset(PRESET_TOP_RIGHT, PRESET_MODE_MINSIZE, 2.0 * EDSCALE);
|
top_right_vbox->set_anchors_and_margins_preset(PRESET_TOP_RIGHT, PRESET_MODE_MINSIZE, 2.0 * EDSCALE);
|
||||||
top_right_vbox->set_h_grow_direction(GROW_DIRECTION_BEGIN);
|
top_right_vbox->set_h_grow_direction(GROW_DIRECTION_BEGIN);
|
||||||
|
|
||||||
const int navigation_control_size = 200;
|
const int navigation_control_size = 150;
|
||||||
|
|
||||||
position_control = memnew(ViewportNavigationControl);
|
position_control = memnew(ViewportNavigationControl);
|
||||||
position_control->set_navigation_mode(SpatialEditorViewport::NAVIGATION_MOVE);
|
position_control->set_navigation_mode(SpatialEditorViewport::NAVIGATION_MOVE);
|
||||||
@ -7661,6 +7661,9 @@ void ViewportNavigationControl::_notification(int p_what) {
|
|||||||
if (!is_connected("mouse_exited", this, "_on_mouse_exited")) {
|
if (!is_connected("mouse_exited", this, "_on_mouse_exited")) {
|
||||||
connect("mouse_exited", this, "_on_mouse_exited");
|
connect("mouse_exited", this, "_on_mouse_exited");
|
||||||
}
|
}
|
||||||
|
if (!is_connected("mouse_entered", this, "_on_mouse_entered")) {
|
||||||
|
connect("mouse_entered", this, "_on_mouse_entered");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_what == NOTIFICATION_DRAW && viewport != nullptr) {
|
if (p_what == NOTIFICATION_DRAW && viewport != nullptr) {
|
||||||
@ -7678,7 +7681,7 @@ void ViewportNavigationControl::_draw() {
|
|||||||
float radius = get_size().x / 2.0;
|
float radius = get_size().x / 2.0;
|
||||||
|
|
||||||
const bool focused = focused_index != -1;
|
const bool focused = focused_index != -1;
|
||||||
draw_circle(center, radius, Color(0.5, 0.5, 0.5, focused ? 0.25 : 0.05));
|
draw_circle(center, radius, Color(0.5, 0.5, 0.5, focused || hovered ? 0.35 : 0.15));
|
||||||
|
|
||||||
const Color c = focused ? Color(0.9, 0.9, 0.9, 0.9) : Color(0.5, 0.5, 0.5, 0.25);
|
const Color c = focused ? Color(0.9, 0.9, 0.9, 0.9) : Color(0.5, 0.5, 0.5, 0.25);
|
||||||
|
|
||||||
@ -7689,6 +7692,9 @@ void ViewportNavigationControl::_draw() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ViewportNavigationControl::_process_click(int p_index, Vector2 p_position, bool p_pressed) {
|
void ViewportNavigationControl::_process_click(int p_index, Vector2 p_position, bool p_pressed) {
|
||||||
|
hovered = false;
|
||||||
|
update();
|
||||||
|
|
||||||
if (focused_index != -1 && focused_index != p_index) {
|
if (focused_index != -1 && focused_index != p_index) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -7799,7 +7805,13 @@ void ViewportNavigationControl::_update_navigation() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ViewportNavigationControl::_on_mouse_entered() {
|
||||||
|
hovered = true;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
void ViewportNavigationControl::_on_mouse_exited() {
|
void ViewportNavigationControl::_on_mouse_exited() {
|
||||||
|
hovered = false;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -875,6 +875,7 @@ class ViewportNavigationControl : public Control {
|
|||||||
SpatialEditorViewport *viewport = nullptr;
|
SpatialEditorViewport *viewport = nullptr;
|
||||||
Vector2i focused_mouse_start;
|
Vector2i focused_mouse_start;
|
||||||
Vector2 focused_pos;
|
Vector2 focused_pos;
|
||||||
|
bool hovered = false;
|
||||||
int focused_index = -1;
|
int focused_index = -1;
|
||||||
SpatialEditorViewport::NavigationMode nav_mode = SpatialEditorViewport::NavigationMode::NAVIGATION_NONE;
|
SpatialEditorViewport::NavigationMode nav_mode = SpatialEditorViewport::NavigationMode::NAVIGATION_NONE;
|
||||||
|
|
||||||
@ -885,6 +886,7 @@ protected:
|
|||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
void _gui_input(Ref<InputEvent> p_event);
|
void _gui_input(Ref<InputEvent> p_event);
|
||||||
void _draw();
|
void _draw();
|
||||||
|
void _on_mouse_entered();
|
||||||
void _on_mouse_exited();
|
void _on_mouse_exited();
|
||||||
void _process_click(int p_index, Vector2 p_position, bool p_pressed);
|
void _process_click(int p_index, Vector2 p_position, bool p_pressed);
|
||||||
void _process_drag(int p_index, Vector2 p_position, Vector2 p_relative_position);
|
void _process_drag(int p_index, Vector2 p_position, Vector2 p_relative_position);
|
||||||
|
Loading…
Reference in New Issue
Block a user