summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/control.cpp20
-rw-r--r--scene/gui/control.h4
-rw-r--r--scene/gui/graph_edit.cpp3
-rw-r--r--scene/gui/item_list.cpp2
-rw-r--r--scene/gui/label.cpp3
-rw-r--r--scene/gui/rich_text_label.cpp3
-rw-r--r--scene/gui/scroll_container.cpp26
-rw-r--r--scene/gui/scroll_container.h3
-rw-r--r--scene/gui/tree.cpp4
-rw-r--r--scene/main/node.h1
10 files changed, 55 insertions, 14 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);
}
diff --git a/scene/main/node.h b/scene/main/node.h
index 5c8cde5192..117ce64645 100644
--- a/scene/main/node.h
+++ b/scene/main/node.h
@@ -146,7 +146,6 @@ private:
void _print_tree(const Node *p_node);
- virtual bool _use_builtin_script() const { return true; }
Node *_get_node(const NodePath& p_path) const;
Node *_get_child_by_name(const StringName& p_name) const;