Improved Inspector Sub-Resource Editing
This commit is contained in:
parent
f30d827448
commit
f28c089d64
@ -71,7 +71,7 @@ Size2 EditorProperty::get_minimum_size() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (bottom_editor != NULL && bottom_editor->is_visible()) {
|
if (bottom_editor != NULL && bottom_editor->is_visible()) {
|
||||||
ms.height += get_constant("vseparation", "Tree");
|
ms.height += get_constant("vseparation");
|
||||||
Size2 bems = bottom_editor->get_combined_minimum_size();
|
Size2 bems = bottom_editor->get_combined_minimum_size();
|
||||||
//bems.width += get_constant("item_margin", "Tree");
|
//bems.width += get_constant("item_margin", "Tree");
|
||||||
ms.height += bems.height;
|
ms.height += bems.height;
|
||||||
@ -135,7 +135,7 @@ void EditorProperty::_notification(int p_what) {
|
|||||||
|
|
||||||
int m = 0; //get_constant("item_margin", "Tree");
|
int m = 0; //get_constant("item_margin", "Tree");
|
||||||
|
|
||||||
bottom_rect = Rect2(m, rect.size.height + get_constant("vseparation", "Tree"), size.width - m, bottom_editor->get_combined_minimum_size().height);
|
bottom_rect = Rect2(m, rect.size.height + get_constant("vseparation"), size.width - m, bottom_editor->get_combined_minimum_size().height);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keying) {
|
if (keying) {
|
||||||
@ -189,11 +189,15 @@ void EditorProperty::_notification(int p_what) {
|
|||||||
size.height = label_reference->get_size().height;
|
size.height = label_reference->get_size().height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ref<StyleBox> sb;
|
||||||
if (selected) {
|
if (selected) {
|
||||||
Ref<StyleBox> sb = get_stylebox("selected", "Tree");
|
sb = get_stylebox("bg_selected");
|
||||||
draw_style_box(sb, Rect2(Vector2(), size));
|
} else {
|
||||||
|
sb = get_stylebox("bg");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
draw_style_box(sb, Rect2(Vector2(), size));
|
||||||
|
|
||||||
if (draw_top_bg && right_child_rect != Rect2()) {
|
if (draw_top_bg && right_child_rect != Rect2()) {
|
||||||
draw_rect(right_child_rect, dark_color);
|
draw_rect(right_child_rect, dark_color);
|
||||||
}
|
}
|
||||||
@ -203,15 +207,15 @@ void EditorProperty::_notification(int p_what) {
|
|||||||
|
|
||||||
Color color;
|
Color color;
|
||||||
if (draw_red) {
|
if (draw_red) {
|
||||||
color = get_color("error_color", "Editor");
|
color = get_color("error_color");
|
||||||
} else {
|
} else {
|
||||||
color = get_color("property_color", "Editor");
|
color = get_color("property_color");
|
||||||
}
|
}
|
||||||
if (label.find(".") != -1) {
|
if (label.find(".") != -1) {
|
||||||
color.a = 0.5; //this should be un-hacked honestly, as it's used for editor overrides
|
color.a = 0.5; //this should be un-hacked honestly, as it's used for editor overrides
|
||||||
}
|
}
|
||||||
|
|
||||||
int ofs = 0;
|
int ofs = get_constant("font_offset");
|
||||||
int text_limit = text_size;
|
int text_limit = text_size;
|
||||||
|
|
||||||
if (checkable) {
|
if (checkable) {
|
||||||
@ -1972,17 +1976,30 @@ int EditorInspector::get_scroll_offset() const {
|
|||||||
return get_v_scroll();
|
return get_v_scroll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditorInspector::_update_inspector_bg() {
|
||||||
|
if (sub_inspector) {
|
||||||
|
int count_subinspectors = 0;
|
||||||
|
Node *n = get_parent();
|
||||||
|
while (n) {
|
||||||
|
EditorInspector *ei = Object::cast_to<EditorInspector>(n);
|
||||||
|
if (ei && ei->sub_inspector) {
|
||||||
|
count_subinspectors++;
|
||||||
|
}
|
||||||
|
n = n->get_parent();
|
||||||
|
}
|
||||||
|
count_subinspectors = MIN(15, count_subinspectors);
|
||||||
|
add_style_override("bg", get_stylebox("sub_inspector_bg" + itos(count_subinspectors), "Editor"));
|
||||||
|
} else {
|
||||||
|
add_style_override("bg", get_stylebox("bg", "Tree"));
|
||||||
|
}
|
||||||
|
}
|
||||||
void EditorInspector::set_sub_inspector(bool p_enable) {
|
void EditorInspector::set_sub_inspector(bool p_enable) {
|
||||||
|
|
||||||
sub_inspector = p_enable;
|
sub_inspector = p_enable;
|
||||||
if (!is_inside_tree())
|
if (!is_inside_tree())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (sub_inspector) {
|
_update_inspector_bg();
|
||||||
add_style_override("bg", get_stylebox("sub_inspector_bg", "Editor"));
|
|
||||||
} else {
|
|
||||||
add_style_override("bg", get_stylebox("bg", "Tree"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorInspector::_edit_request_change(Object *p_object, const String &p_property) {
|
void EditorInspector::_edit_request_change(Object *p_object, const String &p_property) {
|
||||||
@ -2203,10 +2220,8 @@ void EditorInspector::_notification(int p_what) {
|
|||||||
|
|
||||||
if (p_what == NOTIFICATION_ENTER_TREE) {
|
if (p_what == NOTIFICATION_ENTER_TREE) {
|
||||||
|
|
||||||
if (sub_inspector) {
|
_update_inspector_bg();
|
||||||
add_style_override("bg", get_stylebox("sub_inspector_bg", "Editor"));
|
if (!sub_inspector) {
|
||||||
} else {
|
|
||||||
add_style_override("bg", get_stylebox("bg", "Tree"));
|
|
||||||
get_tree()->connect("node_removed", this, "_node_removed");
|
get_tree()->connect("node_removed", this, "_node_removed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2266,11 +2281,7 @@ void EditorInspector::_notification(int p_what) {
|
|||||||
|
|
||||||
if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
|
if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
|
||||||
|
|
||||||
if (sub_inspector) {
|
_update_inspector_bg();
|
||||||
add_style_override("bg", get_stylebox("sub_inspector_bg", "Editor"));
|
|
||||||
} else if (is_inside_tree()) {
|
|
||||||
add_style_override("bg", get_stylebox("bg", "Tree"));
|
|
||||||
}
|
|
||||||
|
|
||||||
update_tree();
|
update_tree();
|
||||||
}
|
}
|
||||||
|
@ -328,6 +328,8 @@ class EditorInspector : public ScrollContainer {
|
|||||||
|
|
||||||
bool _is_property_disabled_by_feature_profile(const StringName &p_property);
|
bool _is_property_disabled_by_feature_profile(const StringName &p_property);
|
||||||
|
|
||||||
|
void _update_inspector_bg();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
@ -381,6 +383,7 @@ public:
|
|||||||
String get_object_class() const;
|
String get_object_class() const;
|
||||||
|
|
||||||
void set_sub_inspector(bool p_enable);
|
void set_sub_inspector(bool p_enable);
|
||||||
|
bool is_sub_inspector() const { return sub_inspector; }
|
||||||
|
|
||||||
EditorInspector();
|
EditorInspector();
|
||||||
};
|
};
|
||||||
|
@ -6036,7 +6036,7 @@ EditorNode::EditorNode() {
|
|||||||
EDITOR_DEF("interface/inspector/horizontal_vector2_editing", false);
|
EDITOR_DEF("interface/inspector/horizontal_vector2_editing", false);
|
||||||
EDITOR_DEF("interface/inspector/horizontal_vector_types_editing", true);
|
EDITOR_DEF("interface/inspector/horizontal_vector_types_editing", true);
|
||||||
EDITOR_DEF("interface/inspector/open_resources_in_current_inspector", true);
|
EDITOR_DEF("interface/inspector/open_resources_in_current_inspector", true);
|
||||||
EDITOR_DEF("interface/inspector/resources_to_open_in_new_inspector", "SpatialMaterial,Script,MeshLibrary,TileSet");
|
EDITOR_DEF("interface/inspector/resources_to_open_in_new_inspector", "Script,MeshLibrary,TileSet");
|
||||||
EDITOR_DEF("interface/inspector/default_color_picker_mode", 0);
|
EDITOR_DEF("interface/inspector/default_color_picker_mode", 0);
|
||||||
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "interface/inspector/default_color_picker_mode", PROPERTY_HINT_ENUM, "RGB,HSV,RAW", PROPERTY_USAGE_DEFAULT));
|
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "interface/inspector/default_color_picker_mode", PROPERTY_HINT_ENUM, "RGB,HSV,RAW", PROPERTY_USAGE_DEFAULT));
|
||||||
EDITOR_DEF("run/auto_save/save_before_running", true);
|
EDITOR_DEF("run/auto_save/save_before_running", true);
|
||||||
|
@ -2649,6 +2649,41 @@ void EditorPropertyResource::_fold_other_editors(Object *p_self) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditorPropertyResource::_update_property_bg() {
|
||||||
|
if (!is_inside_tree()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
updating_theme = true;
|
||||||
|
if (sub_inspector != nullptr) {
|
||||||
|
int count_subinspectors = 0;
|
||||||
|
Node *n = get_parent();
|
||||||
|
while (n) {
|
||||||
|
EditorInspector *ei = Object::cast_to<EditorInspector>(n);
|
||||||
|
if (ei && ei->is_sub_inspector()) {
|
||||||
|
count_subinspectors++;
|
||||||
|
}
|
||||||
|
n = n->get_parent();
|
||||||
|
}
|
||||||
|
count_subinspectors = MIN(15, count_subinspectors);
|
||||||
|
|
||||||
|
add_color_override("property_color", get_color("sub_inspector_property_color", "Editor"));
|
||||||
|
add_style_override("bg_selected", get_stylebox("sub_inspector_property_bg_selected" + itos(count_subinspectors), "Editor"));
|
||||||
|
add_style_override("bg", get_stylebox("sub_inspector_property_bg" + itos(count_subinspectors), "Editor"));
|
||||||
|
|
||||||
|
add_constant_override("font_offset", get_constant("sub_inspector_font_offset", "Editor"));
|
||||||
|
add_constant_override("vseparation", 0);
|
||||||
|
} else {
|
||||||
|
add_color_override("property_color", get_color("property_color", "EditorProperty"));
|
||||||
|
add_style_override("bg_selected", get_stylebox("bg_selected", "EditorProperty"));
|
||||||
|
add_style_override("bg", get_stylebox("bg", "EditorProperty"));
|
||||||
|
add_constant_override("vseparation", get_constant("vseparation", "EditorProperty"));
|
||||||
|
add_constant_override("font_offset", get_constant("font_offset", "EditorProperty"));
|
||||||
|
}
|
||||||
|
|
||||||
|
updating_theme = false;
|
||||||
|
update();
|
||||||
|
}
|
||||||
void EditorPropertyResource::update_property() {
|
void EditorPropertyResource::update_property() {
|
||||||
|
|
||||||
RES res = get_edited_object()->get(get_edited_property());
|
RES res = get_edited_object()->get(get_edited_property());
|
||||||
@ -2700,6 +2735,8 @@ void EditorPropertyResource::update_property() {
|
|||||||
}
|
}
|
||||||
opened_editor = true;
|
opened_editor = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_update_property_bg();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res.ptr() != sub_inspector->get_edited_object()) {
|
if (res.ptr() != sub_inspector->get_edited_object()) {
|
||||||
@ -2717,6 +2754,7 @@ void EditorPropertyResource::update_property() {
|
|||||||
EditorNode::get_singleton()->hide_top_editors();
|
EditorNode::get_singleton()->hide_top_editors();
|
||||||
opened_editor = false;
|
opened_editor = false;
|
||||||
}
|
}
|
||||||
|
_update_property_bg();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2774,8 +2812,12 @@ void EditorPropertyResource::setup(const String &p_base_type) {
|
|||||||
void EditorPropertyResource::_notification(int p_what) {
|
void EditorPropertyResource::_notification(int p_what) {
|
||||||
|
|
||||||
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
|
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
|
||||||
|
if (updating_theme) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Ref<Texture> t = get_icon("select_arrow", "Tree");
|
Ref<Texture> t = get_icon("select_arrow", "Tree");
|
||||||
edit->set_icon(t);
|
edit->set_icon(t);
|
||||||
|
_update_property_bg();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_what == NOTIFICATION_DRAG_BEGIN) {
|
if (p_what == NOTIFICATION_DRAG_BEGIN) {
|
||||||
|
@ -601,6 +601,9 @@ class EditorPropertyResource : public EditorProperty {
|
|||||||
|
|
||||||
bool opened_editor;
|
bool opened_editor;
|
||||||
|
|
||||||
|
bool updating_theme = false;
|
||||||
|
void _update_property_bg();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
|
@ -432,6 +432,8 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
|
|||||||
|
|
||||||
// Property editor
|
// Property editor
|
||||||
_initial_set("docks/property_editor/auto_refresh_interval", 0.3);
|
_initial_set("docks/property_editor/auto_refresh_interval", 0.3);
|
||||||
|
_initial_set("docks/property_editor/subresource_hue_tint", 0.75);
|
||||||
|
hints["docks/property_editor/subresource_hue_tint"] = PropertyInfo(Variant::REAL, "docks/property_editor/subresource_hue_tint", PROPERTY_HINT_RANGE, "0,1,0.01", PROPERTY_USAGE_DEFAULT);
|
||||||
|
|
||||||
/* Text editor */
|
/* Text editor */
|
||||||
|
|
||||||
|
@ -718,14 +718,58 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
|
|||||||
theme->set_icon("visibility_xray", "PopupMenu", theme->get_icon("GuiVisibilityXray", "EditorIcons"));
|
theme->set_icon("visibility_xray", "PopupMenu", theme->get_icon("GuiVisibilityXray", "EditorIcons"));
|
||||||
theme->set_constant("vseparation", "PopupMenu", (extra_spacing + default_margin_size + 1) * EDSCALE);
|
theme->set_constant("vseparation", "PopupMenu", (extra_spacing + default_margin_size + 1) * EDSCALE);
|
||||||
|
|
||||||
Ref<StyleBoxFlat> sub_inspector_bg = make_flat_stylebox(dark_color_1.linear_interpolate(accent_color, 0.08), 2, 0, 2, 2);
|
for (int i = 0; i < 16; i++) {
|
||||||
sub_inspector_bg->set_border_width(MARGIN_LEFT, 2);
|
Color si_base_color = accent_color;
|
||||||
sub_inspector_bg->set_border_width(MARGIN_RIGHT, 2);
|
|
||||||
sub_inspector_bg->set_border_width(MARGIN_BOTTOM, 2);
|
float hue_rotate = (i * 2 % 16) / 16.0;
|
||||||
sub_inspector_bg->set_border_color(accent_color * Color(1, 1, 1, 0.3));
|
si_base_color.set_hsv(Math::fmod(float(si_base_color.get_h() + hue_rotate), float(1.0)), si_base_color.get_s(), si_base_color.get_v());
|
||||||
sub_inspector_bg->set_draw_center(true);
|
si_base_color = accent_color.linear_interpolate(si_base_color, float(EDITOR_GET("docks/property_editor/subresource_hue_tint")));
|
||||||
|
|
||||||
|
Ref<StyleBoxFlat> sub_inspector_bg;
|
||||||
|
|
||||||
|
sub_inspector_bg = make_flat_stylebox(dark_color_1.linear_interpolate(si_base_color, 0.08), 2, 0, 2, 2);
|
||||||
|
|
||||||
|
sub_inspector_bg->set_border_width(MARGIN_LEFT, 2);
|
||||||
|
sub_inspector_bg->set_border_width(MARGIN_RIGHT, 2);
|
||||||
|
sub_inspector_bg->set_border_width(MARGIN_BOTTOM, 2);
|
||||||
|
sub_inspector_bg->set_border_width(MARGIN_TOP, 2);
|
||||||
|
sub_inspector_bg->set_default_margin(MARGIN_LEFT, 3);
|
||||||
|
sub_inspector_bg->set_default_margin(MARGIN_RIGHT, 3);
|
||||||
|
sub_inspector_bg->set_default_margin(MARGIN_BOTTOM, 10);
|
||||||
|
sub_inspector_bg->set_default_margin(MARGIN_TOP, 5);
|
||||||
|
sub_inspector_bg->set_border_color(si_base_color * Color(0.7, 0.7, 0.7, 0.8));
|
||||||
|
sub_inspector_bg->set_draw_center(true);
|
||||||
|
|
||||||
|
theme->set_stylebox("sub_inspector_bg" + itos(i), "Editor", sub_inspector_bg);
|
||||||
|
|
||||||
|
Ref<StyleBoxFlat> bg_color;
|
||||||
|
bg_color.instance();
|
||||||
|
bg_color->set_bg_color(si_base_color * Color(0.7, 0.7, 0.7, 0.8));
|
||||||
|
bg_color->set_border_width_all(0);
|
||||||
|
|
||||||
|
Ref<StyleBoxFlat> bg_color_selected;
|
||||||
|
bg_color_selected.instance();
|
||||||
|
bg_color_selected->set_border_width_all(0);
|
||||||
|
bg_color_selected->set_bg_color(si_base_color * Color(0.8, 0.8, 0.8, 0.8));
|
||||||
|
|
||||||
|
theme->set_stylebox("sub_inspector_property_bg" + itos(i), "Editor", bg_color);
|
||||||
|
theme->set_stylebox("sub_inspector_property_bg_selected" + itos(i), "Editor", bg_color_selected);
|
||||||
|
}
|
||||||
|
|
||||||
|
theme->set_color("sub_inspector_property_color", "Editor", dark_theme ? Color(1, 1, 1, 1) : Color(0, 0, 0, 1));
|
||||||
|
theme->set_constant("sub_inspector_font_offset", "Editor", 4 * EDSCALE);
|
||||||
|
|
||||||
|
Ref<StyleBoxFlat> style_property_bg = style_default->duplicate();
|
||||||
|
style_property_bg->set_bg_color(highlight_color);
|
||||||
|
style_property_bg->set_border_width_all(0);
|
||||||
|
|
||||||
|
theme->set_constant("font_offset", "EditorProperty", 1 * EDSCALE);
|
||||||
|
theme->set_stylebox("bg_selected", "EditorProperty", style_property_bg);
|
||||||
|
theme->set_stylebox("bg", "EditorProperty", Ref<StyleBoxEmpty>(memnew(StyleBoxEmpty)));
|
||||||
|
theme->set_constant("vseparation", "EditorProperty", (extra_spacing + default_margin_size) * EDSCALE);
|
||||||
|
theme->set_color("error_color", "EditorProperty", error_color);
|
||||||
|
theme->set_color("property_color", "EditorProperty", property_color);
|
||||||
|
|
||||||
theme->set_stylebox("sub_inspector_bg", "Editor", sub_inspector_bg);
|
|
||||||
theme->set_constant("inspector_margin", "Editor", 8 * EDSCALE);
|
theme->set_constant("inspector_margin", "Editor", 8 * EDSCALE);
|
||||||
|
|
||||||
// Tree & ItemList background
|
// Tree & ItemList background
|
||||||
|
Loading…
Reference in New Issue
Block a user