summaryrefslogtreecommitdiffstats
path: root/tools/editor/property_editor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/editor/property_editor.cpp')
-rw-r--r--tools/editor/property_editor.cpp202
1 files changed, 111 insertions, 91 deletions
diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp
index 16e4d4ec6c..4b1b93ea6e 100644
--- a/tools/editor/property_editor.cpp
+++ b/tools/editor/property_editor.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "property_editor.h"
+#include "scene/gui/label.h"
#include "io/resource_loader.h"
#include "io/image_loader.h"
#include "object_type_db.h"
@@ -34,6 +35,7 @@
#include "globals.h"
#include "scene/resources/font.h"
#include "pair.h"
+#include "scene/scene_string_names.h"
#include "editor_settings.h"
#include "editor_import_export.h"
#include "editor_node.h"
@@ -41,8 +43,6 @@
#include "array_property_edit.h"
#include "editor_help.h"
#include "scene/resources/packed_scene.h"
-#include "os/input.h"
-#include "os/keyboard.h"
void CustomPropertyEditor::_notification(int p_what) {
@@ -52,16 +52,11 @@ void CustomPropertyEditor::_notification(int p_what) {
RID ci = get_canvas_item();
get_stylebox("panel","PopupMenu")->draw(ci,Rect2(Point2(),get_size()));
+ /*
+ if (v.get_type()==Variant::COLOR) {
- } else if (p_what==NOTIFICATION_POPUP_HIDE) {
-
- if (!text_changed)
- return;
-
- if (Input::get_singleton()->is_key_pressed(KEY_ESCAPE))
- return;
-
- _modified(String());
+ VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2( 10,10,60, get_size().height-20 ), v );
+ }*/
}
}
@@ -240,8 +235,6 @@ String CustomPropertyEditor::get_name() const {
bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Type p_type, const Variant& p_variant,int p_hint,String p_hint_text) {
- text_changed=false;
-
owner=p_owner;
updating=true;
name=p_name;
@@ -261,6 +254,8 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
value_editor[i]->hide();
value_label[i]->hide();
+ if (i<4)
+ scroll[i]->hide();
}
for (int i=0;i<MAX_ACTION_BUTTONS;i++) {
@@ -596,10 +591,44 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
} break;
case Variant::COLOR: {
+
color_picker->show();
color_picker->set_edit_alpha(hint!=PROPERTY_HINT_COLOR_NO_ALPHA);
color_picker->set_color(v);
set_size( Size2(300, color_picker->get_combined_minimum_size().height+10));
+ /*
+ int ofs=80;
+ int m=10;
+ int h=20;
+ Color c=v;
+ float values[4]={c.r,c.g,c.b,c.a};
+ for (int i=0;i<4;i++) {
+ int y=m+i*h;
+
+ value_editor[i]->show();
+ value_label[i]->show();
+ value_label[i]->set_pos(Point2(ofs,y));
+ scroll[i]->set_min(0);
+ scroll[i]->set_max(1.0);
+ scroll[i]->set_page(0);
+ scroll[i]->set_pos(Point2(ofs+15,y+Math::floor((h-scroll[i]->get_minimum_size().height)/2.0)));
+ scroll[i]->set_val(values[i]);
+ scroll[i]->set_size(Size2(120,1));
+ scroll[i]->show();
+ value_editor[i]->set_pos(Point2(ofs+140,y));
+ value_editor[i]->set_size(Size2(40,h));
+ value_editor[i]->set_text( String::num(values[i],2 ));
+
+ }
+
+ value_label[0]->set_text("R");
+ value_label[1]->set_text("G");
+ value_label[2]->set_text("B");
+ value_label[3]->set_text("A");
+
+ Size2 new_size = value_editor[3]->get_pos() + value_editor[3]->get_size() + Point2(10,10);
+ set_size( new_size );
+ */
} break;
case Variant::IMAGE: {
@@ -1155,8 +1184,37 @@ void CustomPropertyEditor::_action_pressed(int p_which) {
} break;
default: {};
}
+
+}
+
+void CustomPropertyEditor::_scroll_modified(double p_value) {
+
+ if (updating)
+ return;
+ /*
+ switch(type) {
+
+ case Variant::COLOR: {
+
+ for (int i=0;i<4;i++) {
+
+ value_editor[i]->set_text( String::num(scroll[i]->get_val(),2) );
+ }
+ Color c;
+ c.r=scroll[0]->get_val();
+ c.g=scroll[1]->get_val();
+ c.b=scroll[2]->get_val();
+ c.a=scroll[3]->get_val();
+ v=c;
+ update();
+ emit_signal("variant_changed");
+ } break;
+ default: {}
+ }
+ */
}
+
void CustomPropertyEditor::_drag_easing(const InputEvent& p_ev) {
@@ -1251,7 +1309,6 @@ void CustomPropertyEditor::_modified(String p_string) {
if (updating)
return;
updating=true;
- text_changed=false;
switch(type) {
case Variant::REAL: {
@@ -1378,8 +1435,20 @@ void CustomPropertyEditor::_modified(String p_string) {
} break;
case Variant::COLOR: {
+ /*
+ for (int i=0;i<4;i++) {
-
+ scroll[i]->set_val( value_editor[i]->get_text().to_double() );
+ }
+ Color c;
+ c.r=value_editor[0]->get_text().to_double();
+ c.g=value_editor[1]->get_text().to_double();
+ c.b=value_editor[2]->get_text().to_double();
+ c.a=value_editor[3]->get_text().to_double();
+ v=c;
+ update();
+ emit_signal("variant_changed");
+ */
} break;
case Variant::IMAGE: {
@@ -1532,11 +1601,9 @@ void CustomPropertyEditor::config_value_editors(int p_amount, int p_columns,int
value_label[i]->hide();
}
}
-}
-void CustomPropertyEditor::_text_editor_changed(String p_text) {
- text_changed=true;
+
}
void CustomPropertyEditor::_bind_methods() {
@@ -1545,6 +1612,7 @@ void CustomPropertyEditor::_bind_methods() {
ObjectTypeDB::bind_method("_focus_exit", &CustomPropertyEditor::_focus_exit);
ObjectTypeDB::bind_method("_modified",&CustomPropertyEditor::_modified);
ObjectTypeDB::bind_method("_range_modified", &CustomPropertyEditor::_range_modified);
+ ObjectTypeDB::bind_method("_scroll_modified",&CustomPropertyEditor::_scroll_modified);
ObjectTypeDB::bind_method("_action_pressed",&CustomPropertyEditor::_action_pressed);
ObjectTypeDB::bind_method("_file_selected",&CustomPropertyEditor::_file_selected);
ObjectTypeDB::bind_method("_type_create_selected",&CustomPropertyEditor::_type_create_selected);
@@ -1552,9 +1620,9 @@ void CustomPropertyEditor::_bind_methods() {
ObjectTypeDB::bind_method("_color_changed",&CustomPropertyEditor::_color_changed);
ObjectTypeDB::bind_method("_draw_easing",&CustomPropertyEditor::_draw_easing);
ObjectTypeDB::bind_method("_drag_easing",&CustomPropertyEditor::_drag_easing);
- ObjectTypeDB::bind_method("_text_edit_changed",&CustomPropertyEditor::_text_edit_changed);
- ObjectTypeDB::bind_method("_menu_option",&CustomPropertyEditor::_menu_option);
- ObjectTypeDB::bind_method("_text_editor_changed",&CustomPropertyEditor::_text_editor_changed);
+ ObjectTypeDB::bind_method( "_text_edit_changed",&CustomPropertyEditor::_text_edit_changed);
+ ObjectTypeDB::bind_method( "_menu_option",&CustomPropertyEditor::_menu_option);
+
ADD_SIGNAL( MethodInfo("variant_changed") );
ADD_SIGNAL( MethodInfo("resource_edit_request") );
@@ -1565,8 +1633,6 @@ CustomPropertyEditor::CustomPropertyEditor() {
read_only=false;
updating=false;
- text_changed=false;
-
for (int i=0;i<MAX_VALUE_EDITORS;i++) {
value_editor[i]=memnew( LineEdit );
@@ -1576,11 +1642,22 @@ CustomPropertyEditor::CustomPropertyEditor() {
value_editor[i]->hide();
value_label[i]->hide();
value_editor[i]->connect("text_entered", this,"_modified");
- value_editor[i]->connect("text_changed", this, "_text_editor_changed");
value_editor[i]->connect("focus_enter", this, "_focus_enter");
value_editor[i]->connect("focus_exit", this, "_focus_exit");
}
+ for(int i=0;i<4;i++) {
+
+ scroll[i] = memnew( HScrollBar );
+ scroll[i]->hide();
+ scroll[i]->set_min(0);
+ scroll[i]->set_max(1.0);
+ scroll[i]->set_step(0.01);
+ add_child(scroll[i]);
+ scroll[i]->connect("value_changed", this,"_scroll_modified");
+
+ }
+
for(int i=0;i<20;i++) {
checks20[i]=memnew( Button );
checks20[i]->set_toggle_mode(true);
@@ -1652,6 +1729,7 @@ CustomPropertyEditor::CustomPropertyEditor() {
easing_draw->hide();
easing_draw->connect("draw",this,"_draw_easing");
easing_draw->connect("input_event",this,"_drag_easing");
+ //easing_draw->emit_signal(SceneStringNames::get_singleton()->input_event,InputEvent());
easing_draw->set_default_cursor_shape(Control::CURSOR_MOVE);
menu = memnew(PopupMenu);
@@ -1967,7 +2045,7 @@ void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String& p
if (img.empty())
p_item->set_text(1,"[Image (empty)]");
else
- p_item->set_text(1,"[Image "+itos(img.get_width())+"x"+itos(img.get_height())+"]");
+ p_item->set_text(1,"[Image "+itos(img.get_width())+"x"+itos(img.get_height())+"-"+String(Image::get_format_name(img.get_format()))+"]");
} break;
case Variant::NODE_PATH: {
@@ -2929,7 +3007,7 @@ void PropertyEditor::update_tree() {
if (img.empty())
item->set_text(1,"[Image (empty)]");
else
- item->set_text(1,"[Image "+itos(img.get_width())+"x"+itos(img.get_height())+"]");
+ item->set_text(1,"[Image "+itos(img.get_width())+"x"+itos(img.get_height())+"-"+String(Image::get_format_name(img.get_format()))+"]");
if (show_type_icons)
item->set_icon( 0,get_icon("Image","EditorIcons") );
@@ -3021,7 +3099,7 @@ void PropertyEditor::update_tree() {
int usage = d.has("usage")?int(int(d["usage"])&(PROPERTY_USAGE_STORE_IF_NONONE|PROPERTY_USAGE_STORE_IF_NONZERO)):0;
if (_get_instanced_node_original_property(p.name,vorig) || usage) {
Variant v = obj->get(p.name);
-
+
if (_is_property_different(v,vorig,usage)) {
//print_line("FOR "+String(p.name)+" RELOAD WITH: "+String(v)+"("+Variant::get_type_name(v.get_type())+")=="+String(vorig)+"("+Variant::get_type_name(vorig.get_type())+")");
@@ -3699,10 +3777,6 @@ class SectionedPropertyEditorFilter : public Object {
for (List<PropertyInfo>::Element *E=pinfo.front();E;E=E->next()) {
PropertyInfo pi=E->get();
-
- if (section=="")
- p_list->push_back(pi);
-
int sp = pi.name.find("/");
if (sp!=-1) {
String ss = pi.name.substr(0,sp);
@@ -3712,7 +3786,7 @@ class SectionedPropertyEditorFilter : public Object {
p_list->push_back(pi);
}
} else {
- if (section=="global")
+ if (section=="")
p_list->push_back(pi);
}
}
@@ -3737,18 +3811,10 @@ public:
};
-void SectionedPropertyEditor::_notification(int p_what) {
-
- if (p_what==NOTIFICATION_ENTER_TREE) {
-
- clear_button->set_icon(get_icon("Close", "EditorIcons"));
- }
-}
void SectionedPropertyEditor::_bind_methods() {
ObjectTypeDB::bind_method("_section_selected",&SectionedPropertyEditor::_section_selected);
- ObjectTypeDB::bind_method("_clear_search_box",&SectionedPropertyEditor::clear_search_box);
}
void SectionedPropertyEditor::_section_selected(int p_which) {
@@ -3756,30 +3822,9 @@ void SectionedPropertyEditor::_section_selected(int p_which) {
filter->set_section( sections->get_item_metadata(p_which) );
}
-void SectionedPropertyEditor::clear_search_box() {
-
- if (search_box->get_text().strip_edges()=="")
- return;
-
- search_box->clear();
- editor->update_tree();
-}
-
-
String SectionedPropertyEditor::get_current_section() const {
- String section = sections->get_item_metadata( sections->get_current() );
-
- if (section=="") {
- String name = editor->get_selected_path();
-
- int sp = name.find("/");
- if (sp!=-1)
- section = name.substr(0, sp);
-
- }
-
- return section;
+ return sections->get_item_metadata( sections->get_current() );
}
String SectionedPropertyEditor::get_full_item_path(const String& p_item) {
@@ -3799,20 +3844,11 @@ void SectionedPropertyEditor::edit(Object* p_object) {
sections->clear();
Set<String> existing_sections;
-
- existing_sections.insert("");
- sections->add_item("All");
- sections->set_item_metadata(0, "");
-
for (List<PropertyInfo>::Element *E=pinfo.front();E;E=E->next()) {
PropertyInfo pi=E->get();
-
if (pi.usage&PROPERTY_USAGE_CATEGORY)
continue;
- if ( !(pi.usage&PROPERTY_USAGE_EDITOR) )
- continue;
-
if (pi.name.find(":")!=-1 || pi.name=="script/script")
continue;
int sp = pi.name.find("/");
@@ -3825,10 +3861,10 @@ void SectionedPropertyEditor::edit(Object* p_object) {
}
} else {
- if (!existing_sections.has("global")) {
- existing_sections.insert("global");
+ if (!existing_sections.has("")) {
+ existing_sections.insert("");
sections->add_item("Global");
- sections->set_item_metadata(sections->get_item_count()-1,"global");
+ sections->set_item_metadata(sections->get_item_count()-1,"");
}
}
@@ -3853,8 +3889,6 @@ PropertyEditor *SectionedPropertyEditor::get_property_editor() {
SectionedPropertyEditor::SectionedPropertyEditor() {
- add_constant_override("separation", 8);
-
VBoxContainer *left_vb = memnew( VBoxContainer);
left_vb->set_custom_minimum_size(Size2(160,0));
add_child(left_vb);
@@ -3869,26 +3903,12 @@ SectionedPropertyEditor::SectionedPropertyEditor() {
add_child(right_vb);
filter = memnew( SectionedPropertyEditorFilter );
-
- HBoxContainer *hbc = memnew( HBoxContainer );
- right_vb->add_margin_child("Search:",hbc);
-
- search_box = memnew( LineEdit );
- search_box->set_h_size_flags(SIZE_EXPAND_FILL);
- hbc->add_child(search_box);
-
- clear_button = memnew( ToolButton );
- hbc->add_child(clear_button);
- clear_button->connect("pressed", this, "_clear_search_box");
-
editor = memnew( PropertyEditor );
- editor->register_text_enter(search_box);
- editor->set_use_filter(true);
editor->set_v_size_flags(SIZE_EXPAND_FILL);
right_vb->add_margin_child("Properties:",editor,true);
editor->get_scene_tree()->set_column_titles_visible(false);
- add_child(editor);
+
editor->hide_top_label();