diff options
author | Juan Linietsky <reduzio@gmail.com> | 2017-01-09 15:50:08 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2017-01-09 15:50:59 -0300 |
commit | e9bb65db815b593037a573c1c7a78e95b7550cb0 (patch) | |
tree | 3ccb0b04272cf36701028a1f662c39cc1bd9bdc1 /scene/gui | |
parent | 0e635b683b84417b0970218ce720bbc553205ca6 (diff) |
-All types have editable script now in properties
-Changed clip to a property in Control which can be set by the user
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/control.cpp | 20 | ||||
-rw-r--r-- | scene/gui/control.h | 4 | ||||
-rw-r--r-- | scene/gui/graph_edit.cpp | 3 | ||||
-rw-r--r-- | scene/gui/item_list.cpp | 2 | ||||
-rw-r--r-- | scene/gui/label.cpp | 3 | ||||
-rw-r--r-- | scene/gui/rich_text_label.cpp | 3 | ||||
-rw-r--r-- | scene/gui/scroll_container.cpp | 26 | ||||
-rw-r--r-- | scene/gui/scroll_container.h | 3 | ||||
-rw-r--r-- | scene/gui/tree.cpp | 4 |
9 files changed, 55 insertions, 13 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 7507ab0952..a4b07d9a13 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -532,7 +532,7 @@ void Control::_notification(int p_notification) { _update_canvas_item_transform(); VisualServer::get_singleton()->canvas_item_set_custom_rect( get_canvas_item(),!data.disable_visibility_clip, Rect2(Point2(),get_size())); - + VisualServer::get_singleton()->canvas_item_set_clip( get_canvas_item(), data.clip_contents ); //emit_signal(SceneStringNames::get_singleton()->draw); } break; @@ -2340,6 +2340,16 @@ void Control::get_argument_options(const StringName& p_function,int p_idx,List<S } +void Control::set_clip_contents(bool p_clip) { + + data.clip_contents=p_clip; + update(); +} + +bool Control::is_clipping_contents() { + + return data.clip_contents; +} void Control::_bind_methods() { @@ -2444,9 +2454,12 @@ void Control::_bind_methods() { ClassDB::bind_method(_MD("force_drag","data","preview"),&Control::force_drag); - ClassDB::bind_method(_MD("set_mouse_filter","stop"),&Control::set_mouse_filter); + ClassDB::bind_method(_MD("set_mouse_filter","filter"),&Control::set_mouse_filter); ClassDB::bind_method(_MD("get_mouse_filter"),&Control::get_mouse_filter); + ClassDB::bind_method(_MD("set_clip_contents","enable"),&Control::set_clip_contents); + ClassDB::bind_method(_MD("is_clipping_contents"),&Control::is_clipping_contents); + ClassDB::bind_method(_MD("grab_click_focus"),&Control::grab_click_focus); ClassDB::bind_method(_MD("set_drag_forwarding","target:Control"),&Control::set_drag_forwarding); @@ -2486,6 +2499,7 @@ void Control::_bind_methods() { ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"rect_min_size"), _SCS("set_custom_minimum_size"),_SCS("get_custom_minimum_size") ); ADD_PROPERTYNZ( PropertyInfo(Variant::REAL,"rect_rotation",PROPERTY_HINT_RANGE,"-1080,1080,0.01"), _SCS("set_rotation_deg"),_SCS("get_rotation_deg") ); ADD_PROPERTYNO( PropertyInfo(Variant::VECTOR2,"rect_scale"), _SCS("set_scale"),_SCS("get_scale") ); + ADD_PROPERTYNO( PropertyInfo(Variant::BOOL,"rect_clip_content"), _SCS("set_clip_contents"),_SCS("is_clipping_contents") ); ADD_GROUP("Hint","hint_"); @@ -2587,7 +2601,7 @@ Control::Control() { data.block_minimum_size_adjust=false; data.disable_visibility_clip=false; - + data.clip_contents=false; for (int i=0;i<4;i++) { data.anchor[i]=ANCHOR_BEGIN; data.margin[i]=0; diff --git a/scene/gui/control.h b/scene/gui/control.h index b67e5980c5..709f19f3f2 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -132,6 +132,8 @@ private: MouseFilter mouse_filter; + bool clip_contents; + bool block_minimum_size_adjust; bool disable_visibility_clip; @@ -401,6 +403,8 @@ public: Control *get_root_parent_control() const; + void set_clip_contents(bool p_clip); + bool is_clipping_contents(); void set_block_minimum_size_adjust(bool p_block); bool is_minimum_size_adjust_blocked() const; diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index d3f2ad7e13..4d72bbbd0d 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -302,7 +302,6 @@ void GraphEdit::_notification(int p_what) { draw_style_box( get_stylebox("bg"),Rect2(Point2(),get_size()) ); - VS::get_singleton()->canvas_item_set_clip(get_canvas_item(),true); if (is_using_snap()) { //draw grid @@ -1337,7 +1336,7 @@ GraphEdit::GraphEdit() { setting_scroll_ofs=false; just_disconected=false; - + set_clip_contents(true); } diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index 5a9b1173da..ece6171b6e 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -788,7 +788,6 @@ void ItemList::_notification(int p_what) { if (p_what==NOTIFICATION_DRAW) { - VS::get_singleton()->canvas_item_set_clip(get_canvas_item(),true); Ref<StyleBox> bg = get_stylebox("bg"); int mw = scroll_bar->get_minimum_size().x; @@ -1402,6 +1401,7 @@ ItemList::ItemList() { allow_rmb_select=false; icon_scale = 1.0f; + set_clip_contents(true); } ItemList::~ItemList() { diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index 3d350b2230..dda9e4b128 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -70,8 +70,9 @@ void Label::_notification(int p_what) { if (p_what==NOTIFICATION_DRAW) { - if (clip || autowrap) + if (clip || autowrap) { VisualServer::get_singleton()->canvas_item_set_clip(get_canvas_item(),true); + } if (word_cache_dirty) regenerate_word_cache(); diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 2e68b19f78..790b7500ea 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -687,8 +687,6 @@ void RichTextLabel::_notification(int p_what) { RID ci=get_canvas_item(); Size2 size = get_size(); - VisualServer::get_singleton()->canvas_item_set_clip(ci,true); - if (has_focus()) { VisualServer::get_singleton()->canvas_item_add_clip_ignore(ci,true); draw_style_box(get_stylebox("focus"),Rect2(Point2(),size)); @@ -2046,6 +2044,7 @@ RichTextLabel::RichTextLabel() { visible_characters=-1; + set_clip_contents(true); } RichTextLabel::~RichTextLabel() { diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp index 966bad7604..43c214b0be 100644 --- a/scene/gui/scroll_container.cpp +++ b/scene/gui/scroll_container.cpp @@ -261,7 +261,6 @@ void ScrollContainer::_notification(int p_what) { update_scrollbars(); - VisualServer::get_singleton()->canvas_item_set_clip(get_canvas_item(),true); } if (p_what==NOTIFICATION_FIXED_PROCESS) { @@ -434,6 +433,29 @@ void ScrollContainer::set_h_scroll(int p_pos) { } +String ScrollContainer::get_configuration_warning() const { + + int found=0; + + for(int i=0;i<get_child_count();i++) { + + Control *c = get_child(i)->cast_to<Control>(); + if (!c) + continue; + if (c->is_set_as_toplevel()) + continue; + if (c == h_scroll || c == v_scroll) + continue; + + found++; + } + + if (found!=1) + return TTR("ScrollContainer is intended to work with a single child control.\nUse a container as child (VBox,HBox,etc), or a Control and set the custom minimum size manually."); + else + return ""; +} + void ScrollContainer::_bind_methods() { @@ -474,6 +496,6 @@ ScrollContainer::ScrollContainer() { scroll_h=true; scroll_v=true; - + set_clip_contents(true); }; diff --git a/scene/gui/scroll_container.h b/scene/gui/scroll_container.h index 69d842a662..114cd06306 100644 --- a/scene/gui/scroll_container.h +++ b/scene/gui/scroll_container.h @@ -86,6 +86,9 @@ public: bool is_v_scroll_enabled() const; virtual bool clips_input() const; + + virtual String get_configuration_warning() const; + ScrollContainer(); }; diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 16175e9f4b..f4f1fd8b9c 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -2760,8 +2760,6 @@ void Tree::_notification(int p_what) { update_scrollbars(); RID ci = get_canvas_item(); - VisualServer::get_singleton()->canvas_item_set_clip(ci,true); - Ref<StyleBox> bg = cache.bg; Ref<StyleBox> bg_focus = get_stylebox("bg_focus"); @@ -3730,6 +3728,8 @@ Tree::Tree() { force_select_on_already_selected=false; allow_rmb_select=false; + + set_clip_contents(true); } |