Minor tweaks/polish to the navigation controls to prevent interference:
- Reduce controls size - Enable opacity on hover to increase visibility
This commit is contained in:
parent
30800d20f4
commit
eacb29c007
2 changed files with 16 additions and 2 deletions
editor/plugins
|
@ -92,6 +92,9 @@ void ViewportNavigationControl::_notification(int p_what) {
|
||||||
if (!is_connected("mouse_exited", callable_mp(this, &ViewportNavigationControl::_on_mouse_exited))) {
|
if (!is_connected("mouse_exited", callable_mp(this, &ViewportNavigationControl::_on_mouse_exited))) {
|
||||||
connect("mouse_exited", callable_mp(this, &ViewportNavigationControl::_on_mouse_exited));
|
connect("mouse_exited", callable_mp(this, &ViewportNavigationControl::_on_mouse_exited));
|
||||||
}
|
}
|
||||||
|
if (!is_connected("mouse_entered", callable_mp(this, &ViewportNavigationControl::_on_mouse_entered))) {
|
||||||
|
connect("mouse_entered", callable_mp(this, &ViewportNavigationControl::_on_mouse_entered));
|
||||||
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case NOTIFICATION_DRAW: {
|
case NOTIFICATION_DRAW: {
|
||||||
|
@ -112,7 +115,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);
|
||||||
|
|
||||||
|
@ -123,6 +126,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;
|
||||||
|
queue_redraw();
|
||||||
|
|
||||||
if (focused_index != -1 && focused_index != p_index) {
|
if (focused_index != -1 && focused_index != p_index) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -233,7 +239,13 @@ void ViewportNavigationControl::_update_navigation() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ViewportNavigationControl::_on_mouse_entered() {
|
||||||
|
hovered = true;
|
||||||
|
queue_redraw();
|
||||||
|
}
|
||||||
|
|
||||||
void ViewportNavigationControl::_on_mouse_exited() {
|
void ViewportNavigationControl::_on_mouse_exited() {
|
||||||
|
hovered = false;
|
||||||
queue_redraw();
|
queue_redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5133,7 +5145,7 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, int p
|
||||||
// Prevent visible spacing between frame time labels.
|
// Prevent visible spacing between frame time labels.
|
||||||
top_right_vbox->add_theme_constant_override("separation", 0);
|
top_right_vbox->add_theme_constant_override("separation", 0);
|
||||||
|
|
||||||
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(Node3DEditorViewport::NAVIGATION_MOVE);
|
position_control->set_navigation_mode(Node3DEditorViewport::NAVIGATION_MOVE);
|
||||||
|
|
|
@ -930,6 +930,7 @@ class ViewportNavigationControl : public Control {
|
||||||
Node3DEditorViewport *viewport = nullptr;
|
Node3DEditorViewport *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;
|
||||||
Node3DEditorViewport::NavigationMode nav_mode = Node3DEditorViewport::NavigationMode::NAVIGATION_NONE;
|
Node3DEditorViewport::NavigationMode nav_mode = Node3DEditorViewport::NavigationMode::NAVIGATION_NONE;
|
||||||
|
|
||||||
|
@ -939,6 +940,7 @@ protected:
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
virtual void gui_input(const Ref<InputEvent> &p_event) override;
|
virtual void gui_input(const Ref<InputEvent> &p_event) override;
|
||||||
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 a new issue