-Ability to open resources in the same window
-Plenty of fixes and improvements to new inspector -Fixes that were needed to make inspector work better
This commit is contained in:
parent
3183375135
commit
4b5227ff77
@ -37,7 +37,8 @@
|
|||||||
#include "scene/resources/packed_scene.h"
|
#include "scene/resources/packed_scene.h"
|
||||||
|
|
||||||
// TODO:
|
// TODO:
|
||||||
// arrays
|
// arrays and dictionary
|
||||||
|
// drag and drop
|
||||||
|
|
||||||
Size2 EditorProperty::get_minimum_size() const {
|
Size2 EditorProperty::get_minimum_size() const {
|
||||||
|
|
||||||
@ -51,6 +52,9 @@ Size2 EditorProperty::get_minimum_size() const {
|
|||||||
continue;
|
continue;
|
||||||
if (!c->is_visible())
|
if (!c->is_visible())
|
||||||
continue;
|
continue;
|
||||||
|
if (c == bottom_editor)
|
||||||
|
continue;
|
||||||
|
|
||||||
Size2 minsize = c->get_combined_minimum_size();
|
Size2 minsize = c->get_combined_minimum_size();
|
||||||
ms.width = MAX(ms.width, minsize.width);
|
ms.width = MAX(ms.width, minsize.width);
|
||||||
ms.height = MAX(ms.height, minsize.height);
|
ms.height = MAX(ms.height, minsize.height);
|
||||||
@ -66,10 +70,14 @@ Size2 EditorProperty::get_minimum_size() const {
|
|||||||
ms.width += check->get_width() + get_constant("hseparator", "Tree");
|
ms.width += check->get_width() + get_constant("hseparator", "Tree");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (label_layout == LABEL_LAYOUT_TOP) {
|
if (bottom_editor != NULL) {
|
||||||
Ref<Font> font = get_font("font", "Tree");
|
Ref<Font> font = get_font("font", "Tree");
|
||||||
ms.height += font->get_height();
|
ms.height += font->get_height();
|
||||||
ms.height += get_constant("vseparation", "Tree");
|
ms.height += get_constant("vseparation", "Tree");
|
||||||
|
Size2 bems = bottom_editor->get_combined_minimum_size();
|
||||||
|
bems.width += get_constant("item_margin", "Tree");
|
||||||
|
ms.height += bems.height;
|
||||||
|
ms.width = MAX(ms.width, bems.width);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ms;
|
return ms;
|
||||||
@ -81,9 +89,12 @@ void EditorProperty::_notification(int p_what) {
|
|||||||
|
|
||||||
Size2 size = get_size();
|
Size2 size = get_size();
|
||||||
Rect2 rect;
|
Rect2 rect;
|
||||||
|
Rect2 bottom_rect;
|
||||||
|
|
||||||
if (label_layout == LABEL_LAYOUT_LEFT) {
|
{
|
||||||
int child_room = size.width / 2;
|
int child_room = size.width / 2;
|
||||||
|
Ref<Font> font = get_font("font", "Tree");
|
||||||
|
int height = font->get_height();
|
||||||
|
|
||||||
//compute room needed
|
//compute room needed
|
||||||
for (int i = 0; i < get_child_count(); i++) {
|
for (int i = 0; i < get_child_count(); i++) {
|
||||||
@ -93,22 +104,23 @@ void EditorProperty::_notification(int p_what) {
|
|||||||
continue;
|
continue;
|
||||||
if (c->is_set_as_toplevel())
|
if (c->is_set_as_toplevel())
|
||||||
continue;
|
continue;
|
||||||
|
if (c == bottom_editor)
|
||||||
|
continue;
|
||||||
|
|
||||||
Size2 minsize = c->get_combined_minimum_size();
|
Size2 minsize = c->get_combined_minimum_size();
|
||||||
child_room = MAX(child_room, minsize.width);
|
child_room = MAX(child_room, minsize.width);
|
||||||
|
height = MAX(height, minsize.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
text_size = MAX(0, size.width - child_room + 4 * EDSCALE);
|
text_size = MAX(0, size.width - child_room + 4 * EDSCALE);
|
||||||
|
|
||||||
rect = Rect2(text_size, 0, size.width - text_size, size.height);
|
rect = Rect2(text_size, 0, size.width - text_size, height);
|
||||||
} else {
|
|
||||||
Ref<Font> font = get_font("font", "Tree");
|
|
||||||
|
|
||||||
text_size = size.width;
|
if (bottom_editor) {
|
||||||
rect.position.x = 0;
|
|
||||||
rect.position.y = font->get_height() + get_constant("vseparation", "Tree");
|
int m = get_constant("item_margin", "Tree");
|
||||||
rect.size = get_size();
|
bottom_rect = Rect2(m, rect.size.height + get_constant("vseparation", "Tree"), size.width - m, bottom_editor->get_combined_minimum_size().height);
|
||||||
rect.size.height -= rect.position.y;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keying) {
|
if (keying) {
|
||||||
@ -131,10 +143,16 @@ void EditorProperty::_notification(int p_what) {
|
|||||||
continue;
|
continue;
|
||||||
if (c->is_set_as_toplevel())
|
if (c->is_set_as_toplevel())
|
||||||
continue;
|
continue;
|
||||||
|
if (c == bottom_editor)
|
||||||
|
continue;
|
||||||
|
|
||||||
fit_child_in_rect(c, rect);
|
fit_child_in_rect(c, rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (bottom_editor) {
|
||||||
|
fit_child_in_rect(bottom_editor, bottom_rect);
|
||||||
|
}
|
||||||
|
|
||||||
update(); //need to redraw text
|
update(); //need to redraw text
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,8 +160,8 @@ void EditorProperty::_notification(int p_what) {
|
|||||||
Ref<Font> font = get_font("font", "Tree");
|
Ref<Font> font = get_font("font", "Tree");
|
||||||
|
|
||||||
Size2 size = get_size();
|
Size2 size = get_size();
|
||||||
if (label_layout == LABEL_LAYOUT_TOP) {
|
if (bottom_editor) {
|
||||||
size.height = font->get_height();
|
size.height = bottom_editor->get_margin(MARGIN_TOP);
|
||||||
} else if (label_reference) {
|
} else if (label_reference) {
|
||||||
size.height = label_reference->get_size().height;
|
size.height = label_reference->get_size().height;
|
||||||
}
|
}
|
||||||
@ -626,7 +644,10 @@ void EditorProperty::set_label_reference(Control *p_control) {
|
|||||||
|
|
||||||
label_reference = p_control;
|
label_reference = p_control;
|
||||||
}
|
}
|
||||||
|
void EditorProperty::set_bottom_editor(Control *p_control) {
|
||||||
|
|
||||||
|
bottom_editor = p_control;
|
||||||
|
}
|
||||||
Variant EditorProperty::get_drag_data(const Point2 &p_point) {
|
Variant EditorProperty::get_drag_data(const Point2 &p_point) {
|
||||||
|
|
||||||
if (property == StringName())
|
if (property == StringName())
|
||||||
@ -644,10 +665,20 @@ Variant EditorProperty::get_drag_data(const Point2 &p_point) {
|
|||||||
return dp;
|
return dp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorProperty::set_label_layout(LabelLayout p_layout) {
|
void EditorProperty::set_use_folding(bool p_use_folding) {
|
||||||
label_layout = p_layout;
|
|
||||||
queue_sort();
|
use_folding = p_use_folding;
|
||||||
update();
|
}
|
||||||
|
|
||||||
|
bool EditorProperty::is_using_folding() const {
|
||||||
|
|
||||||
|
return use_folding;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditorProperty::expand_all_folding() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditorProperty::collapse_all_folding() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorProperty::_bind_methods() {
|
void EditorProperty::_bind_methods() {
|
||||||
@ -685,6 +716,7 @@ void EditorProperty::_bind_methods() {
|
|||||||
ADD_SIGNAL(MethodInfo("property_changed", PropertyInfo(Variant::STRING, "property"), PropertyInfo(Variant::NIL, "value", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NIL_IS_VARIANT)));
|
ADD_SIGNAL(MethodInfo("property_changed", PropertyInfo(Variant::STRING, "property"), PropertyInfo(Variant::NIL, "value", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NIL_IS_VARIANT)));
|
||||||
ADD_SIGNAL(MethodInfo("multiple_properties_changed", PropertyInfo(Variant::POOL_STRING_ARRAY, "properties"), PropertyInfo(Variant::ARRAY, "value")));
|
ADD_SIGNAL(MethodInfo("multiple_properties_changed", PropertyInfo(Variant::POOL_STRING_ARRAY, "properties"), PropertyInfo(Variant::ARRAY, "value")));
|
||||||
ADD_SIGNAL(MethodInfo("property_keyed", PropertyInfo(Variant::STRING, "property")));
|
ADD_SIGNAL(MethodInfo("property_keyed", PropertyInfo(Variant::STRING, "property")));
|
||||||
|
ADD_SIGNAL(MethodInfo("property_keyed_with_value", PropertyInfo(Variant::STRING, "property"), PropertyInfo(Variant::NIL, "value", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NIL_IS_VARIANT)));
|
||||||
ADD_SIGNAL(MethodInfo("property_checked", PropertyInfo(Variant::STRING, "property"), PropertyInfo(Variant::STRING, "bool")));
|
ADD_SIGNAL(MethodInfo("property_checked", PropertyInfo(Variant::STRING, "property"), PropertyInfo(Variant::STRING, "bool")));
|
||||||
ADD_SIGNAL(MethodInfo("resource_selected", PropertyInfo(Variant::STRING, "path"), PropertyInfo(Variant::OBJECT, "resource", PROPERTY_HINT_RESOURCE_TYPE, "Resource")));
|
ADD_SIGNAL(MethodInfo("resource_selected", PropertyInfo(Variant::STRING, "path"), PropertyInfo(Variant::OBJECT, "resource", PROPERTY_HINT_RESOURCE_TYPE, "Resource")));
|
||||||
ADD_SIGNAL(MethodInfo("object_id_selected", PropertyInfo(Variant::STRING, "property"), PropertyInfo(Variant::INT, "id")));
|
ADD_SIGNAL(MethodInfo("object_id_selected", PropertyInfo(Variant::STRING, "property"), PropertyInfo(Variant::INT, "id")));
|
||||||
@ -707,11 +739,12 @@ EditorProperty::EditorProperty() {
|
|||||||
revert_hover = false;
|
revert_hover = false;
|
||||||
check_hover = false;
|
check_hover = false;
|
||||||
can_revert = false;
|
can_revert = false;
|
||||||
|
use_folding = false;
|
||||||
property_usage = 0;
|
property_usage = 0;
|
||||||
selected = false;
|
selected = false;
|
||||||
selected_focusable = -1;
|
selected_focusable = -1;
|
||||||
label_reference = NULL;
|
label_reference = NULL;
|
||||||
label_layout = LABEL_LAYOUT_LEFT;
|
bottom_editor = NULL;
|
||||||
}
|
}
|
||||||
////////////////////////////////////////////////
|
////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////
|
////////////////////////////////////////////////
|
||||||
@ -755,6 +788,14 @@ void EditorInspectorPlugin::parse_begin(Object *p_object) {
|
|||||||
get_script_instance()->call("parse_begin", p_object);
|
get_script_instance()->call("parse_begin", p_object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditorInspectorPlugin::parse_category(Object *p_object, const String &p_parse_category) {
|
||||||
|
|
||||||
|
if (get_script_instance()) {
|
||||||
|
get_script_instance()->call("parse_category", p_object, p_parse_category);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool EditorInspectorPlugin::parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage) {
|
bool EditorInspectorPlugin::parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage) {
|
||||||
|
|
||||||
if (get_script_instance()) {
|
if (get_script_instance()) {
|
||||||
@ -789,6 +830,10 @@ void EditorInspectorPlugin::_bind_methods() {
|
|||||||
BIND_VMETHOD(vm);
|
BIND_VMETHOD(vm);
|
||||||
vm.name = "parse_begin";
|
vm.name = "parse_begin";
|
||||||
BIND_VMETHOD(vm);
|
BIND_VMETHOD(vm);
|
||||||
|
vm.name = "parse_category";
|
||||||
|
vm.arguments.push_back(PropertyInfo(Variant::STRING, "category"));
|
||||||
|
BIND_VMETHOD(vm);
|
||||||
|
vm.arguments.pop_back();
|
||||||
vm.name = "parse_property";
|
vm.name = "parse_property";
|
||||||
vm.return_val.type = Variant::BOOL;
|
vm.return_val.type = Variant::BOOL;
|
||||||
vm.arguments.push_back(PropertyInfo(Variant::INT, "type"));
|
vm.arguments.push_back(PropertyInfo(Variant::INT, "type"));
|
||||||
@ -1096,6 +1141,55 @@ String EditorInspector::get_selected_path() const {
|
|||||||
return property_selected;
|
return property_selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditorInspector::_parse_added_editors(VBoxContainer *current_vbox, Ref<EditorInspectorPlugin> ped) {
|
||||||
|
|
||||||
|
for (List<EditorInspectorPlugin::AddedEditor>::Element *F = ped->added_editors.front(); F; F = F->next()) {
|
||||||
|
|
||||||
|
EditorProperty *ep = Object::cast_to<EditorProperty>(F->get().property_editor);
|
||||||
|
current_vbox->add_child(F->get().property_editor);
|
||||||
|
|
||||||
|
if (ep) {
|
||||||
|
|
||||||
|
ep->object = object;
|
||||||
|
ep->connect("property_changed", this, "_property_changed");
|
||||||
|
ep->connect("property_keyed", this, "_property_keyed");
|
||||||
|
ep->connect("property_keyed_with_value", this, "_property_keyed_with_value");
|
||||||
|
ep->connect("property_checked", this, "_property_checked");
|
||||||
|
ep->connect("selected", this, "_property_selected");
|
||||||
|
ep->connect("multiple_properties_changed", this, "_multiple_properties_changed");
|
||||||
|
ep->connect("resource_selected", this, "_resource_selected", varray(), CONNECT_DEFERRED);
|
||||||
|
ep->connect("object_id_selected", this, "_object_id_selected", varray(), CONNECT_DEFERRED);
|
||||||
|
|
||||||
|
if (F->get().properties.size()) {
|
||||||
|
|
||||||
|
if (F->get().properties.size() == 1) {
|
||||||
|
//since it's one, associate:
|
||||||
|
ep->property = F->get().properties[0];
|
||||||
|
ep->property_usage = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (F->get().label != String()) {
|
||||||
|
ep->set_label(F->get().label);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < F->get().properties.size(); i++) {
|
||||||
|
String prop = F->get().properties[i];
|
||||||
|
|
||||||
|
if (!editor_property_map.has(prop)) {
|
||||||
|
editor_property_map[prop] = List<EditorProperty *>();
|
||||||
|
}
|
||||||
|
editor_property_map[prop].push_back(ep);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ep->set_read_only(read_only);
|
||||||
|
ep->update_property();
|
||||||
|
ep->update_reload_status();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ped->added_editors.clear();
|
||||||
|
}
|
||||||
|
|
||||||
void EditorInspector::update_tree() {
|
void EditorInspector::update_tree() {
|
||||||
|
|
||||||
//to update properly if all is refreshed
|
//to update properly if all is refreshed
|
||||||
@ -1139,6 +1233,12 @@ void EditorInspector::update_tree() {
|
|||||||
|
|
||||||
Color sscolor = get_color("prop_subsection", "Editor");
|
Color sscolor = get_color("prop_subsection", "Editor");
|
||||||
|
|
||||||
|
for (List<Ref<EditorInspectorPlugin> >::Element *E = valid_plugins.front(); E; E = E->next()) {
|
||||||
|
Ref<EditorInspectorPlugin> ped = E->get();
|
||||||
|
ped->parse_begin(object);
|
||||||
|
_parse_added_editors(main_vbox, ped);
|
||||||
|
}
|
||||||
|
|
||||||
for (List<PropertyInfo>::Element *I = plist.front(); I; I = I->next()) {
|
for (List<PropertyInfo>::Element *I = plist.front(); I; I = I->next()) {
|
||||||
|
|
||||||
PropertyInfo &p = I->get();
|
PropertyInfo &p = I->get();
|
||||||
@ -1201,6 +1301,13 @@ void EditorInspector::update_tree() {
|
|||||||
|
|
||||||
category->set_tooltip(TTR("Class:") + " " + p.name + (class_descr_cache[type] == "" ? "" : "\n\n" + class_descr_cache[type]));
|
category->set_tooltip(TTR("Class:") + " " + p.name + (class_descr_cache[type] == "" ? "" : "\n\n" + class_descr_cache[type]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (List<Ref<EditorInspectorPlugin> >::Element *E = valid_plugins.front(); E; E = E->next()) {
|
||||||
|
Ref<EditorInspectorPlugin> ped = E->get();
|
||||||
|
ped->parse_category(object, p.name);
|
||||||
|
_parse_added_editors(main_vbox, ped);
|
||||||
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
} else if (!(p.usage & PROPERTY_USAGE_EDITOR))
|
} else if (!(p.usage & PROPERTY_USAGE_EDITOR))
|
||||||
@ -1339,7 +1446,10 @@ void EditorInspector::update_tree() {
|
|||||||
for (List<Ref<EditorInspectorPlugin> >::Element *E = valid_plugins.front(); E; E = E->next()) {
|
for (List<Ref<EditorInspectorPlugin> >::Element *E = valid_plugins.front(); E; E = E->next()) {
|
||||||
Ref<EditorInspectorPlugin> ped = E->get();
|
Ref<EditorInspectorPlugin> ped = E->get();
|
||||||
ped->parse_property(object, p.type, p.name, p.hint, p.hint_string, p.usage);
|
ped->parse_property(object, p.type, p.name, p.hint, p.hint_string, p.usage);
|
||||||
for (List<EditorInspectorPlugin::AddedEditor>::Element *F = ped->added_editors.front(); F; F = F->next()) {
|
List<EditorInspectorPlugin::AddedEditor> editors = ped->added_editors; //make a copy, since plugins may be used again in a sub-inspector
|
||||||
|
ped->added_editors.clear();
|
||||||
|
|
||||||
|
for (List<EditorInspectorPlugin::AddedEditor>::Element *F = editors.front(); F; F = F->next()) {
|
||||||
|
|
||||||
EditorProperty *ep = Object::cast_to<EditorProperty>(F->get().property_editor);
|
EditorProperty *ep = Object::cast_to<EditorProperty>(F->get().property_editor);
|
||||||
current_vbox->add_child(F->get().property_editor);
|
current_vbox->add_child(F->get().property_editor);
|
||||||
@ -1349,6 +1459,7 @@ void EditorInspector::update_tree() {
|
|||||||
ep->object = object;
|
ep->object = object;
|
||||||
ep->connect("property_changed", this, "_property_changed");
|
ep->connect("property_changed", this, "_property_changed");
|
||||||
ep->connect("property_keyed", this, "_property_keyed");
|
ep->connect("property_keyed", this, "_property_keyed");
|
||||||
|
ep->connect("property_keyed_with_value", this, "_property_keyed_with_value");
|
||||||
ep->connect("property_checked", this, "_property_checked");
|
ep->connect("property_checked", this, "_property_checked");
|
||||||
ep->connect("selected", this, "_property_selected");
|
ep->connect("selected", this, "_property_selected");
|
||||||
ep->connect("multiple_properties_changed", this, "_multiple_properties_changed");
|
ep->connect("multiple_properties_changed", this, "_multiple_properties_changed");
|
||||||
@ -1360,6 +1471,7 @@ void EditorInspector::update_tree() {
|
|||||||
ep->set_tooltip(TTR("Property: ") + p.name);
|
ep->set_tooltip(TTR("Property: ") + p.name);
|
||||||
}
|
}
|
||||||
ep->set_draw_red(draw_red);
|
ep->set_draw_red(draw_red);
|
||||||
|
ep->set_use_folding(use_folding);
|
||||||
ep->set_checkable(checkable);
|
ep->set_checkable(checkable);
|
||||||
ep->set_checked(checked);
|
ep->set_checked(checked);
|
||||||
ep->set_keying(keying);
|
ep->set_keying(keying);
|
||||||
@ -1398,10 +1510,15 @@ void EditorInspector::update_tree() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ped->added_editors.clear();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (List<Ref<EditorInspectorPlugin> >::Element *E = valid_plugins.front(); E; E = E->next()) {
|
||||||
|
Ref<EditorInspectorPlugin> ped = E->get();
|
||||||
|
ped->parse_end();
|
||||||
|
_parse_added_editors(main_vbox, ped);
|
||||||
|
}
|
||||||
|
|
||||||
//see if this property exists and should be kept
|
//see if this property exists and should be kept
|
||||||
}
|
}
|
||||||
void EditorInspector::update_property(const String &p_prop) {
|
void EditorInspector::update_property(const String &p_prop) {
|
||||||
@ -1416,14 +1533,14 @@ void EditorInspector::update_property(const String &p_prop) {
|
|||||||
|
|
||||||
void EditorInspector::_clear() {
|
void EditorInspector::_clear() {
|
||||||
|
|
||||||
editor_property_map.clear();
|
|
||||||
sections.clear();
|
|
||||||
pending.clear();
|
|
||||||
property_selected = StringName();
|
|
||||||
property_focusable = -1;
|
|
||||||
while (main_vbox->get_child_count()) {
|
while (main_vbox->get_child_count()) {
|
||||||
memdelete(main_vbox->get_child(0));
|
memdelete(main_vbox->get_child(0));
|
||||||
}
|
}
|
||||||
|
property_selected = StringName();
|
||||||
|
property_focusable = -1;
|
||||||
|
editor_property_map.clear();
|
||||||
|
sections.clear();
|
||||||
|
pending.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorInspector::refresh() {
|
void EditorInspector::refresh() {
|
||||||
@ -1433,17 +1550,21 @@ void EditorInspector::refresh() {
|
|||||||
refresh_countdown = EditorSettings::get_singleton()->get("docks/property_editor/auto_refresh_interval");
|
refresh_countdown = EditorSettings::get_singleton()->get("docks/property_editor/auto_refresh_interval");
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorInspector::edit(Object *p_object) {
|
Object *EditorInspector::get_edited_object() {
|
||||||
if (object != p_object) {
|
return object;
|
||||||
_clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditorInspector::edit(Object *p_object) {
|
||||||
|
if (object == p_object)
|
||||||
|
return;
|
||||||
if (object) {
|
if (object) {
|
||||||
|
|
||||||
|
_clear();
|
||||||
object->remove_change_receptor(this);
|
object->remove_change_receptor(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
object = p_object;
|
object = p_object;
|
||||||
|
|
||||||
if (object) {
|
if (object) {
|
||||||
object->add_change_receptor(this);
|
object->add_change_receptor(this);
|
||||||
update_tree();
|
update_tree();
|
||||||
@ -1518,12 +1639,23 @@ void EditorInspector::collapse_all_folding() {
|
|||||||
for (List<EditorInspectorSection *>::Element *E = sections.front(); E; E = E->next()) {
|
for (List<EditorInspectorSection *>::Element *E = sections.front(); E; E = E->next()) {
|
||||||
E->get()->fold();
|
E->get()->fold();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (Map<StringName, List<EditorProperty *> >::Element *F = editor_property_map.front(); F; F = F->next()) {
|
||||||
|
for (List<EditorProperty *>::Element *E = F->get().front(); E; E = E->next()) {
|
||||||
|
E->get()->collapse_all_folding();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorInspector::expand_all_folding() {
|
void EditorInspector::expand_all_folding() {
|
||||||
for (List<EditorInspectorSection *>::Element *E = sections.front(); E; E = E->next()) {
|
for (List<EditorInspectorSection *>::Element *E = sections.front(); E; E = E->next()) {
|
||||||
E->get()->unfold();
|
E->get()->unfold();
|
||||||
}
|
}
|
||||||
|
for (Map<StringName, List<EditorProperty *> >::Element *F = editor_property_map.front(); F; F = F->next()) {
|
||||||
|
for (List<EditorProperty *>::Element *E = F->get().front(); E; E = E->next()) {
|
||||||
|
E->get()->expand_all_folding();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorInspector::set_scroll_offset(int p_offset) {
|
void EditorInspector::set_scroll_offset(int p_offset) {
|
||||||
@ -1653,6 +1785,14 @@ void EditorInspector::_property_keyed(const String &p_path) {
|
|||||||
emit_signal("property_keyed", p_path, object->get(p_path), false); //second param is deprecated
|
emit_signal("property_keyed", p_path, object->get(p_path), false); //second param is deprecated
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditorInspector::_property_keyed_with_value(const String &p_path, const Variant &p_value) {
|
||||||
|
|
||||||
|
if (!object)
|
||||||
|
return;
|
||||||
|
|
||||||
|
emit_signal("property_keyed", p_path, p_value, false); //second param is deprecated
|
||||||
|
}
|
||||||
|
|
||||||
void EditorInspector::_property_checked(const String &p_path, bool p_checked) {
|
void EditorInspector::_property_checked(const String &p_path, bool p_checked) {
|
||||||
|
|
||||||
if (!object)
|
if (!object)
|
||||||
@ -1791,6 +1931,7 @@ void EditorInspector::_bind_methods() {
|
|||||||
ClassDB::bind_method("_node_removed", &EditorInspector::_node_removed);
|
ClassDB::bind_method("_node_removed", &EditorInspector::_node_removed);
|
||||||
ClassDB::bind_method("_filter_changed", &EditorInspector::_filter_changed);
|
ClassDB::bind_method("_filter_changed", &EditorInspector::_filter_changed);
|
||||||
ClassDB::bind_method("_property_keyed", &EditorInspector::_property_keyed);
|
ClassDB::bind_method("_property_keyed", &EditorInspector::_property_keyed);
|
||||||
|
ClassDB::bind_method("_property_keyed_with_value", &EditorInspector::_property_keyed_with_value);
|
||||||
ClassDB::bind_method("_property_checked", &EditorInspector::_property_checked);
|
ClassDB::bind_method("_property_checked", &EditorInspector::_property_checked);
|
||||||
ClassDB::bind_method("_property_selected", &EditorInspector::_property_selected);
|
ClassDB::bind_method("_property_selected", &EditorInspector::_property_selected);
|
||||||
ClassDB::bind_method("_resource_selected", &EditorInspector::_resource_selected);
|
ClassDB::bind_method("_resource_selected", &EditorInspector::_resource_selected);
|
||||||
@ -1807,9 +1948,8 @@ EditorInspector::EditorInspector() {
|
|||||||
main_vbox = memnew(VBoxContainer);
|
main_vbox = memnew(VBoxContainer);
|
||||||
main_vbox->set_h_size_flags(SIZE_EXPAND_FILL);
|
main_vbox->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||||
add_child(main_vbox);
|
add_child(main_vbox);
|
||||||
main_vbox->set_name("pipirulo");
|
set_enable_h_scroll(false);
|
||||||
set_h_scroll(false);
|
set_enable_v_scroll(true);
|
||||||
set_v_scroll(true);
|
|
||||||
|
|
||||||
show_categories = false;
|
show_categories = false;
|
||||||
hide_script = true;
|
hide_script = true;
|
||||||
|
@ -31,18 +31,15 @@
|
|||||||
#ifndef EDITOR_INSPECTOR_H
|
#ifndef EDITOR_INSPECTOR_H
|
||||||
#define EDITOR_INSPECTOR_H
|
#define EDITOR_INSPECTOR_H
|
||||||
|
|
||||||
#include "editor_data.h"
|
#include "scene/gui/box_container.h"
|
||||||
|
#include "scene/gui/line_edit.h"
|
||||||
#include "scene/gui/scroll_container.h"
|
#include "scene/gui/scroll_container.h"
|
||||||
|
|
||||||
|
class UndoRedo;
|
||||||
|
|
||||||
class EditorProperty : public Container {
|
class EditorProperty : public Container {
|
||||||
|
|
||||||
GDCLASS(EditorProperty, Container)
|
GDCLASS(EditorProperty, Container)
|
||||||
public:
|
|
||||||
enum LabelLayout {
|
|
||||||
LABEL_LAYOUT_LEFT,
|
|
||||||
LABEL_LAYOUT_TOP,
|
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
String label;
|
String label;
|
||||||
int text_size;
|
int text_size;
|
||||||
@ -50,8 +47,6 @@ private:
|
|||||||
Object *object;
|
Object *object;
|
||||||
StringName property;
|
StringName property;
|
||||||
|
|
||||||
LabelLayout label_layout;
|
|
||||||
|
|
||||||
int property_usage;
|
int property_usage;
|
||||||
|
|
||||||
bool read_only;
|
bool read_only;
|
||||||
@ -69,6 +64,8 @@ private:
|
|||||||
|
|
||||||
bool can_revert;
|
bool can_revert;
|
||||||
|
|
||||||
|
bool use_folding;
|
||||||
|
|
||||||
bool _might_be_in_instance();
|
bool _might_be_in_instance();
|
||||||
bool _is_property_different(const Variant &p_current, const Variant &p_orig, int p_usage);
|
bool _is_property_different(const Variant &p_current, const Variant &p_orig, int p_usage);
|
||||||
bool _is_instanced_node_with_original_property_different();
|
bool _is_instanced_node_with_original_property_different();
|
||||||
@ -80,6 +77,7 @@ private:
|
|||||||
|
|
||||||
Vector<Control *> focusables;
|
Vector<Control *> focusables;
|
||||||
Control *label_reference;
|
Control *label_reference;
|
||||||
|
Control *bottom_editor;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
@ -122,10 +120,16 @@ public:
|
|||||||
bool is_selected() const;
|
bool is_selected() const;
|
||||||
|
|
||||||
void set_label_reference(Control *p_control);
|
void set_label_reference(Control *p_control);
|
||||||
|
void set_bottom_editor(Control *p_editor);
|
||||||
|
|
||||||
|
void set_use_folding(bool p_use_folding);
|
||||||
|
bool is_using_folding() const;
|
||||||
|
|
||||||
|
virtual void expand_all_folding();
|
||||||
|
virtual void collapse_all_folding();
|
||||||
|
|
||||||
virtual Variant get_drag_data(const Point2 &p_point);
|
virtual Variant get_drag_data(const Point2 &p_point);
|
||||||
|
|
||||||
void set_label_layout(LabelLayout p_layout);
|
|
||||||
EditorProperty();
|
EditorProperty();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -151,6 +155,7 @@ public:
|
|||||||
|
|
||||||
virtual bool can_handle(Object *p_object);
|
virtual bool can_handle(Object *p_object);
|
||||||
virtual void parse_begin(Object *p_object);
|
virtual void parse_begin(Object *p_object);
|
||||||
|
virtual void parse_category(Object *p_object, const String &p_parse_category);
|
||||||
virtual bool parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage);
|
virtual bool parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage);
|
||||||
virtual void parse_end();
|
virtual void parse_end();
|
||||||
};
|
};
|
||||||
@ -249,6 +254,8 @@ class EditorInspector : public ScrollContainer {
|
|||||||
void _property_changed(const String &p_path, const Variant &p_value);
|
void _property_changed(const String &p_path, const Variant &p_value);
|
||||||
void _multiple_properties_changed(Vector<String> p_paths, Array p_values);
|
void _multiple_properties_changed(Vector<String> p_paths, Array p_values);
|
||||||
void _property_keyed(const String &p_path);
|
void _property_keyed(const String &p_path);
|
||||||
|
void _property_keyed_with_value(const String &p_path, const Variant &p_value);
|
||||||
|
|
||||||
void _property_checked(const String &p_path, bool p_checked);
|
void _property_checked(const String &p_path, bool p_checked);
|
||||||
|
|
||||||
void _resource_selected(const String &p_path, RES p_resource);
|
void _resource_selected(const String &p_path, RES p_resource);
|
||||||
@ -261,6 +268,7 @@ class EditorInspector : public ScrollContainer {
|
|||||||
void _edit_request_change(Object *p_changed, const String &p_prop);
|
void _edit_request_change(Object *p_changed, const String &p_prop);
|
||||||
|
|
||||||
void _filter_changed(const String &p_text);
|
void _filter_changed(const String &p_text);
|
||||||
|
void _parse_added_editors(VBoxContainer *current_vbox, Ref<EditorInspectorPlugin> ped);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
@ -281,6 +289,7 @@ public:
|
|||||||
void refresh();
|
void refresh();
|
||||||
|
|
||||||
void edit(Object *p_object);
|
void edit(Object *p_object);
|
||||||
|
Object *get_edited_object();
|
||||||
|
|
||||||
void set_keying(bool p_active);
|
void set_keying(bool p_active);
|
||||||
void set_read_only(bool p_read_only);
|
void set_read_only(bool p_read_only);
|
||||||
|
@ -324,7 +324,7 @@ void EditorNode::_notification(int p_what) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
|
if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
|
||||||
scene_tabs->set_tab_close_display_policy((bool(EDITOR_DEF("interface/scene_tabs/always_show_close_button", false)) ? Tabs::CLOSE_BUTTON_SHOW_ALWAYS : Tabs::CLOSE_BUTTON_SHOW_ACTIVE_ONLY));
|
scene_tabs->set_tab_close_display_policy((bool(EDITOR_GET("interface/scene_tabs/always_show_close_button")) ? Tabs::CLOSE_BUTTON_SHOW_ALWAYS : Tabs::CLOSE_BUTTON_SHOW_ACTIVE_ONLY));
|
||||||
Ref<Theme> theme = create_editor_theme(theme_base->get_theme());
|
Ref<Theme> theme = create_editor_theme(theme_base->get_theme());
|
||||||
|
|
||||||
theme_base->set_theme(theme);
|
theme_base->set_theme(theme);
|
||||||
@ -343,8 +343,8 @@ void EditorNode::_notification(int p_what) {
|
|||||||
settings_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles"));
|
settings_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles"));
|
||||||
help_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles"));
|
help_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles"));
|
||||||
|
|
||||||
if (bool(EDITOR_DEF("interface/scene_tabs/resize_if_many_tabs", true))) {
|
if (EDITOR_GET("interface/scene_tabs/resize_if_many_tabs")) {
|
||||||
scene_tabs->set_min_width(int(EDITOR_DEF("interface/scene_tabs/minimum_width", 50)) * EDSCALE);
|
scene_tabs->set_min_width(int(EDITOR_GET("interface/scene_tabs/minimum_width")) * EDSCALE);
|
||||||
} else {
|
} else {
|
||||||
scene_tabs->set_min_width(0);
|
scene_tabs->set_min_width(0);
|
||||||
}
|
}
|
||||||
@ -1527,7 +1527,7 @@ void EditorNode::_edit_current() {
|
|||||||
|
|
||||||
object_menu->set_disabled(true);
|
object_menu->set_disabled(true);
|
||||||
|
|
||||||
bool capitalize = bool(EDITOR_DEF("interface/editor/capitalize_properties", true));
|
bool capitalize = bool(EDITOR_GET("interface/inspector/capitalize_properties"));
|
||||||
bool is_resource = current_obj->is_class("Resource");
|
bool is_resource = current_obj->is_class("Resource");
|
||||||
bool is_node = current_obj->is_class("Node");
|
bool is_node = current_obj->is_class("Node");
|
||||||
resource_save_button->set_disabled(!is_resource);
|
resource_save_button->set_disabled(!is_resource);
|
||||||
@ -1796,7 +1796,7 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bool(EDITOR_DEF("run/auto_save/save_before_running", true))) {
|
if (bool(EDITOR_GET("run/auto_save/save_before_running"))) {
|
||||||
|
|
||||||
if (unsaved_cache) {
|
if (unsaved_cache) {
|
||||||
|
|
||||||
@ -1823,11 +1823,11 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
|
|||||||
if (!call_build())
|
if (!call_build())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (bool(EDITOR_DEF("run/output/always_clear_output_on_play", true))) {
|
if (bool(EDITOR_GET("run/output/always_clear_output_on_play"))) {
|
||||||
log->clear();
|
log->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bool(EDITOR_DEF("run/output/always_open_output_on_play", true))) {
|
if (bool(EDITOR_GET("run/output/always_open_output_on_play"))) {
|
||||||
make_bottom_panel_item_visible(log);
|
make_bottom_panel_item_visible(log);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2326,7 +2326,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
|
|||||||
play_custom_scene_button->set_icon(gui_base->get_icon("PlayCustom", "EditorIcons"));
|
play_custom_scene_button->set_icon(gui_base->get_icon("PlayCustom", "EditorIcons"));
|
||||||
stop_button->set_disabled(true);
|
stop_button->set_disabled(true);
|
||||||
|
|
||||||
if (bool(EDITOR_DEF("run/output/always_close_output_on_stop", true))) {
|
if (bool(EDITOR_GET("run/output/always_close_output_on_stop"))) {
|
||||||
for (int i = 0; i < bottom_panel_items.size(); i++) {
|
for (int i = 0; i < bottom_panel_items.size(); i++) {
|
||||||
if (bottom_panel_items[i].control == log) {
|
if (bottom_panel_items[i].control == log) {
|
||||||
_bottom_panel_switch(false, i);
|
_bottom_panel_switch(false, i);
|
||||||
@ -2346,7 +2346,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
|
|||||||
} break;
|
} break;
|
||||||
case RUN_PLAY_NATIVE: {
|
case RUN_PLAY_NATIVE: {
|
||||||
|
|
||||||
bool autosave = EDITOR_DEF("run/auto_save/save_before_running", true);
|
bool autosave = EDITOR_GET("run/auto_save/save_before_running");
|
||||||
if (autosave) {
|
if (autosave) {
|
||||||
_menu_option_confirm(FILE_SAVE_ALL_SCENES, false);
|
_menu_option_confirm(FILE_SAVE_ALL_SCENES, false);
|
||||||
}
|
}
|
||||||
@ -2372,10 +2372,10 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
|
|||||||
case RUN_PROJECT_MANAGER: {
|
case RUN_PROJECT_MANAGER: {
|
||||||
|
|
||||||
if (!p_confirmed) {
|
if (!p_confirmed) {
|
||||||
bool save_each = EDITOR_DEF("interface/editor/save_each_scene_on_quit", true);
|
bool save_each = EDITOR_GET("interface/editor/save_each_scene_on_quit");
|
||||||
if (_next_unsaved_scene(!save_each) == -1) {
|
if (_next_unsaved_scene(!save_each) == -1) {
|
||||||
|
|
||||||
bool confirm = EDITOR_DEF("interface/editor/quit_confirmation", true);
|
bool confirm = EDITOR_GET("interface/editor/quit_confirmation");
|
||||||
if (confirm) {
|
if (confirm) {
|
||||||
|
|
||||||
confirmation->get_ok()->set_text(p_option == FILE_QUIT ? TTR("Quit") : TTR("Yes"));
|
confirmation->get_ok()->set_text(p_option == FILE_QUIT ? TTR("Quit") : TTR("Yes"));
|
||||||
@ -4044,7 +4044,7 @@ void EditorNode::_load_docks_from_config(Ref<ConfigFile> p_layout, const String
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EditorNode::_load_open_scenes_from_config(Ref<ConfigFile> p_layout, const String &p_section) {
|
void EditorNode::_load_open_scenes_from_config(Ref<ConfigFile> p_layout, const String &p_section) {
|
||||||
if (!bool(EDITOR_DEF("interface/scene_tabs/restore_scenes_on_load", false))) {
|
if (!bool(EDITOR_GET("interface/scene_tabs/restore_scenes_on_load"))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4166,7 +4166,7 @@ void EditorNode::_scene_tab_closed(int p_tab) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EditorNode::_scene_tab_hover(int p_tab) {
|
void EditorNode::_scene_tab_hover(int p_tab) {
|
||||||
if (bool(EDITOR_DEF("interface/scene_tabs/show_thumbnail_on_hover", true)) == false) {
|
if (bool(EDITOR_GET("interface/scene_tabs/show_thumbnail_on_hover")) == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int current_tab = scene_tabs->get_current_tab();
|
int current_tab = scene_tabs->get_current_tab();
|
||||||
@ -5042,6 +5042,22 @@ EditorNode::EditorNode() {
|
|||||||
ClassDB::set_class_enabled("CollisionShape2D", true);
|
ClassDB::set_class_enabled("CollisionShape2D", true);
|
||||||
ClassDB::set_class_enabled("CollisionPolygon2D", true);
|
ClassDB::set_class_enabled("CollisionPolygon2D", true);
|
||||||
|
|
||||||
|
//defs here, use EDITOR_GET in logic
|
||||||
|
EDITOR_DEF("interface/scene_tabs/always_show_close_button", false);
|
||||||
|
EDITOR_DEF("interface/scene_tabs/resize_if_many_tabs", true);
|
||||||
|
EDITOR_DEF("interface/scene_tabs/minimum_width", 50);
|
||||||
|
EDITOR_DEF("run/output/always_clear_output_on_play", true);
|
||||||
|
EDITOR_DEF("run/output/always_open_output_on_play", true);
|
||||||
|
EDITOR_DEF("run/output/always_close_output_on_stop", true);
|
||||||
|
EDITOR_DEF("run/auto_save/save_before_running", true);
|
||||||
|
EDITOR_DEF("interface/editor/save_each_scene_on_quit", true);
|
||||||
|
EDITOR_DEF("interface/editor/quit_confirmation", true);
|
||||||
|
EDITOR_DEF("interface/scene_tabs/restore_scenes_on_load", false);
|
||||||
|
EDITOR_DEF("interface/scene_tabs/show_thumbnail_on_hover", true);
|
||||||
|
EDITOR_DEF("interface/inspector/capitalize_properties", true);
|
||||||
|
EDITOR_DEF("interface/inspector/open_resources_in_new_inspector", false);
|
||||||
|
EDITOR_DEF("run/auto_save/save_before_running", true);
|
||||||
|
|
||||||
theme_base = memnew(Control);
|
theme_base = memnew(Control);
|
||||||
add_child(theme_base);
|
add_child(theme_base);
|
||||||
theme_base->set_anchors_and_margins_preset(Control::PRESET_WIDE);
|
theme_base->set_anchors_and_margins_preset(Control::PRESET_WIDE);
|
||||||
@ -5679,8 +5695,8 @@ EditorNode::EditorNode() {
|
|||||||
inspector->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
inspector->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||||
inspector->set_use_doc_hints(true);
|
inspector->set_use_doc_hints(true);
|
||||||
inspector->set_hide_script(false);
|
inspector->set_hide_script(false);
|
||||||
inspector->set_enable_capitalize_paths(bool(EDITOR_DEF("interface/editor/capitalize_properties", true)));
|
inspector->set_enable_capitalize_paths(bool(EDITOR_DEF("interface/inspector/capitalize_properties", true)));
|
||||||
inspector->set_use_folding(!bool(EDITOR_DEF("interface/editor/disable_inspector_folding", false)));
|
inspector->set_use_folding(!bool(EDITOR_DEF("interface/inspector/disable_inspector_folding", false)));
|
||||||
|
|
||||||
// inspector->hide_top_label();
|
// inspector->hide_top_label();
|
||||||
inspector->register_text_enter(search_box);
|
inspector->register_text_enter(search_box);
|
||||||
|
@ -659,6 +659,14 @@ void EditorPlugin::remove_export_plugin(const Ref<EditorExportPlugin> &p_exporte
|
|||||||
EditorExport::get_singleton()->remove_export_plugin(p_exporter);
|
EditorExport::get_singleton()->remove_export_plugin(p_exporter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditorPlugin::add_inspector_plugin(const Ref<EditorInspectorPlugin> &p_plugin) {
|
||||||
|
EditorInspector::add_inspector_plugin(p_plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditorPlugin::remove_inspector_plugin(const Ref<EditorInspectorPlugin> &p_plugin) {
|
||||||
|
EditorInspector::remove_inspector_plugin(p_plugin);
|
||||||
|
}
|
||||||
|
|
||||||
void EditorPlugin::add_scene_import_plugin(const Ref<EditorSceneImporter> &p_importer) {
|
void EditorPlugin::add_scene_import_plugin(const Ref<EditorSceneImporter> &p_importer) {
|
||||||
ResourceImporterScene::get_singleton()->add_importer(p_importer);
|
ResourceImporterScene::get_singleton()->add_importer(p_importer);
|
||||||
}
|
}
|
||||||
@ -728,8 +736,10 @@ void EditorPlugin::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("remove_import_plugin", "importer"), &EditorPlugin::remove_import_plugin);
|
ClassDB::bind_method(D_METHOD("remove_import_plugin", "importer"), &EditorPlugin::remove_import_plugin);
|
||||||
ClassDB::bind_method(D_METHOD("add_scene_import_plugin", "scene_importer"), &EditorPlugin::add_scene_import_plugin);
|
ClassDB::bind_method(D_METHOD("add_scene_import_plugin", "scene_importer"), &EditorPlugin::add_scene_import_plugin);
|
||||||
ClassDB::bind_method(D_METHOD("remove_scene_import_plugin", "scene_importer"), &EditorPlugin::remove_scene_import_plugin);
|
ClassDB::bind_method(D_METHOD("remove_scene_import_plugin", "scene_importer"), &EditorPlugin::remove_scene_import_plugin);
|
||||||
ClassDB::bind_method(D_METHOD("add_export_plugin", "exporter"), &EditorPlugin::add_export_plugin);
|
ClassDB::bind_method(D_METHOD("add_export_plugin", "plugin"), &EditorPlugin::add_export_plugin);
|
||||||
ClassDB::bind_method(D_METHOD("remove_export_plugin", "exporter"), &EditorPlugin::remove_export_plugin);
|
ClassDB::bind_method(D_METHOD("remove_export_plugin", "plugin"), &EditorPlugin::remove_export_plugin);
|
||||||
|
ClassDB::bind_method(D_METHOD("add_inspector_plugin", "plugin"), &EditorPlugin::add_inspector_plugin);
|
||||||
|
ClassDB::bind_method(D_METHOD("remove_inspector_plugin", "plugin"), &EditorPlugin::remove_inspector_plugin);
|
||||||
ClassDB::bind_method(D_METHOD("set_input_event_forwarding_always_enabled"), &EditorPlugin::set_input_event_forwarding_always_enabled);
|
ClassDB::bind_method(D_METHOD("set_input_event_forwarding_always_enabled"), &EditorPlugin::set_input_event_forwarding_always_enabled);
|
||||||
ClassDB::bind_method(D_METHOD("set_force_draw_over_forwarding_enabled"), &EditorPlugin::set_force_draw_over_forwarding_enabled);
|
ClassDB::bind_method(D_METHOD("set_force_draw_over_forwarding_enabled"), &EditorPlugin::set_force_draw_over_forwarding_enabled);
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#ifndef EDITOR_PLUGIN_H
|
#ifndef EDITOR_PLUGIN_H
|
||||||
#define EDITOR_PLUGIN_H
|
#define EDITOR_PLUGIN_H
|
||||||
|
|
||||||
|
#include "editor/editor_inspector.h"
|
||||||
#include "editor/import/editor_import_plugin.h"
|
#include "editor/import/editor_import_plugin.h"
|
||||||
#include "editor/import/resource_importer_scene.h"
|
#include "editor/import/resource_importer_scene.h"
|
||||||
#include "io/config_file.h"
|
#include "io/config_file.h"
|
||||||
@ -210,6 +211,9 @@ public:
|
|||||||
void add_export_plugin(const Ref<EditorExportPlugin> &p_exporter);
|
void add_export_plugin(const Ref<EditorExportPlugin> &p_exporter);
|
||||||
void remove_export_plugin(const Ref<EditorExportPlugin> &p_exporter);
|
void remove_export_plugin(const Ref<EditorExportPlugin> &p_exporter);
|
||||||
|
|
||||||
|
void add_inspector_plugin(const Ref<EditorInspectorPlugin> &p_plugin);
|
||||||
|
void remove_inspector_plugin(const Ref<EditorInspectorPlugin> &p_plugin);
|
||||||
|
|
||||||
void add_scene_import_plugin(const Ref<EditorSceneImporter> &p_importer);
|
void add_scene_import_plugin(const Ref<EditorSceneImporter> &p_importer);
|
||||||
void remove_scene_import_plugin(const Ref<EditorSceneImporter> &p_importer);
|
void remove_scene_import_plugin(const Ref<EditorSceneImporter> &p_importer);
|
||||||
|
|
||||||
|
@ -118,8 +118,8 @@ void EditorPropertyMultilineText::_bind_methods() {
|
|||||||
|
|
||||||
EditorPropertyMultilineText::EditorPropertyMultilineText() {
|
EditorPropertyMultilineText::EditorPropertyMultilineText() {
|
||||||
HBoxContainer *hb = memnew(HBoxContainer);
|
HBoxContainer *hb = memnew(HBoxContainer);
|
||||||
set_label_layout(LABEL_LAYOUT_TOP);
|
|
||||||
add_child(hb);
|
add_child(hb);
|
||||||
|
set_bottom_editor(hb);
|
||||||
text = memnew(TextEdit);
|
text = memnew(TextEdit);
|
||||||
text->connect("text_changed", this, "_text_changed");
|
text->connect("text_changed", this, "_text_changed");
|
||||||
add_focusable(text);
|
add_focusable(text);
|
||||||
@ -622,6 +622,7 @@ void EditorPropertyLayers::_button_pressed() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Rect2 gp = button->get_global_rect();
|
Rect2 gp = button->get_global_rect();
|
||||||
|
layers->set_as_minsize();
|
||||||
Vector2 popup_pos = gp.position - Vector2(layers->get_combined_minimum_size().x, 0);
|
Vector2 popup_pos = gp.position - Vector2(layers->get_combined_minimum_size().x, 0);
|
||||||
layers->set_global_position(popup_pos);
|
layers->set_global_position(popup_pos);
|
||||||
layers->popup();
|
layers->popup();
|
||||||
@ -656,7 +657,7 @@ EditorPropertyLayers::EditorPropertyLayers() {
|
|||||||
button->set_text("..");
|
button->set_text("..");
|
||||||
button->connect("pressed", this, "_button_pressed");
|
button->connect("pressed", this, "_button_pressed");
|
||||||
hb->add_child(button);
|
hb->add_child(button);
|
||||||
set_label_layout(LABEL_LAYOUT_TOP);
|
set_bottom_editor(hb);
|
||||||
layers = memnew(PopupMenu);
|
layers = memnew(PopupMenu);
|
||||||
add_child(layers);
|
add_child(layers);
|
||||||
layers->connect("id_pressed", this, "_menu_pressed");
|
layers->connect("id_pressed", this, "_menu_pressed");
|
||||||
@ -1267,8 +1268,7 @@ EditorPropertyAABB::EditorPropertyAABB() {
|
|||||||
add_focusable(spin[i]);
|
add_focusable(spin[i]);
|
||||||
spin[i]->connect("value_changed", this, "_value_changed");
|
spin[i]->connect("value_changed", this, "_value_changed");
|
||||||
}
|
}
|
||||||
set_label_reference(spin[0]); //show text and buttons around this
|
set_bottom_editor(g);
|
||||||
set_label_layout(LABEL_LAYOUT_TOP);
|
|
||||||
setting = false;
|
setting = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1330,8 +1330,7 @@ EditorPropertyTransform2D::EditorPropertyTransform2D() {
|
|||||||
add_focusable(spin[i]);
|
add_focusable(spin[i]);
|
||||||
spin[i]->connect("value_changed", this, "_value_changed");
|
spin[i]->connect("value_changed", this, "_value_changed");
|
||||||
}
|
}
|
||||||
set_label_reference(spin[0]); //show text and buttons around this
|
set_bottom_editor(g);
|
||||||
set_label_layout(LABEL_LAYOUT_TOP);
|
|
||||||
setting = false;
|
setting = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1399,8 +1398,7 @@ EditorPropertyBasis::EditorPropertyBasis() {
|
|||||||
add_focusable(spin[i]);
|
add_focusable(spin[i]);
|
||||||
spin[i]->connect("value_changed", this, "_value_changed");
|
spin[i]->connect("value_changed", this, "_value_changed");
|
||||||
}
|
}
|
||||||
set_label_reference(spin[0]); //show text and buttons around this
|
set_bottom_editor(g);
|
||||||
set_label_layout(LABEL_LAYOUT_TOP);
|
|
||||||
setting = false;
|
setting = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1474,8 +1472,7 @@ EditorPropertyTransform::EditorPropertyTransform() {
|
|||||||
add_focusable(spin[i]);
|
add_focusable(spin[i]);
|
||||||
spin[i]->connect("value_changed", this, "_value_changed");
|
spin[i]->connect("value_changed", this, "_value_changed");
|
||||||
}
|
}
|
||||||
set_label_reference(spin[0]); //show text and buttons around this
|
set_bottom_editor(g);
|
||||||
set_label_layout(LABEL_LAYOUT_TOP);
|
|
||||||
setting = false;
|
setting = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1952,23 +1949,75 @@ void EditorPropertyResource::_update_menu() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Rect2 gt = get_global_rect();
|
Rect2 gt = edit->get_global_rect();
|
||||||
|
menu->set_as_minsize();
|
||||||
int ms = menu->get_combined_minimum_size().width;
|
int ms = menu->get_combined_minimum_size().width;
|
||||||
Vector2 popup_pos = gt.position + gt.size - Vector2(ms, 0);
|
Vector2 popup_pos = gt.position + gt.size - Vector2(ms, 0);
|
||||||
menu->set_position(popup_pos);
|
menu->set_global_position(popup_pos);
|
||||||
menu->popup();
|
menu->popup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditorPropertyResource::_sub_inspector_property_keyed(const String &p_property, const Variant &p_value, bool) {
|
||||||
|
|
||||||
|
emit_signal("property_keyed_with_value", String(get_edited_property()) + ":" + p_property, p_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditorPropertyResource::_sub_inspector_resource_selected(const RES &p_resource, const String &p_property) {
|
||||||
|
|
||||||
|
emit_signal("resource_selected", String(get_edited_property()) + ":" + p_property, p_resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditorPropertyResource::_sub_inspector_object_id_selected(int p_id) {
|
||||||
|
|
||||||
|
emit_signal("object_id_selected", get_edited_property(), p_id);
|
||||||
|
}
|
||||||
|
|
||||||
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());
|
||||||
|
|
||||||
|
if (use_sub_inspector) {
|
||||||
|
|
||||||
|
if (res.is_valid() != assign->is_toggle_mode()) {
|
||||||
|
assign->set_toggle_mode(res.is_valid());
|
||||||
|
}
|
||||||
|
#ifdef TOOLS_ENABLED
|
||||||
|
if (res.is_valid() && get_edited_object()->editor_is_section_unfolded(get_edited_property())) {
|
||||||
|
|
||||||
|
if (!sub_inspector) {
|
||||||
|
sub_inspector = memnew(EditorInspector);
|
||||||
|
sub_inspector->set_enable_v_scroll(false);
|
||||||
|
|
||||||
|
sub_inspector->connect("property_keyed", this, "_sub_inspector_property_keyed");
|
||||||
|
sub_inspector->connect("resource_selected", this, "_sub_inspector_resource_selected");
|
||||||
|
sub_inspector->connect("object_id_selected", this, "_sub_inspector_object_id_selected");
|
||||||
|
sub_inspector->set_keying(is_keying());
|
||||||
|
sub_inspector->set_read_only(is_read_only());
|
||||||
|
sub_inspector->set_use_folding(is_using_folding());
|
||||||
|
|
||||||
|
add_child(sub_inspector);
|
||||||
|
set_bottom_editor(sub_inspector);
|
||||||
|
assign->set_pressed(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (res.ptr() != sub_inspector->get_edited_object()) {
|
||||||
|
sub_inspector->edit(res.ptr());
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (sub_inspector) {
|
||||||
|
set_bottom_editor(NULL);
|
||||||
|
memdelete(sub_inspector);
|
||||||
|
sub_inspector = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
if (res == RES()) {
|
if (res == RES()) {
|
||||||
assign->set_icon(Ref<Texture>());
|
assign->set_icon(Ref<Texture>());
|
||||||
assign->set_text(TTR("[empty]"));
|
assign->set_text(TTR("[empty]"));
|
||||||
assign->set_disabled(true);
|
|
||||||
} else {
|
} else {
|
||||||
assign->set_disabled(false);
|
|
||||||
|
|
||||||
Ref<Texture> icon;
|
Ref<Texture> icon;
|
||||||
if (has_icon(res->get_class(), "EditorIcons"))
|
if (has_icon(res->get_class(), "EditorIcons"))
|
||||||
@ -1999,7 +2048,16 @@ void EditorPropertyResource::update_property() {
|
|||||||
void EditorPropertyResource::_resource_selected() {
|
void EditorPropertyResource::_resource_selected() {
|
||||||
RES res = get_edited_object()->get(get_edited_property());
|
RES res = get_edited_object()->get(get_edited_property());
|
||||||
|
|
||||||
if (!res.is_null()) {
|
if (res.is_null()) {
|
||||||
|
_update_menu();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (use_sub_inspector) {
|
||||||
|
|
||||||
|
get_edited_object()->editor_set_section_unfold(get_edited_property(), assign->is_pressed());
|
||||||
|
update_property();
|
||||||
|
} else {
|
||||||
|
|
||||||
emit_signal("resource_selected", get_edited_property(), res);
|
emit_signal("resource_selected", get_edited_property(), res);
|
||||||
}
|
}
|
||||||
@ -2033,6 +2091,20 @@ void EditorPropertyResource::_viewport_selected(const NodePath &p_path) {
|
|||||||
emit_signal("property_changed", get_edited_property(), vt);
|
emit_signal("property_changed", get_edited_property(), vt);
|
||||||
update_property();
|
update_property();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditorPropertyResource::collapse_all_folding() {
|
||||||
|
if (sub_inspector) {
|
||||||
|
sub_inspector->collapse_all_folding();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditorPropertyResource::expand_all_folding() {
|
||||||
|
|
||||||
|
if (sub_inspector) {
|
||||||
|
sub_inspector->expand_all_folding();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void EditorPropertyResource::_bind_methods() {
|
void EditorPropertyResource::_bind_methods() {
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("_file_selected"), &EditorPropertyResource::_file_selected);
|
ClassDB::bind_method(D_METHOD("_file_selected"), &EditorPropertyResource::_file_selected);
|
||||||
@ -2041,10 +2113,15 @@ void EditorPropertyResource::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("_resource_preview"), &EditorPropertyResource::_resource_preview);
|
ClassDB::bind_method(D_METHOD("_resource_preview"), &EditorPropertyResource::_resource_preview);
|
||||||
ClassDB::bind_method(D_METHOD("_resource_selected"), &EditorPropertyResource::_resource_selected);
|
ClassDB::bind_method(D_METHOD("_resource_selected"), &EditorPropertyResource::_resource_selected);
|
||||||
ClassDB::bind_method(D_METHOD("_viewport_selected"), &EditorPropertyResource::_viewport_selected);
|
ClassDB::bind_method(D_METHOD("_viewport_selected"), &EditorPropertyResource::_viewport_selected);
|
||||||
|
ClassDB::bind_method(D_METHOD("_sub_inspector_property_keyed"), &EditorPropertyResource::_sub_inspector_property_keyed);
|
||||||
|
ClassDB::bind_method(D_METHOD("_sub_inspector_resource_selected"), &EditorPropertyResource::_sub_inspector_resource_selected);
|
||||||
|
ClassDB::bind_method(D_METHOD("_sub_inspector_object_id_selected"), &EditorPropertyResource::_sub_inspector_object_id_selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorPropertyResource::EditorPropertyResource() {
|
EditorPropertyResource::EditorPropertyResource() {
|
||||||
|
|
||||||
|
sub_inspector = NULL;
|
||||||
|
use_sub_inspector = !bool(EDITOR_GET("interface/inspector/open_resources_in_new_inspector"));
|
||||||
HBoxContainer *hbc = memnew(HBoxContainer);
|
HBoxContainer *hbc = memnew(HBoxContainer);
|
||||||
add_child(hbc);
|
add_child(hbc);
|
||||||
assign = memnew(Button);
|
assign = memnew(Button);
|
||||||
|
@ -481,7 +481,9 @@ class EditorPropertyResource : public EditorProperty {
|
|||||||
PopupMenu *menu;
|
PopupMenu *menu;
|
||||||
EditorFileDialog *file;
|
EditorFileDialog *file;
|
||||||
Vector<String> inheritors_array;
|
Vector<String> inheritors_array;
|
||||||
|
EditorInspector *sub_inspector;
|
||||||
|
|
||||||
|
bool use_sub_inspector;
|
||||||
String base_type;
|
String base_type;
|
||||||
|
|
||||||
SceneTreeDialog *scene_tree;
|
SceneTreeDialog *scene_tree;
|
||||||
@ -494,6 +496,10 @@ class EditorPropertyResource : public EditorProperty {
|
|||||||
|
|
||||||
void _update_menu();
|
void _update_menu();
|
||||||
|
|
||||||
|
void _sub_inspector_property_keyed(const String &p_property, const Variant &p_value, bool);
|
||||||
|
void _sub_inspector_resource_selected(const RES &p_resource, const String &p_property);
|
||||||
|
void _sub_inspector_object_id_selected(int p_id);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
@ -501,6 +507,10 @@ protected:
|
|||||||
public:
|
public:
|
||||||
virtual void update_property();
|
virtual void update_property();
|
||||||
void setup(const String &p_base_type);
|
void setup(const String &p_base_type);
|
||||||
|
|
||||||
|
void collapse_all_folding();
|
||||||
|
void expand_all_folding();
|
||||||
|
|
||||||
EditorPropertyResource();
|
EditorPropertyResource();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@ void CollisionPolygon2DEditor::_set_node(Node *p_polygon) {
|
|||||||
|
|
||||||
CollisionPolygon2DEditor::CollisionPolygon2DEditor(EditorNode *p_editor) :
|
CollisionPolygon2DEditor::CollisionPolygon2DEditor(EditorNode *p_editor) :
|
||||||
AbstractPolygon2DEditor(p_editor) {
|
AbstractPolygon2DEditor(p_editor) {
|
||||||
|
node = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
CollisionPolygon2DEditorPlugin::CollisionPolygon2DEditorPlugin(EditorNode *p_node) :
|
CollisionPolygon2DEditorPlugin::CollisionPolygon2DEditorPlugin(EditorNode *p_node) :
|
||||||
|
@ -91,7 +91,7 @@ void CurveEditor::set_curve(Ref<Curve> curve) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Size2 CurveEditor::get_minimum_size() const {
|
Size2 CurveEditor::get_minimum_size() const {
|
||||||
return Vector2(64, 64);
|
return Vector2(64, 150) * EDSCALE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveEditor::_notification(int p_what) {
|
void CurveEditor::_notification(int p_what) {
|
||||||
@ -639,7 +639,7 @@ void CurveEditor::_draw() {
|
|||||||
|
|
||||||
Ref<Font> font = get_font("font", "Label");
|
Ref<Font> font = get_font("font", "Label");
|
||||||
float font_height = font->get_height();
|
float font_height = font->get_height();
|
||||||
const Color text_color = get_color("font_color", "Editor");
|
Color text_color = get_color("font_color", "Editor");
|
||||||
|
|
||||||
{
|
{
|
||||||
// X axis
|
// X axis
|
||||||
@ -720,6 +720,7 @@ void CurveEditor::_draw() {
|
|||||||
// Help text
|
// Help text
|
||||||
|
|
||||||
if (_selected_point > 0 && _selected_point + 1 < curve.get_point_count()) {
|
if (_selected_point > 0 && _selected_point + 1 < curve.get_point_count()) {
|
||||||
|
text_color.a *= 0.4;
|
||||||
draw_string(font, Vector2(50, font_height), TTR("Hold Shift to edit tangents individually"), text_color);
|
draw_string(font, Vector2(50, font_height), TTR("Hold Shift to edit tangents individually"), text_color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -750,89 +751,30 @@ void CurveEditor::_bind_methods() {
|
|||||||
|
|
||||||
//---------------
|
//---------------
|
||||||
|
|
||||||
|
bool EditorInspectorPluginCurve::can_handle(Object *p_object) {
|
||||||
|
|
||||||
|
return Object::cast_to<Curve>(p_object) != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditorInspectorPluginCurve::parse_begin(Object *p_object) {
|
||||||
|
|
||||||
|
Curve *curve = Object::cast_to<Curve>(p_object);
|
||||||
|
ERR_FAIL_COND(!curve);
|
||||||
|
Ref<Curve> c(curve);
|
||||||
|
|
||||||
|
CurveEditor *editor = memnew(CurveEditor);
|
||||||
|
editor->set_curve(curve);
|
||||||
|
add_custom_control(editor);
|
||||||
|
}
|
||||||
|
|
||||||
CurveEditorPlugin::CurveEditorPlugin(EditorNode *p_node) {
|
CurveEditorPlugin::CurveEditorPlugin(EditorNode *p_node) {
|
||||||
_editor_node = p_node;
|
Ref<EditorInspectorPluginCurve> curve_plugin;
|
||||||
|
curve_plugin.instance();
|
||||||
_view = memnew(CurveEditor);
|
EditorInspector::add_inspector_plugin(curve_plugin);
|
||||||
_view->set_custom_minimum_size(Size2(100, 128 * EDSCALE));
|
|
||||||
_view->hide();
|
|
||||||
|
|
||||||
_toggle_button = _editor_node->add_bottom_panel_item(get_name(), _view);
|
|
||||||
_toggle_button->hide();
|
|
||||||
|
|
||||||
get_editor_interface()->get_resource_previewer()->add_preview_generator(memnew(CurvePreviewGenerator));
|
get_editor_interface()->get_resource_previewer()->add_preview_generator(memnew(CurvePreviewGenerator));
|
||||||
}
|
}
|
||||||
|
|
||||||
CurveEditorPlugin::~CurveEditorPlugin() {
|
|
||||||
}
|
|
||||||
|
|
||||||
void CurveEditorPlugin::edit(Object *p_object) {
|
|
||||||
|
|
||||||
Ref<Curve> curve_ref;
|
|
||||||
|
|
||||||
if (_current_ref.is_valid()) {
|
|
||||||
CurveTexture *ct = Object::cast_to<CurveTexture>(*_current_ref);
|
|
||||||
if (ct)
|
|
||||||
ct->disconnect(CoreStringNames::get_singleton()->changed, this, "_curve_texture_changed");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (p_object) {
|
|
||||||
Resource *res = Object::cast_to<Resource>(p_object);
|
|
||||||
ERR_FAIL_COND(res == NULL);
|
|
||||||
ERR_FAIL_COND(!handles(p_object));
|
|
||||||
|
|
||||||
_current_ref = Ref<Resource>(Object::cast_to<Resource>(p_object));
|
|
||||||
|
|
||||||
if (_current_ref.is_valid()) {
|
|
||||||
Curve *curve = Object::cast_to<Curve>(*_current_ref);
|
|
||||||
if (curve)
|
|
||||||
curve_ref = Ref<Curve>(curve);
|
|
||||||
else {
|
|
||||||
CurveTexture *ct = Object::cast_to<CurveTexture>(*_current_ref);
|
|
||||||
if (ct) {
|
|
||||||
ct->connect(CoreStringNames::get_singleton()->changed, this, "_curve_texture_changed");
|
|
||||||
curve_ref = ct->get_curve();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
_current_ref = Ref<Resource>();
|
|
||||||
}
|
|
||||||
|
|
||||||
_view->set_curve(curve_ref);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CurveEditorPlugin::handles(Object *p_object) const {
|
|
||||||
// Both handled so that we can keep the curve editor open
|
|
||||||
return Object::cast_to<Curve>(p_object) || Object::cast_to<CurveTexture>(p_object);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CurveEditorPlugin::make_visible(bool p_visible) {
|
|
||||||
if (p_visible) {
|
|
||||||
_toggle_button->show();
|
|
||||||
_editor_node->make_bottom_panel_item_visible(_view);
|
|
||||||
} else {
|
|
||||||
_toggle_button->hide();
|
|
||||||
if (_view->is_visible_in_tree())
|
|
||||||
_editor_node->hide_bottom_panel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CurveEditorPlugin::_curve_texture_changed() {
|
|
||||||
// If the curve is shown indirectly as a CurveTexture is edited,
|
|
||||||
// we need to monitor when the curve property gets assigned
|
|
||||||
CurveTexture *ct = Object::cast_to<CurveTexture>(*_current_ref);
|
|
||||||
if (ct) {
|
|
||||||
_view->set_curve(ct->get_curve());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CurveEditorPlugin::_bind_methods() {
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("_curve_texture_changed"), &CurveEditorPlugin::_curve_texture_changed);
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------
|
//-----------------------------------
|
||||||
// Preview generator
|
// Preview generator
|
||||||
|
|
||||||
|
@ -119,28 +119,19 @@ private:
|
|||||||
float _tangents_length;
|
float _tangents_length;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class EditorInspectorPluginCurve : public EditorInspectorPlugin {
|
||||||
|
GDCLASS(EditorInspectorPluginCurve, EditorInspectorPlugin)
|
||||||
|
public:
|
||||||
|
virtual bool can_handle(Object *p_object);
|
||||||
|
virtual void parse_begin(Object *p_object);
|
||||||
|
};
|
||||||
|
|
||||||
class CurveEditorPlugin : public EditorPlugin {
|
class CurveEditorPlugin : public EditorPlugin {
|
||||||
GDCLASS(CurveEditorPlugin, EditorPlugin)
|
GDCLASS(CurveEditorPlugin, EditorPlugin)
|
||||||
public:
|
public:
|
||||||
CurveEditorPlugin(EditorNode *p_node);
|
CurveEditorPlugin(EditorNode *p_node);
|
||||||
~CurveEditorPlugin();
|
|
||||||
|
|
||||||
String get_name() const { return "Curve"; }
|
String get_name() const { return "Curve"; }
|
||||||
bool has_main_screen() const { return false; }
|
|
||||||
void edit(Object *p_object);
|
|
||||||
bool handles(Object *p_object) const;
|
|
||||||
void make_visible(bool p_visible);
|
|
||||||
|
|
||||||
private:
|
|
||||||
static void _bind_methods();
|
|
||||||
|
|
||||||
void _curve_texture_changed();
|
|
||||||
|
|
||||||
private:
|
|
||||||
CurveEditor *_view;
|
|
||||||
Ref<Resource> _current_ref;
|
|
||||||
EditorNode *_editor_node;
|
|
||||||
ToolButton *_toggle_button;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class CurvePreviewGenerator : public EditorResourcePreviewGenerator {
|
class CurvePreviewGenerator : public EditorResourcePreviewGenerator {
|
||||||
|
@ -33,77 +33,70 @@
|
|||||||
#include "canvas_item_editor_plugin.h"
|
#include "canvas_item_editor_plugin.h"
|
||||||
#include "spatial_editor_plugin.h"
|
#include "spatial_editor_plugin.h"
|
||||||
|
|
||||||
GradientEditorPlugin::GradientEditorPlugin(EditorNode *p_node) {
|
Size2 GradientEditor::get_minimum_size() const {
|
||||||
|
return Size2(0, 60) * EDSCALE;
|
||||||
|
}
|
||||||
|
void GradientEditor::_gradient_changed() {
|
||||||
|
|
||||||
editor = p_node;
|
if (editing)
|
||||||
ramp_editor = memnew(GradientEdit);
|
return;
|
||||||
|
|
||||||
add_control_to_container(CONTAINER_PROPERTY_EDITOR_BOTTOM, ramp_editor);
|
editing = true;
|
||||||
|
Vector<Gradient::Point> points = gradient->get_points();
|
||||||
ramp_editor->set_custom_minimum_size(Size2(100, 48));
|
set_points(points);
|
||||||
ramp_editor->hide();
|
editing = false;
|
||||||
ramp_editor->connect("ramp_changed", this, "ramp_changed");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GradientEditorPlugin::edit(Object *p_object) {
|
void GradientEditor::_ramp_changed() {
|
||||||
|
|
||||||
|
editing = true;
|
||||||
|
UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo();
|
||||||
|
undo_redo->create_action("Gradient Edited");
|
||||||
|
undo_redo->add_do_method(gradient.ptr(), "set_offsets", get_offsets());
|
||||||
|
undo_redo->add_do_method(gradient.ptr(), "set_colors", get_colors());
|
||||||
|
undo_redo->add_undo_method(gradient.ptr(), "set_offsets", gradient->get_offsets());
|
||||||
|
undo_redo->add_undo_method(gradient.ptr(), "set_colors", gradient->get_colors());
|
||||||
|
undo_redo->commit_action();
|
||||||
|
editing = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GradientEditor::_bind_methods() {
|
||||||
|
|
||||||
|
ClassDB::bind_method("_gradient_changed", &GradientEditor::_gradient_changed);
|
||||||
|
ClassDB::bind_method("_ramp_changed", &GradientEditor::_ramp_changed);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GradientEditor::set_gradient(const Ref<Gradient> &p_gradient) {
|
||||||
|
gradient = p_gradient;
|
||||||
|
connect("ramp_changed", this, "_ramp_changed");
|
||||||
|
gradient->connect("changed", this, "_gradient_changed");
|
||||||
|
set_points(gradient->get_points());
|
||||||
|
}
|
||||||
|
|
||||||
|
GradientEditor::GradientEditor() {
|
||||||
|
editing = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////
|
||||||
|
|
||||||
|
bool EditorInspectorPluginGradient::can_handle(Object *p_object) {
|
||||||
|
|
||||||
|
return Object::cast_to<Gradient>(p_object) != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditorInspectorPluginGradient::parse_begin(Object *p_object) {
|
||||||
|
|
||||||
Gradient *gradient = Object::cast_to<Gradient>(p_object);
|
Gradient *gradient = Object::cast_to<Gradient>(p_object);
|
||||||
if (!gradient)
|
Ref<Gradient> g(gradient);
|
||||||
return;
|
|
||||||
gradient_ref = Ref<Gradient>(gradient);
|
GradientEditor *editor = memnew(GradientEditor);
|
||||||
ramp_editor->set_points(gradient_ref->get_points());
|
editor->set_gradient(g);
|
||||||
|
add_custom_control(editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GradientEditorPlugin::handles(Object *p_object) const {
|
GradientEditorPlugin::GradientEditorPlugin(EditorNode *p_node) {
|
||||||
|
|
||||||
return p_object->is_class("Gradient");
|
Ref<EditorInspectorPluginGradient> plugin;
|
||||||
}
|
plugin.instance();
|
||||||
|
add_inspector_plugin(plugin);
|
||||||
void GradientEditorPlugin::make_visible(bool p_visible) {
|
|
||||||
|
|
||||||
if (p_visible) {
|
|
||||||
ramp_editor->show();
|
|
||||||
} else {
|
|
||||||
ramp_editor->hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GradientEditorPlugin::_ramp_changed() {
|
|
||||||
|
|
||||||
if (gradient_ref.is_valid()) {
|
|
||||||
|
|
||||||
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
|
|
||||||
|
|
||||||
//Not sure if I should convert this data to PoolVector
|
|
||||||
Vector<float> new_offsets = ramp_editor->get_offsets();
|
|
||||||
Vector<Color> new_colors = ramp_editor->get_colors();
|
|
||||||
Vector<float> old_offsets = gradient_ref->get_offsets();
|
|
||||||
Vector<Color> old_colors = gradient_ref->get_colors();
|
|
||||||
|
|
||||||
if (old_offsets.size() != new_offsets.size())
|
|
||||||
ur->create_action(TTR("Add/Remove Color Ramp Point"));
|
|
||||||
else
|
|
||||||
ur->create_action(TTR("Modify Color Ramp"), UndoRedo::MERGE_ENDS);
|
|
||||||
ur->add_do_method(this, "undo_redo_gradient", new_offsets, new_colors);
|
|
||||||
ur->add_undo_method(this, "undo_redo_gradient", old_offsets, old_colors);
|
|
||||||
ur->commit_action();
|
|
||||||
|
|
||||||
//color_ramp_ref->set_points(ramp_editor->get_points());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GradientEditorPlugin::_undo_redo_gradient(const Vector<float> &offsets, const Vector<Color> &colors) {
|
|
||||||
|
|
||||||
gradient_ref->set_offsets(offsets);
|
|
||||||
gradient_ref->set_colors(colors);
|
|
||||||
ramp_editor->set_points(gradient_ref->get_points());
|
|
||||||
ramp_editor->update();
|
|
||||||
}
|
|
||||||
|
|
||||||
GradientEditorPlugin::~GradientEditorPlugin() {
|
|
||||||
}
|
|
||||||
|
|
||||||
void GradientEditorPlugin::_bind_methods() {
|
|
||||||
ClassDB::bind_method(D_METHOD("ramp_changed"), &GradientEditorPlugin::_ramp_changed);
|
|
||||||
ClassDB::bind_method(D_METHOD("undo_redo_gradient", "offsets", "colors"), &GradientEditorPlugin::_undo_redo_gradient);
|
|
||||||
}
|
}
|
||||||
|
@ -35,28 +35,39 @@
|
|||||||
#include "editor/editor_plugin.h"
|
#include "editor/editor_plugin.h"
|
||||||
#include "scene/gui/gradient_edit.h"
|
#include "scene/gui/gradient_edit.h"
|
||||||
|
|
||||||
|
class GradientEditor : public GradientEdit {
|
||||||
|
GDCLASS(GradientEditor, GradientEdit)
|
||||||
|
|
||||||
|
bool editing;
|
||||||
|
Ref<Gradient> gradient;
|
||||||
|
|
||||||
|
void _gradient_changed();
|
||||||
|
void _ramp_changed();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static void _bind_methods();
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual Size2 get_minimum_size() const;
|
||||||
|
void set_gradient(const Ref<Gradient> &p_gradient);
|
||||||
|
GradientEditor();
|
||||||
|
};
|
||||||
|
|
||||||
|
class EditorInspectorPluginGradient : public EditorInspectorPlugin {
|
||||||
|
GDCLASS(EditorInspectorPluginGradient, EditorInspectorPlugin)
|
||||||
|
public:
|
||||||
|
virtual bool can_handle(Object *p_object);
|
||||||
|
virtual void parse_begin(Object *p_object);
|
||||||
|
};
|
||||||
|
|
||||||
class GradientEditorPlugin : public EditorPlugin {
|
class GradientEditorPlugin : public EditorPlugin {
|
||||||
|
|
||||||
GDCLASS(GradientEditorPlugin, EditorPlugin);
|
GDCLASS(GradientEditorPlugin, EditorPlugin);
|
||||||
|
|
||||||
Ref<Gradient> gradient_ref;
|
|
||||||
GradientEdit *ramp_editor;
|
|
||||||
EditorNode *editor;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
static void _bind_methods();
|
|
||||||
void _ramp_changed();
|
|
||||||
void _undo_redo_gradient(const Vector<float> &offsets, const Vector<Color> &colors);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual String get_name() const { return "ColorRamp"; }
|
virtual String get_name() const { return "ColorRamp"; }
|
||||||
bool has_main_screen() const { return false; }
|
|
||||||
virtual void edit(Object *p_object);
|
|
||||||
virtual bool handles(Object *p_object) const;
|
|
||||||
virtual void make_visible(bool p_visible);
|
|
||||||
|
|
||||||
GradientEditorPlugin(EditorNode *p_node);
|
GradientEditorPlugin(EditorNode *p_node);
|
||||||
~GradientEditorPlugin();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* TOOLS_EDITOR_PLUGINS_COLOR_RAMP_EDITOR_PLUGIN_H_ */
|
#endif /* TOOLS_EDITOR_PLUGINS_COLOR_RAMP_EDITOR_PLUGIN_H_ */
|
||||||
|
@ -64,6 +64,7 @@ void Line2DEditor::_action_set_polygon(int p_idx, const Variant &p_previous, con
|
|||||||
|
|
||||||
Line2DEditor::Line2DEditor(EditorNode *p_editor) :
|
Line2DEditor::Line2DEditor(EditorNode *p_editor) :
|
||||||
AbstractPolygon2DEditor(p_editor) {
|
AbstractPolygon2DEditor(p_editor) {
|
||||||
|
node = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Line2DEditorPlugin::Line2DEditorPlugin(EditorNode *p_node) :
|
Line2DEditorPlugin::Line2DEditorPlugin(EditorNode *p_node) :
|
||||||
|
@ -123,6 +123,7 @@ void NavigationPolygonEditor::_create_resource() {
|
|||||||
|
|
||||||
NavigationPolygonEditor::NavigationPolygonEditor(EditorNode *p_editor) :
|
NavigationPolygonEditor::NavigationPolygonEditor(EditorNode *p_editor) :
|
||||||
AbstractPolygon2DEditor(p_editor) {
|
AbstractPolygon2DEditor(p_editor) {
|
||||||
|
node = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
NavigationPolygonEditorPlugin::NavigationPolygonEditorPlugin(EditorNode *p_node) :
|
NavigationPolygonEditorPlugin::NavigationPolygonEditorPlugin(EditorNode *p_node) :
|
||||||
|
@ -1035,6 +1035,7 @@ Vector2 Polygon2DEditor::snap_point(Vector2 p_target) const {
|
|||||||
Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) :
|
Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) :
|
||||||
AbstractPolygon2DEditor(p_editor) {
|
AbstractPolygon2DEditor(p_editor) {
|
||||||
|
|
||||||
|
node = NULL;
|
||||||
snap_step = Vector2(10, 10);
|
snap_step = Vector2(10, 10);
|
||||||
use_snap = false;
|
use_snap = false;
|
||||||
snap_show_grid = false;
|
snap_show_grid = false;
|
||||||
|
@ -30,7 +30,26 @@
|
|||||||
|
|
||||||
#include "style_box_editor_plugin.h"
|
#include "style_box_editor_plugin.h"
|
||||||
|
|
||||||
void StyleBoxEditor::edit(const Ref<StyleBox> &p_stylebox) {
|
bool EditorInspectorPluginStyleBox::can_handle(Object *p_object) {
|
||||||
|
|
||||||
|
return Object::cast_to<StyleBox>(p_object) != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditorInspectorPluginStyleBox::parse_begin(Object *p_object) {
|
||||||
|
|
||||||
|
Ref<StyleBox> sb = Ref<StyleBox>(Object::cast_to<StyleBox>(p_object));
|
||||||
|
|
||||||
|
StyleBoxPreview *preview = memnew(StyleBoxPreview);
|
||||||
|
preview->edit(sb);
|
||||||
|
add_custom_control(preview);
|
||||||
|
}
|
||||||
|
bool EditorInspectorPluginStyleBox::parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage) {
|
||||||
|
return false; //do not want
|
||||||
|
}
|
||||||
|
void EditorInspectorPluginStyleBox::parse_end() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void StyleBoxPreview::edit(const Ref<StyleBox> &p_stylebox) {
|
||||||
|
|
||||||
if (stylebox.is_valid())
|
if (stylebox.is_valid())
|
||||||
stylebox->disconnect("changed", this, "_sb_changed");
|
stylebox->disconnect("changed", this, "_sb_changed");
|
||||||
@ -39,71 +58,33 @@ void StyleBoxEditor::edit(const Ref<StyleBox> &p_stylebox) {
|
|||||||
preview->add_style_override("panel", stylebox);
|
preview->add_style_override("panel", stylebox);
|
||||||
stylebox->connect("changed", this, "_sb_changed");
|
stylebox->connect("changed", this, "_sb_changed");
|
||||||
}
|
}
|
||||||
|
_sb_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StyleBoxEditor::_sb_changed() {
|
void StyleBoxPreview::_sb_changed() {
|
||||||
|
|
||||||
preview->update();
|
preview->update();
|
||||||
|
if (stylebox.is_valid()) {
|
||||||
|
Size2 ms = stylebox->get_minimum_size() * 4 / 3;
|
||||||
|
ms.height = MAX(ms.height, 150 * EDSCALE);
|
||||||
|
preview->set_custom_minimum_size(ms);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StyleBoxEditor::_bind_methods() {
|
void StyleBoxPreview::_bind_methods() {
|
||||||
|
|
||||||
ClassDB::bind_method("_sb_changed", &StyleBoxEditor::_sb_changed);
|
ClassDB::bind_method("_sb_changed", &StyleBoxPreview::_sb_changed);
|
||||||
//ClassDB::bind_method("_import",&StyleBoxEditor::_import);
|
|
||||||
//ClassDB::bind_method("_import_accept",&StyleBoxEditor::_import_accept);
|
|
||||||
//ClassDB::bind_method("_preview_text_changed",&StyleBoxEditor::_preview_text_changed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StyleBoxEditor::StyleBoxEditor() {
|
StyleBoxPreview::StyleBoxPreview() {
|
||||||
|
|
||||||
panel = memnew(Panel);
|
|
||||||
add_child(panel);
|
|
||||||
panel->set_anchors_and_margins_preset(Control::PRESET_WIDE);
|
|
||||||
|
|
||||||
Label *l = memnew(Label);
|
|
||||||
l->set_text(TTR("StyleBox Preview:"));
|
|
||||||
l->set_position(Point2(5, 5));
|
|
||||||
panel->add_child(l);
|
|
||||||
|
|
||||||
preview = memnew(Panel);
|
preview = memnew(Panel);
|
||||||
panel->add_child(preview);
|
add_margin_child(TTR("Preview:"), preview);
|
||||||
preview->set_position(Point2(50, 50));
|
|
||||||
preview->set_size(Size2(200, 100));
|
|
||||||
}
|
|
||||||
|
|
||||||
void StyleBoxEditorPlugin::edit(Object *p_node) {
|
|
||||||
|
|
||||||
if (Object::cast_to<StyleBox>(p_node)) {
|
|
||||||
stylebox_editor->edit(Object::cast_to<StyleBox>(p_node));
|
|
||||||
stylebox_editor->show();
|
|
||||||
} else
|
|
||||||
stylebox_editor->hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool StyleBoxEditorPlugin::handles(Object *p_node) const {
|
|
||||||
|
|
||||||
return p_node->is_class("StyleBox");
|
|
||||||
}
|
|
||||||
|
|
||||||
void StyleBoxEditorPlugin::make_visible(bool p_visible) {
|
|
||||||
|
|
||||||
if (p_visible) {
|
|
||||||
button->show();
|
|
||||||
EditorNode::get_singleton()->make_bottom_panel_item_visible(stylebox_editor);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
if (stylebox_editor->is_visible_in_tree())
|
|
||||||
EditorNode::get_singleton()->hide_bottom_panel();
|
|
||||||
button->hide();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StyleBoxEditorPlugin::StyleBoxEditorPlugin(EditorNode *p_node) {
|
StyleBoxEditorPlugin::StyleBoxEditorPlugin(EditorNode *p_node) {
|
||||||
|
|
||||||
stylebox_editor = memnew(StyleBoxEditor);
|
Ref<EditorInspectorPluginStyleBox> inspector_plugin;
|
||||||
stylebox_editor->set_custom_minimum_size(Size2(0, 250));
|
inspector_plugin.instance();
|
||||||
|
add_inspector_plugin(inspector_plugin);
|
||||||
//p_node->get_viewport()->add_child(stylebox_editor);
|
|
||||||
button = p_node->add_bottom_panel_item(TTR("StyleBox"), stylebox_editor);
|
|
||||||
button->hide();
|
|
||||||
}
|
}
|
||||||
|
@ -31,18 +31,17 @@
|
|||||||
#ifndef STYLE_BOX_EDITOR_PLUGIN_H
|
#ifndef STYLE_BOX_EDITOR_PLUGIN_H
|
||||||
#define STYLE_BOX_EDITOR_PLUGIN_H
|
#define STYLE_BOX_EDITOR_PLUGIN_H
|
||||||
|
|
||||||
|
#include "editor/editor_inspector.h"
|
||||||
#include "editor/editor_node.h"
|
#include "editor/editor_node.h"
|
||||||
#include "scene/gui/option_button.h"
|
#include "scene/gui/option_button.h"
|
||||||
#include "scene/gui/texture_rect.h"
|
#include "scene/gui/texture_rect.h"
|
||||||
#include "scene/resources/style_box.h"
|
#include "scene/resources/style_box.h"
|
||||||
|
|
||||||
class StyleBoxEditor : public Control {
|
class StyleBoxPreview : public VBoxContainer {
|
||||||
|
|
||||||
GDCLASS(StyleBoxEditor, Control);
|
GDCLASS(StyleBoxPreview, VBoxContainer);
|
||||||
|
|
||||||
Panel *panel;
|
|
||||||
Panel *preview;
|
Panel *preview;
|
||||||
|
|
||||||
Ref<StyleBox> stylebox;
|
Ref<StyleBox> stylebox;
|
||||||
|
|
||||||
void _sb_changed();
|
void _sb_changed();
|
||||||
@ -53,23 +52,24 @@ protected:
|
|||||||
public:
|
public:
|
||||||
void edit(const Ref<StyleBox> &p_stylebox);
|
void edit(const Ref<StyleBox> &p_stylebox);
|
||||||
|
|
||||||
StyleBoxEditor();
|
StyleBoxPreview();
|
||||||
|
};
|
||||||
|
|
||||||
|
class EditorInspectorPluginStyleBox : public EditorInspectorPlugin {
|
||||||
|
GDCLASS(EditorInspectorPluginStyleBox, EditorInspectorPlugin)
|
||||||
|
public:
|
||||||
|
virtual bool can_handle(Object *p_object);
|
||||||
|
virtual void parse_begin(Object *p_object);
|
||||||
|
virtual bool parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage);
|
||||||
|
virtual void parse_end();
|
||||||
};
|
};
|
||||||
|
|
||||||
class StyleBoxEditorPlugin : public EditorPlugin {
|
class StyleBoxEditorPlugin : public EditorPlugin {
|
||||||
|
|
||||||
GDCLASS(StyleBoxEditorPlugin, EditorPlugin);
|
GDCLASS(StyleBoxEditorPlugin, EditorPlugin);
|
||||||
|
|
||||||
StyleBoxEditor *stylebox_editor;
|
|
||||||
EditorNode *editor;
|
|
||||||
Button *button;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual String get_name() const { return "StyleBox"; }
|
virtual String get_name() const { return "StyleBox"; }
|
||||||
bool has_main_screen() const { return false; }
|
|
||||||
virtual void edit(Object *p_node);
|
|
||||||
virtual bool handles(Object *p_node) const;
|
|
||||||
virtual void make_visible(bool p_visible);
|
|
||||||
|
|
||||||
StyleBoxEditorPlugin(EditorNode *p_node);
|
StyleBoxEditorPlugin(EditorNode *p_node);
|
||||||
};
|
};
|
||||||
|
@ -601,6 +601,17 @@ void TextureRegionEditor::apply_rect(const Rect2 &rect) {
|
|||||||
|
|
||||||
void TextureRegionEditor::_notification(int p_what) {
|
void TextureRegionEditor::_notification(int p_what) {
|
||||||
switch (p_what) {
|
switch (p_what) {
|
||||||
|
case NOTIFICATION_PROCESS: {
|
||||||
|
if (node_sprite) {
|
||||||
|
if (node_sprite->is_region()) {
|
||||||
|
|
||||||
|
set_process(false);
|
||||||
|
EditorNode::get_singleton()->make_bottom_panel_item_visible(this);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
set_process(false);
|
||||||
|
}
|
||||||
|
} break;
|
||||||
case NOTIFICATION_THEME_CHANGED:
|
case NOTIFICATION_THEME_CHANGED:
|
||||||
case NOTIFICATION_READY: {
|
case NOTIFICATION_READY: {
|
||||||
zoom_out->set_icon(get_icon("ZoomLess", "EditorIcons"));
|
zoom_out->set_icon(get_icon("ZoomLess", "EditorIcons"));
|
||||||
@ -640,6 +651,23 @@ void TextureRegionEditor::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("_zoom_out"), &TextureRegionEditor::_zoom_out);
|
ClassDB::bind_method(D_METHOD("_zoom_out"), &TextureRegionEditor::_zoom_out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TextureRegionEditor::is_stylebox() {
|
||||||
|
return obj_styleBox.is_valid();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TextureRegionEditor::is_atlas_texture() {
|
||||||
|
|
||||||
|
return atlas_tex.is_valid();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TextureRegionEditor::is_ninepatch() {
|
||||||
|
return node_ninepatch != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
Sprite *TextureRegionEditor::get_sprite() {
|
||||||
|
return node_sprite;
|
||||||
|
}
|
||||||
|
|
||||||
void TextureRegionEditor::edit(Object *p_obj) {
|
void TextureRegionEditor::edit(Object *p_obj) {
|
||||||
if (node_sprite)
|
if (node_sprite)
|
||||||
node_sprite->remove_change_receptor(this);
|
node_sprite->remove_change_receptor(this);
|
||||||
@ -670,6 +698,12 @@ void TextureRegionEditor::edit(Object *p_obj) {
|
|||||||
tile_set = Ref<TileSet>(NULL);
|
tile_set = Ref<TileSet>(NULL);
|
||||||
}
|
}
|
||||||
edit_draw->update();
|
edit_draw->update();
|
||||||
|
if (node_sprite && !node_sprite->is_region()) {
|
||||||
|
set_process(true);
|
||||||
|
}
|
||||||
|
if (!p_obj) {
|
||||||
|
set_process(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureRegionEditor::_changed_callback(Object *p_changed, const char *p_prop) {
|
void TextureRegionEditor::_changed_callback(Object *p_changed, const char *p_prop) {
|
||||||
@ -932,8 +966,12 @@ bool TextureRegionEditorPlugin::handles(Object *p_object) const {
|
|||||||
void TextureRegionEditorPlugin::make_visible(bool p_visible) {
|
void TextureRegionEditorPlugin::make_visible(bool p_visible) {
|
||||||
if (p_visible) {
|
if (p_visible) {
|
||||||
texture_region_button->show();
|
texture_region_button->show();
|
||||||
|
if (region_editor->is_stylebox() || region_editor->is_atlas_texture() || region_editor->is_ninepatch() || (region_editor->get_sprite() && region_editor->get_sprite()->is_region())) {
|
||||||
|
editor->make_bottom_panel_item_visible(region_editor);
|
||||||
|
} else {
|
||||||
if (texture_region_button->is_pressed())
|
if (texture_region_button->is_pressed())
|
||||||
region_editor->show();
|
region_editor->show();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
texture_region_button->hide();
|
texture_region_button->hide();
|
||||||
region_editor->edit(NULL);
|
region_editor->edit(NULL);
|
||||||
@ -992,7 +1030,7 @@ TextureRegionEditorPlugin::TextureRegionEditorPlugin(EditorNode *p_node) {
|
|||||||
texture_region_button = p_node->add_bottom_panel_item(TTR("TextureRegion"), region_editor);
|
texture_region_button = p_node->add_bottom_panel_item(TTR("TextureRegion"), region_editor);
|
||||||
texture_region_button->set_tooltip(TTR("Texture Region Editor"));
|
texture_region_button->set_tooltip(TTR("Texture Region Editor"));
|
||||||
|
|
||||||
region_editor->set_custom_minimum_size(Size2(0, 200));
|
region_editor->set_custom_minimum_size(Size2(0, 200) * EDSCALE);
|
||||||
region_editor->hide();
|
region_editor->hide();
|
||||||
texture_region_button->hide();
|
texture_region_button->hide();
|
||||||
}
|
}
|
||||||
|
@ -131,6 +131,10 @@ public:
|
|||||||
void _region_draw();
|
void _region_draw();
|
||||||
void _region_input(const Ref<InputEvent> &p_input);
|
void _region_input(const Ref<InputEvent> &p_input);
|
||||||
void _scroll_changed(float);
|
void _scroll_changed(float);
|
||||||
|
bool is_stylebox();
|
||||||
|
bool is_atlas_texture();
|
||||||
|
bool is_ninepatch();
|
||||||
|
Sprite *get_sprite();
|
||||||
|
|
||||||
void edit(Object *p_obj);
|
void edit(Object *p_obj);
|
||||||
TextureRegionEditor(EditorNode *p_editor);
|
TextureRegionEditor(EditorNode *p_editor);
|
||||||
|
@ -1936,6 +1936,12 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
|
|||||||
menu->add_icon_shortcut(get_icon("ScriptCreate", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/attach_script"), TOOL_ATTACH_SCRIPT);
|
menu->add_icon_shortcut(get_icon("ScriptCreate", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/attach_script"), TOOL_ATTACH_SCRIPT);
|
||||||
menu->add_icon_shortcut(get_icon("ScriptRemove", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/clear_script"), TOOL_CLEAR_SCRIPT);
|
menu->add_icon_shortcut(get_icon("ScriptRemove", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/clear_script"), TOOL_CLEAR_SCRIPT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (selection.size() > 1) {
|
||||||
|
//this is not a commonly used action, it makes no sense for it to be where it was nor always present.
|
||||||
|
menu->add_separator();
|
||||||
|
menu->add_icon_shortcut(get_icon("Rename", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/batch_rename"), TOOL_BATCH_RENAME);
|
||||||
|
}
|
||||||
menu->add_separator();
|
menu->add_separator();
|
||||||
menu->add_icon_shortcut(get_icon("Remove", "EditorIcons"), ED_SHORTCUT("scene_tree/delete", TTR("Delete Node(s)"), KEY_DELETE), TOOL_ERASE);
|
menu->add_icon_shortcut(get_icon("Remove", "EditorIcons"), ED_SHORTCUT("scene_tree/delete", TTR("Delete Node(s)"), KEY_DELETE), TOOL_ERASE);
|
||||||
menu->set_size(Size2(1, 1));
|
menu->set_size(Size2(1, 1));
|
||||||
|
@ -93,9 +93,10 @@ String WorldEnvironment::get_configuration_warning() const {
|
|||||||
return TTR("Only one WorldEnvironment is allowed per scene (or set of instanced scenes).");
|
return TTR("Only one WorldEnvironment is allowed per scene (or set of instanced scenes).");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (environment.is_valid() && get_viewport() && !get_viewport()->get_camera() && environment->get_background() != Environment::BG_CANVAS) {
|
// Commenting this warning for now, I think it makes no sense. If anyone can figure out what its supposed to do, feedback welcome. Else it should be deprecated.
|
||||||
return TTR("This WorldEnvironment is ignored. Either add a Camera (for 3D scenes) or set this environment's Background Mode to Canvas (for 2D scenes).");
|
//if (environment.is_valid() && get_viewport() && !get_viewport()->get_camera() && environment->get_background() != Environment::BG_CANVAS) {
|
||||||
}
|
// return TTR("This WorldEnvironment is ignored. Either add a Camera (for 3D scenes) or set this environment's Background Mode to Canvas (for 2D scenes).");
|
||||||
|
//}
|
||||||
|
|
||||||
return String();
|
return String();
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,8 @@ void Container::add_child_notify(Node *p_child) {
|
|||||||
control->connect("size_flags_changed", this, "queue_sort");
|
control->connect("size_flags_changed", this, "queue_sort");
|
||||||
control->connect("minimum_size_changed", this, "_child_minsize_changed");
|
control->connect("minimum_size_changed", this, "_child_minsize_changed");
|
||||||
control->connect("visibility_changed", this, "_child_minsize_changed");
|
control->connect("visibility_changed", this, "_child_minsize_changed");
|
||||||
|
|
||||||
|
minimum_size_changed();
|
||||||
queue_sort();
|
queue_sort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,6 +63,7 @@ void Container::move_child_notify(Node *p_child) {
|
|||||||
if (!Object::cast_to<Control>(p_child))
|
if (!Object::cast_to<Control>(p_child))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
minimum_size_changed();
|
||||||
queue_sort();
|
queue_sort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,6 +78,8 @@ void Container::remove_child_notify(Node *p_child) {
|
|||||||
control->disconnect("size_flags_changed", this, "queue_sort");
|
control->disconnect("size_flags_changed", this, "queue_sort");
|
||||||
control->disconnect("minimum_size_changed", this, "_child_minsize_changed");
|
control->disconnect("minimum_size_changed", this, "_child_minsize_changed");
|
||||||
control->disconnect("visibility_changed", this, "_child_minsize_changed");
|
control->disconnect("visibility_changed", this, "_child_minsize_changed");
|
||||||
|
|
||||||
|
minimum_size_changed();
|
||||||
queue_sort();
|
queue_sort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,6 +277,7 @@ void Control::_update_minimum_size() {
|
|||||||
data.updating_last_minimum_size = false;
|
data.updating_last_minimum_size = false;
|
||||||
|
|
||||||
if (minsize != data.last_minimum_size) {
|
if (minsize != data.last_minimum_size) {
|
||||||
|
data.last_minimum_size = minsize;
|
||||||
emit_signal(SceneStringNames::get_singleton()->minimum_size_changed);
|
emit_signal(SceneStringNames::get_singleton()->minimum_size_changed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -147,6 +147,7 @@ void GradientEdit::_gui_input(const Ref<InputEvent> &p_event) {
|
|||||||
grabbed = _get_point_from_pos(x);
|
grabbed = _get_point_from_pos(x);
|
||||||
//grab or select
|
//grab or select
|
||||||
if (grabbed != -1) {
|
if (grabbed != -1) {
|
||||||
|
grabbed = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -533,6 +533,7 @@ void PopupMenu::add_icon_item(const Ref<Texture> &p_icon, const String &p_label,
|
|||||||
item.ID = p_ID;
|
item.ID = p_ID;
|
||||||
items.push_back(item);
|
items.push_back(item);
|
||||||
update();
|
update();
|
||||||
|
minimum_size_changed();
|
||||||
}
|
}
|
||||||
void PopupMenu::add_item(const String &p_label, int p_ID, uint32_t p_accel) {
|
void PopupMenu::add_item(const String &p_label, int p_ID, uint32_t p_accel) {
|
||||||
|
|
||||||
@ -543,6 +544,7 @@ void PopupMenu::add_item(const String &p_label, int p_ID, uint32_t p_accel) {
|
|||||||
item.ID = p_ID;
|
item.ID = p_ID;
|
||||||
items.push_back(item);
|
items.push_back(item);
|
||||||
update();
|
update();
|
||||||
|
minimum_size_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupMenu::add_submenu_item(const String &p_label, const String &p_submenu, int p_ID) {
|
void PopupMenu::add_submenu_item(const String &p_label, const String &p_submenu, int p_ID) {
|
||||||
@ -554,6 +556,7 @@ void PopupMenu::add_submenu_item(const String &p_label, const String &p_submenu,
|
|||||||
item.submenu = p_submenu;
|
item.submenu = p_submenu;
|
||||||
items.push_back(item);
|
items.push_back(item);
|
||||||
update();
|
update();
|
||||||
|
minimum_size_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupMenu::add_icon_check_item(const Ref<Texture> &p_icon, const String &p_label, int p_ID, uint32_t p_accel) {
|
void PopupMenu::add_icon_check_item(const Ref<Texture> &p_icon, const String &p_label, int p_ID, uint32_t p_accel) {
|
||||||
@ -567,6 +570,7 @@ void PopupMenu::add_icon_check_item(const Ref<Texture> &p_icon, const String &p_
|
|||||||
item.checkable_type = Item::CHECKABLE_TYPE_CHECK_BOX;
|
item.checkable_type = Item::CHECKABLE_TYPE_CHECK_BOX;
|
||||||
items.push_back(item);
|
items.push_back(item);
|
||||||
update();
|
update();
|
||||||
|
minimum_size_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupMenu::add_check_item(const String &p_label, int p_ID, uint32_t p_accel) {
|
void PopupMenu::add_check_item(const String &p_label, int p_ID, uint32_t p_accel) {
|
||||||
@ -579,6 +583,7 @@ void PopupMenu::add_check_item(const String &p_label, int p_ID, uint32_t p_accel
|
|||||||
item.checkable_type = Item::CHECKABLE_TYPE_CHECK_BOX;
|
item.checkable_type = Item::CHECKABLE_TYPE_CHECK_BOX;
|
||||||
items.push_back(item);
|
items.push_back(item);
|
||||||
update();
|
update();
|
||||||
|
minimum_size_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupMenu::add_radio_check_item(const String &p_label, int p_ID, uint32_t p_accel) {
|
void PopupMenu::add_radio_check_item(const String &p_label, int p_ID, uint32_t p_accel) {
|
||||||
@ -586,6 +591,7 @@ void PopupMenu::add_radio_check_item(const String &p_label, int p_ID, uint32_t p
|
|||||||
add_check_item(p_label, p_ID, p_accel);
|
add_check_item(p_label, p_ID, p_accel);
|
||||||
items[items.size() - 1].checkable_type = Item::CHECKABLE_TYPE_RADIO_BUTTON;
|
items[items.size() - 1].checkable_type = Item::CHECKABLE_TYPE_RADIO_BUTTON;
|
||||||
update();
|
update();
|
||||||
|
minimum_size_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupMenu::add_icon_radio_check_item(const Ref<Texture> &p_icon, const String &p_label, int p_ID, uint32_t p_accel) {
|
void PopupMenu::add_icon_radio_check_item(const Ref<Texture> &p_icon, const String &p_label, int p_ID, uint32_t p_accel) {
|
||||||
@ -593,6 +599,7 @@ void PopupMenu::add_icon_radio_check_item(const Ref<Texture> &p_icon, const Stri
|
|||||||
add_icon_check_item(p_icon, p_label, p_ID, p_accel);
|
add_icon_check_item(p_icon, p_label, p_ID, p_accel);
|
||||||
items[items.size() - 1].checkable_type = Item::CHECKABLE_TYPE_RADIO_BUTTON;
|
items[items.size() - 1].checkable_type = Item::CHECKABLE_TYPE_RADIO_BUTTON;
|
||||||
update();
|
update();
|
||||||
|
minimum_size_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupMenu::add_icon_shortcut(const Ref<Texture> &p_icon, const Ref<ShortCut> &p_shortcut, int p_ID, bool p_global) {
|
void PopupMenu::add_icon_shortcut(const Ref<Texture> &p_icon, const Ref<ShortCut> &p_shortcut, int p_ID, bool p_global) {
|
||||||
@ -608,6 +615,7 @@ void PopupMenu::add_icon_shortcut(const Ref<Texture> &p_icon, const Ref<ShortCut
|
|||||||
item.shortcut_is_global = p_global;
|
item.shortcut_is_global = p_global;
|
||||||
items.push_back(item);
|
items.push_back(item);
|
||||||
update();
|
update();
|
||||||
|
minimum_size_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupMenu::add_shortcut(const Ref<ShortCut> &p_shortcut, int p_ID, bool p_global) {
|
void PopupMenu::add_shortcut(const Ref<ShortCut> &p_shortcut, int p_ID, bool p_global) {
|
||||||
@ -622,6 +630,7 @@ void PopupMenu::add_shortcut(const Ref<ShortCut> &p_shortcut, int p_ID, bool p_g
|
|||||||
item.shortcut_is_global = p_global;
|
item.shortcut_is_global = p_global;
|
||||||
items.push_back(item);
|
items.push_back(item);
|
||||||
update();
|
update();
|
||||||
|
minimum_size_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupMenu::add_icon_check_shortcut(const Ref<Texture> &p_icon, const Ref<ShortCut> &p_shortcut, int p_ID, bool p_global) {
|
void PopupMenu::add_icon_check_shortcut(const Ref<Texture> &p_icon, const Ref<ShortCut> &p_shortcut, int p_ID, bool p_global) {
|
||||||
@ -638,6 +647,7 @@ void PopupMenu::add_icon_check_shortcut(const Ref<Texture> &p_icon, const Ref<Sh
|
|||||||
item.shortcut_is_global = p_global;
|
item.shortcut_is_global = p_global;
|
||||||
items.push_back(item);
|
items.push_back(item);
|
||||||
update();
|
update();
|
||||||
|
minimum_size_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupMenu::add_check_shortcut(const Ref<ShortCut> &p_shortcut, int p_ID, bool p_global) {
|
void PopupMenu::add_check_shortcut(const Ref<ShortCut> &p_shortcut, int p_ID, bool p_global) {
|
||||||
@ -653,6 +663,7 @@ void PopupMenu::add_check_shortcut(const Ref<ShortCut> &p_shortcut, int p_ID, bo
|
|||||||
item.checkable_type = Item::CHECKABLE_TYPE_CHECK_BOX;
|
item.checkable_type = Item::CHECKABLE_TYPE_CHECK_BOX;
|
||||||
items.push_back(item);
|
items.push_back(item);
|
||||||
update();
|
update();
|
||||||
|
minimum_size_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupMenu::add_radio_check_shortcut(const Ref<ShortCut> &p_shortcut, int p_ID, bool p_global) {
|
void PopupMenu::add_radio_check_shortcut(const Ref<ShortCut> &p_shortcut, int p_ID, bool p_global) {
|
||||||
@ -660,6 +671,7 @@ void PopupMenu::add_radio_check_shortcut(const Ref<ShortCut> &p_shortcut, int p_
|
|||||||
add_check_shortcut(p_shortcut, p_ID, p_global);
|
add_check_shortcut(p_shortcut, p_ID, p_global);
|
||||||
items[items.size() - 1].checkable_type = Item::CHECKABLE_TYPE_RADIO_BUTTON;
|
items[items.size() - 1].checkable_type = Item::CHECKABLE_TYPE_RADIO_BUTTON;
|
||||||
update();
|
update();
|
||||||
|
minimum_size_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupMenu::add_multistate_item(const String &p_label, int p_max_states, int p_default_state, int p_ID, uint32_t p_accel) {
|
void PopupMenu::add_multistate_item(const String &p_label, int p_max_states, int p_default_state, int p_ID, uint32_t p_accel) {
|
||||||
@ -673,6 +685,7 @@ void PopupMenu::add_multistate_item(const String &p_label, int p_max_states, int
|
|||||||
item.state = p_default_state;
|
item.state = p_default_state;
|
||||||
items.push_back(item);
|
items.push_back(item);
|
||||||
update();
|
update();
|
||||||
|
minimum_size_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupMenu::set_item_text(int p_idx, const String &p_text) {
|
void PopupMenu::set_item_text(int p_idx, const String &p_text) {
|
||||||
@ -682,6 +695,7 @@ void PopupMenu::set_item_text(int p_idx, const String &p_text) {
|
|||||||
items[p_idx].xl_text = tr(p_text);
|
items[p_idx].xl_text = tr(p_text);
|
||||||
|
|
||||||
update();
|
update();
|
||||||
|
minimum_size_changed();
|
||||||
}
|
}
|
||||||
void PopupMenu::set_item_icon(int p_idx, const Ref<Texture> &p_icon) {
|
void PopupMenu::set_item_icon(int p_idx, const Ref<Texture> &p_icon) {
|
||||||
|
|
||||||
@ -689,6 +703,7 @@ void PopupMenu::set_item_icon(int p_idx, const Ref<Texture> &p_icon) {
|
|||||||
items[p_idx].icon = p_icon;
|
items[p_idx].icon = p_icon;
|
||||||
|
|
||||||
update();
|
update();
|
||||||
|
minimum_size_changed();
|
||||||
}
|
}
|
||||||
void PopupMenu::set_item_checked(int p_idx, bool p_checked) {
|
void PopupMenu::set_item_checked(int p_idx, bool p_checked) {
|
||||||
|
|
||||||
@ -697,6 +712,7 @@ void PopupMenu::set_item_checked(int p_idx, bool p_checked) {
|
|||||||
items[p_idx].checked = p_checked;
|
items[p_idx].checked = p_checked;
|
||||||
|
|
||||||
update();
|
update();
|
||||||
|
minimum_size_changed();
|
||||||
}
|
}
|
||||||
void PopupMenu::set_item_id(int p_idx, int p_ID) {
|
void PopupMenu::set_item_id(int p_idx, int p_ID) {
|
||||||
|
|
||||||
@ -704,6 +720,7 @@ void PopupMenu::set_item_id(int p_idx, int p_ID) {
|
|||||||
items[p_idx].ID = p_ID;
|
items[p_idx].ID = p_ID;
|
||||||
|
|
||||||
update();
|
update();
|
||||||
|
minimum_size_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupMenu::set_item_accelerator(int p_idx, uint32_t p_accel) {
|
void PopupMenu::set_item_accelerator(int p_idx, uint32_t p_accel) {
|
||||||
@ -712,6 +729,7 @@ void PopupMenu::set_item_accelerator(int p_idx, uint32_t p_accel) {
|
|||||||
items[p_idx].accel = p_accel;
|
items[p_idx].accel = p_accel;
|
||||||
|
|
||||||
update();
|
update();
|
||||||
|
minimum_size_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupMenu::set_item_metadata(int p_idx, const Variant &p_meta) {
|
void PopupMenu::set_item_metadata(int p_idx, const Variant &p_meta) {
|
||||||
@ -719,6 +737,7 @@ void PopupMenu::set_item_metadata(int p_idx, const Variant &p_meta) {
|
|||||||
ERR_FAIL_INDEX(p_idx, items.size());
|
ERR_FAIL_INDEX(p_idx, items.size());
|
||||||
items[p_idx].metadata = p_meta;
|
items[p_idx].metadata = p_meta;
|
||||||
update();
|
update();
|
||||||
|
minimum_size_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupMenu::set_item_disabled(int p_idx, bool p_disabled) {
|
void PopupMenu::set_item_disabled(int p_idx, bool p_disabled) {
|
||||||
@ -726,6 +745,7 @@ void PopupMenu::set_item_disabled(int p_idx, bool p_disabled) {
|
|||||||
ERR_FAIL_INDEX(p_idx, items.size());
|
ERR_FAIL_INDEX(p_idx, items.size());
|
||||||
items[p_idx].disabled = p_disabled;
|
items[p_idx].disabled = p_disabled;
|
||||||
update();
|
update();
|
||||||
|
minimum_size_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupMenu::set_item_submenu(int p_idx, const String &p_submenu) {
|
void PopupMenu::set_item_submenu(int p_idx, const String &p_submenu) {
|
||||||
@ -733,6 +753,7 @@ void PopupMenu::set_item_submenu(int p_idx, const String &p_submenu) {
|
|||||||
ERR_FAIL_INDEX(p_idx, items.size());
|
ERR_FAIL_INDEX(p_idx, items.size());
|
||||||
items[p_idx].submenu = p_submenu;
|
items[p_idx].submenu = p_submenu;
|
||||||
update();
|
update();
|
||||||
|
minimum_size_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupMenu::toggle_item_checked(int p_idx) {
|
void PopupMenu::toggle_item_checked(int p_idx) {
|
||||||
@ -740,6 +761,7 @@ void PopupMenu::toggle_item_checked(int p_idx) {
|
|||||||
ERR_FAIL_INDEX(p_idx, items.size());
|
ERR_FAIL_INDEX(p_idx, items.size());
|
||||||
items[p_idx].checked = !items[p_idx].checked;
|
items[p_idx].checked = !items[p_idx].checked;
|
||||||
update();
|
update();
|
||||||
|
minimum_size_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
String PopupMenu::get_item_text(int p_idx) const {
|
String PopupMenu::get_item_text(int p_idx) const {
|
||||||
@ -881,6 +903,7 @@ void PopupMenu::set_item_h_offset(int p_idx, int p_offset) {
|
|||||||
ERR_FAIL_INDEX(p_idx, items.size());
|
ERR_FAIL_INDEX(p_idx, items.size());
|
||||||
items[p_idx].h_ofs = p_offset;
|
items[p_idx].h_ofs = p_offset;
|
||||||
update();
|
update();
|
||||||
|
minimum_size_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupMenu::set_item_multistate(int p_idx, int p_state) {
|
void PopupMenu::set_item_multistate(int p_idx, int p_state) {
|
||||||
@ -1045,6 +1068,7 @@ void PopupMenu::clear() {
|
|||||||
items.clear();
|
items.clear();
|
||||||
mouse_over = -1;
|
mouse_over = -1;
|
||||||
update();
|
update();
|
||||||
|
minimum_size_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
Array PopupMenu::_get_items() const {
|
Array PopupMenu::_get_items() const {
|
||||||
|
@ -136,8 +136,17 @@ Ref<Texture> StyleBoxTexture::get_normal_map() const {
|
|||||||
|
|
||||||
void StyleBoxTexture::set_margin_size(Margin p_margin, float p_size) {
|
void StyleBoxTexture::set_margin_size(Margin p_margin, float p_size) {
|
||||||
|
|
||||||
|
ERR_FAIL_INDEX(p_margin, 4);
|
||||||
|
|
||||||
margin[p_margin] = p_size;
|
margin[p_margin] = p_size;
|
||||||
emit_changed();
|
emit_changed();
|
||||||
|
static const char *margin_prop[4] = {
|
||||||
|
"content_margin_left",
|
||||||
|
"content_margin_top",
|
||||||
|
"content_margin_right",
|
||||||
|
"content_margin_bottom",
|
||||||
|
};
|
||||||
|
_change_notify(margin_prop[p_margin]);
|
||||||
}
|
}
|
||||||
float StyleBoxTexture::get_margin_size(Margin p_margin) const {
|
float StyleBoxTexture::get_margin_size(Margin p_margin) const {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user