diff options
-rw-r--r-- | scene/gui/tree.cpp | 25 | ||||
-rw-r--r-- | scene/gui/tree.h | 5 | ||||
-rw-r--r-- | tools/editor/property_editor.cpp | 126 | ||||
-rw-r--r-- | tools/editor/property_editor.h | 8 |
4 files changed, 107 insertions, 57 deletions
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 66ce117c9d..e6f09ece94 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -1723,7 +1723,6 @@ int Tree::propagate_mouse_event(const Point2i &p_pos,int x_ofs,int y_ofs,bool p_ void Tree::text_editor_enter(String p_text) { - text_changed=false; text_editor->hide(); value_editor->hide(); @@ -1762,22 +1761,6 @@ void Tree::text_editor_enter(String p_text) { } -void Tree::text_editor_changed(String p_text) { - - text_changed=true; -} - -void Tree::text_editor_hide() { - - if (!text_changed) - return; - - if (Input::get_singleton()->is_key_pressed(KEY_ESCAPE)) - return; - - text_editor_enter(text_editor->get_text()); -} - void Tree::value_editor_changed(double p_value) { if (updating_value_editor) { @@ -2367,8 +2350,6 @@ bool Tree::edit_selected() { } else if (c.mode==TreeItem::CELL_MODE_STRING || c.mode==TreeItem::CELL_MODE_RANGE) { - text_changed=false; - Point2i textedpos=get_global_pos() + rect.pos; text_editor->set_pos( textedpos ); text_editor->set_size( rect.size); @@ -3204,8 +3185,6 @@ void Tree::_bind_methods() { ObjectTypeDB::bind_method(_MD("_input_event"),&Tree::_input_event); ObjectTypeDB::bind_method(_MD("_popup_select"),&Tree::popup_select); ObjectTypeDB::bind_method(_MD("_text_editor_enter"),&Tree::text_editor_enter); - ObjectTypeDB::bind_method(_MD("_text_editor_changed"),&Tree::text_editor_changed); - ObjectTypeDB::bind_method(_MD("_text_editor_hide"),&Tree::text_editor_hide); ObjectTypeDB::bind_method(_MD("_value_editor_changed"),&Tree::value_editor_changed); ObjectTypeDB::bind_method(_MD("_scroll_moved"),&Tree::_scroll_moved); @@ -3304,8 +3283,6 @@ Tree::Tree() { h_scroll->connect("value_changed", this,"_scroll_moved"); v_scroll->connect("value_changed", this,"_scroll_moved"); text_editor->connect("text_entered", this,"_text_editor_enter"); - text_editor->connect("text_changed",this,"_text_editor_changed"); - text_editor->connect("hide",this,"_text_editor_hide"); popup_menu->connect("item_pressed", this,"_popup_select"); value_editor->connect("value_changed", this,"_value_editor_changed"); @@ -3339,8 +3316,6 @@ Tree::Tree() { hide_folding=false; - text_changed=false; - } diff --git a/scene/gui/tree.h b/scene/gui/tree.h index 2562e6aaef..54e6a9c6b9 100644 --- a/scene/gui/tree.h +++ b/scene/gui/tree.h @@ -271,6 +271,7 @@ friend class TreeItem; bool range_drag_enabled; Vector2 range_drag_capture_pos; + //TreeItem *cursor_item; //int cursor_column; @@ -313,8 +314,6 @@ friend class TreeItem; void select_single_item(TreeItem *p_selected,TreeItem *p_current,int p_col,TreeItem *p_prev=NULL,bool *r_in_range=NULL); int propagate_mouse_event(const Point2i &p_pos,int x_ofs,int y_ofs,bool p_doubleclick,TreeItem *p_item,int p_button,const InputModifierState& p_mod); void text_editor_enter(String p_text); - void text_editor_changed(String p_text); - void text_editor_hide(); void value_editor_changed(double p_value); void popup_select(int p_option); @@ -419,8 +418,6 @@ friend class TreeItem; bool hide_folding; - bool text_changed; - protected: static void _bind_methods(); diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp index 16e4d4ec6c..286a8f25b1 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); diff --git a/tools/editor/property_editor.h b/tools/editor/property_editor.h index 2e533a0c64..5dc2f6d154 100644 --- a/tools/editor/property_editor.h +++ b/tools/editor/property_editor.h @@ -38,6 +38,8 @@ #include "scene/gui/menu_button.h" #include "scene/gui/texture_frame.h" #include "scene/gui/text_edit.h" +#include "scene/gui/check_button.h" +#include "scene/gui/split_container.h" #include "scene_tree_editor.h" /** @@ -83,6 +85,7 @@ class CustomPropertyEditor : public Popup { String hint_text; LineEdit *value_editor[MAX_VALUE_EDITORS]; Label *value_label[MAX_VALUE_EDITORS]; + HScrollBar *scroll[4]; Button *action_buttons[MAX_ACTION_BUTTONS]; MenuButton *type_button; Vector<String> inheritors_array; @@ -103,6 +106,7 @@ class CustomPropertyEditor : public Popup { void _text_edit_changed(); void _file_selected(String p_file); + void _scroll_modified(double p_value); void _modified(String p_string); void _range_modified(double p_value); void _focus_enter(); @@ -122,10 +126,6 @@ class CustomPropertyEditor : public Popup { void config_value_editors(int p_amount, int p_columns,int p_label_w,const List<String>& p_strings); void config_action_buttons(const List<String>& p_strings); - bool text_changed; - - void _text_editor_changed(String p_text); - protected: void _notification(int p_what); |