@@ -343,7 +343,13 @@ void ViewportRotationControl::_draw_axis(const Axis2D &p_axis) {
343
343
const Color axis_color = axis_colors[direction];
344
344
const double min_alpha = 0.35 ;
345
345
const double alpha = focused ? 1.0 : Math::remap ((p_axis.z_axis + 1.0 ) / 2.0 , 0 , 0.5 , min_alpha, 1.0 );
346
- const Color c = focused ? Color (axis_color.lightened (0.75 ), 1.0 ) : Color (axis_color, alpha);
346
+ const Color c = focused ? Color (axis_color.lightened (0.25 ), 1.0 ) : Color (axis_color, alpha);
347
+
348
+ // Highlight positive axis text when hovered.
349
+ const Color c_positive_axis = focused ? Color (1.0 , 1.0 , 1.0 , alpha) : Color (0.0 , 0.0 , 0.0 , alpha * 0.6 );
350
+
351
+ // Highlight negative axis text when hovered, but hide when not focused.
352
+ const Color c_negative_axis = focused ? Color (1.0 , 1.0 , 1.0 , alpha) : Color (axis_color, 0 );
347
353
348
354
if (positive) {
349
355
// Draw axis lines for the positive axes.
@@ -361,11 +367,22 @@ void ViewportRotationControl::_draw_axis(const Axis2D &p_axis) {
361
367
const int font_size = get_theme_font_size (SNAME (" rotation_control_size" ), EditorStringName (EditorFonts));
362
368
const Size2 char_size = font->get_char_size (axis_name[0 ], font_size);
363
369
const Vector2 char_offset = Vector2 (-char_size.width / 2.0 , char_size.height * 0.25 );
364
- draw_char (font, p_axis.screen_point + char_offset, axis_name, font_size, Color ( 0.0 , 0.0 , 0.0 , alpha * 0.6 ) );
370
+ draw_char (font, p_axis.screen_point + char_offset, axis_name, font_size, c_positive_axis );
365
371
} else {
366
372
// Draw an outline around the negative axes.
367
373
draw_circle (p_axis.screen_point , AXIS_CIRCLE_RADIUS, c, true , -1.0 , true );
368
374
draw_circle (p_axis.screen_point , AXIS_CIRCLE_RADIUS * 0.8 , c.darkened (0.4 ), true , -1.0 , true );
375
+
376
+ // Draw the text for the negative axes.
377
+ const String axis_name = direction == 0 ? " -X" : (direction == 1 ? " -Y" : " -Z" );
378
+ const Ref<Font> &font = get_theme_font (SNAME (" rotation_control" ), EditorStringName (EditorFonts));
379
+ const int font_size = get_theme_font_size (SNAME (" rotation_control_size" ), EditorStringName (EditorFonts));
380
+ const Size2 string_size = font->get_string_size (axis_name, HORIZONTAL_ALIGNMENT_LEFT, -1 .0f , font_size);
381
+ const float font_ascent = font->get_ascent (font_size);
382
+ const float font_descent = font->get_descent (font_size);
383
+ const float string_height = font_ascent + font_descent;
384
+ const Vector2 offset (-string_size.width / 2.0 , string_height * 0.25 );
385
+ draw_string (font, p_axis.screen_point + offset, axis_name, HORIZONTAL_ALIGNMENT_LEFT, -1 .0f , font_size, c_negative_axis);
369
386
}
370
387
}
371
388
0 commit comments