|
@@ -1172,6 +1172,36 @@ void EditorInspectorSection::_test_unfold() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+Ref<Texture2D> EditorInspectorSection::_get_arrow() {
|
|
|
+ Ref<Texture2D> arrow;
|
|
|
+ if (foldable) {
|
|
|
+ if (object->editor_is_section_unfolded(section)) {
|
|
|
+ arrow = get_theme_icon(SNAME("arrow"), SNAME("Tree"));
|
|
|
+ } else {
|
|
|
+ if (is_layout_rtl()) {
|
|
|
+ arrow = get_theme_icon(SNAME("arrow_collapsed_mirrored"), SNAME("Tree"));
|
|
|
+ } else {
|
|
|
+ arrow = get_theme_icon(SNAME("arrow_collapsed"), SNAME("Tree"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return arrow;
|
|
|
+}
|
|
|
+
|
|
|
+int EditorInspectorSection::_get_header_height() {
|
|
|
+ Ref<Font> font = get_theme_font(SNAME("bold"), SNAME("EditorFonts"));
|
|
|
+ int font_size = get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts"));
|
|
|
+
|
|
|
+ int header_height = font->get_height(font_size);
|
|
|
+ Ref<Texture2D> arrow = _get_arrow();
|
|
|
+ if (arrow.is_valid()) {
|
|
|
+ header_height = MAX(header_height, arrow->get_height());
|
|
|
+ }
|
|
|
+ header_height += get_theme_constant(SNAME("v_separation"), SNAME("Tree"));
|
|
|
+
|
|
|
+ return header_height;
|
|
|
+}
|
|
|
+
|
|
|
void EditorInspectorSection::_notification(int p_what) {
|
|
|
switch (p_what) {
|
|
|
case NOTIFICATION_THEME_CHANGED: {
|
|
@@ -1182,30 +1212,6 @@ void EditorInspectorSection::_notification(int p_what) {
|
|
|
if (!vbox_added) {
|
|
|
return;
|
|
|
}
|
|
|
- // Get the section header font.
|
|
|
- Ref<Font> font = get_theme_font(SNAME("bold"), SNAME("EditorFonts"));
|
|
|
- int font_size = get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts"));
|
|
|
-
|
|
|
- // Get the right direction arrow texture, if the section is foldable.
|
|
|
- Ref<Texture2D> arrow;
|
|
|
- if (foldable) {
|
|
|
- if (object->editor_is_section_unfolded(section)) {
|
|
|
- arrow = get_theme_icon(SNAME("arrow"), SNAME("Tree"));
|
|
|
- } else {
|
|
|
- if (is_layout_rtl()) {
|
|
|
- arrow = get_theme_icon(SNAME("arrow_collapsed_mirrored"), SNAME("Tree"));
|
|
|
- } else {
|
|
|
- arrow = get_theme_icon(SNAME("arrow_collapsed"), SNAME("Tree"));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // Compute the height of the section header.
|
|
|
- int header_height = font->get_height(font_size);
|
|
|
- if (arrow.is_valid()) {
|
|
|
- header_height = MAX(header_height, arrow->get_height());
|
|
|
- }
|
|
|
- header_height += get_theme_constant(SNAME("v_separation"), SNAME("Tree"));
|
|
|
|
|
|
int inspector_margin = get_theme_constant(SNAME("inspector_margin"), SNAME("Editor"));
|
|
|
int section_indent_size = get_theme_constant(SNAME("indent_size"), SNAME("EditorInspectorSection"));
|
|
@@ -1218,6 +1224,7 @@ void EditorInspectorSection::_notification(int p_what) {
|
|
|
}
|
|
|
|
|
|
Size2 size = get_size() - Vector2(inspector_margin, 0);
|
|
|
+ int header_height = _get_header_height();
|
|
|
Vector2 offset = Vector2(is_layout_rtl() ? 0 : inspector_margin, header_height);
|
|
|
for (int i = 0; i < get_child_count(); i++) {
|
|
|
Control *c = Object::cast_to<Control>(get_child(i));
|
|
@@ -1233,36 +1240,6 @@ void EditorInspectorSection::_notification(int p_what) {
|
|
|
} break;
|
|
|
|
|
|
case NOTIFICATION_DRAW: {
|
|
|
- // Get the section header font.
|
|
|
- Ref<Font> font = get_theme_font(SNAME("bold"), SNAME("EditorFonts"));
|
|
|
- int font_size = get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts"));
|
|
|
- Color font_color = get_theme_color(SNAME("font_color"), SNAME("Editor"));
|
|
|
-
|
|
|
- // Get the right direction arrow texture, if the section is foldable.
|
|
|
- Ref<Texture2D> arrow;
|
|
|
- bool folded = foldable;
|
|
|
- if (foldable) {
|
|
|
- if (object->editor_is_section_unfolded(section)) {
|
|
|
- arrow = get_theme_icon(SNAME("arrow"), SNAME("Tree"));
|
|
|
- folded = false;
|
|
|
- } else {
|
|
|
- if (is_layout_rtl()) {
|
|
|
- arrow = get_theme_icon(SNAME("arrow_collapsed_mirrored"), SNAME("Tree"));
|
|
|
- } else {
|
|
|
- arrow = get_theme_icon(SNAME("arrow_collapsed"), SNAME("Tree"));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- bool rtl = is_layout_rtl();
|
|
|
-
|
|
|
- // Compute the height and width of the section header.
|
|
|
- int header_height = font->get_height(font_size);
|
|
|
- if (arrow.is_valid()) {
|
|
|
- header_height = MAX(header_height, arrow->get_height());
|
|
|
- }
|
|
|
- header_height += get_theme_constant(SNAME("v_separation"), SNAME("Tree"));
|
|
|
-
|
|
|
int section_indent = 0;
|
|
|
int section_indent_size = get_theme_constant(SNAME("indent_size"), SNAME("EditorInspectorSection"));
|
|
|
if (indent_depth > 0 && section_indent_size > 0) {
|
|
@@ -1275,11 +1252,13 @@ void EditorInspectorSection::_notification(int p_what) {
|
|
|
|
|
|
int header_width = get_size().width - section_indent;
|
|
|
int header_offset_x = 0.0;
|
|
|
+ bool rtl = is_layout_rtl();
|
|
|
if (!rtl) {
|
|
|
header_offset_x += section_indent;
|
|
|
}
|
|
|
|
|
|
// Draw header area.
|
|
|
+ int header_height = _get_header_height();
|
|
|
Rect2 header_rect = Rect2(Vector2(header_offset_x, 0.0), Vector2(header_width, header_height));
|
|
|
Color c = bg_color;
|
|
|
c.a *= 0.4;
|
|
@@ -1288,7 +1267,7 @@ void EditorInspectorSection::_notification(int p_what) {
|
|
|
}
|
|
|
draw_rect(header_rect, c);
|
|
|
|
|
|
- // Draw header title, folding arrow and coutn of revertable properties.
|
|
|
+ // Draw header title, folding arrow and count of revertable properties.
|
|
|
{
|
|
|
int separation = Math::round(2 * EDSCALE);
|
|
|
|
|
@@ -1296,6 +1275,7 @@ void EditorInspectorSection::_notification(int p_what) {
|
|
|
int margin_end = separation;
|
|
|
|
|
|
// - Arrow.
|
|
|
+ Ref<Texture2D> arrow = _get_arrow();
|
|
|
if (arrow.is_valid()) {
|
|
|
Point2 arrow_position;
|
|
|
if (rtl) {
|
|
@@ -1313,6 +1293,13 @@ void EditorInspectorSection::_notification(int p_what) {
|
|
|
// - Count of revertable properties.
|
|
|
String num_revertable_str;
|
|
|
int num_revertable_width = 0;
|
|
|
+
|
|
|
+ bool folded = foldable && !object->editor_is_section_unfolded(section);
|
|
|
+
|
|
|
+ Ref<Font> font = get_theme_font(SNAME("bold"), SNAME("EditorFonts"));
|
|
|
+ int font_size = get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts"));
|
|
|
+ Color font_color = get_theme_color(SNAME("font_color"), SNAME("Editor"));
|
|
|
+
|
|
|
if (folded && revertable_properties.size()) {
|
|
|
int label_width = font->get_string_size(label, HORIZONTAL_ALIGNMENT_LEFT, available, font_size, TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_CONSTRAIN_ELLIPSIS).x;
|
|
|
|
|
@@ -1481,10 +1468,12 @@ void EditorInspectorSection::gui_input(const Ref<InputEvent> &p_event) {
|
|
|
|
|
|
Ref<InputEventMouseButton> mb = p_event;
|
|
|
if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT) {
|
|
|
- Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Tree"));
|
|
|
- int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Tree"));
|
|
|
- if (mb->get_position().y > font->get_height(font_size)) { //clicked outside
|
|
|
- return;
|
|
|
+ if (object->editor_is_section_unfolded(section)) {
|
|
|
+ int header_height = _get_header_height();
|
|
|
+
|
|
|
+ if (mb->get_position().y >= header_height) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
accept_event();
|