Parcourir la source

Highlight hovered inspector categories

Jummit il y a 4 ans
Parent
commit
38b312404b
1 fichiers modifiés avec 9 ajouts et 1 suppressions
  1. 9 1
      editor/editor_inspector.cpp

+ 9 - 1
editor/editor_inspector.cpp

@@ -1266,9 +1266,13 @@ void EditorInspectorSection::_notification(int p_what) {
 			}
 			header_height += get_theme_constant(SNAME("vseparation"), SNAME("Tree"));
 
+			Rect2 header_rect = Rect2(Vector2(), Vector2(get_size().width, header_height));
 			Color c = bg_color;
 			c.a *= 0.4;
-			draw_rect(Rect2(Vector2(), Vector2(get_size().width, header_height)), c);
+			if (foldable && header_rect.has_point(get_local_mouse_position())) {
+				c = c.lightened(Input::get_singleton()->is_mouse_button_pressed(MOUSE_BUTTON_LEFT) ? -0.05 : 0.2);
+			}
+			draw_rect(header_rect, c);
 
 			const int arrow_margin = 2;
 			const int arrow_width = arrow.is_valid() ? arrow->get_width() : 0;
@@ -1315,12 +1319,14 @@ void EditorInspectorSection::_notification(int p_what) {
 			if (dropping) {
 				dropping_unfold_timer->start();
 			}
+			update();
 		} break;
 
 		case NOTIFICATION_MOUSE_EXIT: {
 			if (dropping) {
 				dropping_unfold_timer->stop();
 			}
+			update();
 		} break;
 	}
 }
@@ -1395,6 +1401,8 @@ void EditorInspectorSection::gui_input(const Ref<InputEvent> &p_event) {
 		} else {
 			fold();
 		}
+	} else if (mb.is_valid() && !mb->is_pressed()) {
+		update();
 	}
 }