diff options
Diffstat (limited to 'scene')
-rw-r--r-- | scene/gui/control.cpp | 36 | ||||
-rw-r--r-- | scene/gui/control.h | 2 | ||||
-rw-r--r-- | scene/gui/item_list.h | 1 | ||||
-rw-r--r-- | scene/resources/dynamic_font.cpp | 4 |
4 files changed, 42 insertions, 1 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 2912dcb3ae..86ec31a9c2 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -652,8 +652,24 @@ bool Control::has_point(const Point2& p_point) const { return Rect2( Point2(), get_size() ).has_point(p_point); } +void Control::set_drag_forwarding(Control* p_target) { + + if (p_target) + data.drag_owner=p_target->get_instance_ID(); + else + data.drag_owner=0; +} + Variant Control::get_drag_data(const Point2& p_point) { + if (data.drag_owner) { + Object *obj = ObjectDB::get_instance(data.drag_owner); + if (obj) { + Control *c = obj->cast_to<Control>(); + return c->call("get_drag_data_fw",p_point,this); + } + } + if (get_script_instance()) { Variant v=p_point; const Variant *p=&v; @@ -669,6 +685,14 @@ Variant Control::get_drag_data(const Point2& p_point) { bool Control::can_drop_data(const Point2& p_point,const Variant& p_data) const { + if (data.drag_owner) { + Object *obj = ObjectDB::get_instance(data.drag_owner); + if (obj) { + Control *c = obj->cast_to<Control>(); + return c->call("can_drop_data_fw",p_point,p_data,this); + } + } + if (get_script_instance()) { Variant v=p_point; const Variant *p[2]={&v,&p_data}; @@ -683,6 +707,15 @@ bool Control::can_drop_data(const Point2& p_point,const Variant& p_data) const { } void Control::drop_data(const Point2& p_point,const Variant& p_data){ + if (data.drag_owner) { + Object *obj = ObjectDB::get_instance(data.drag_owner); + if (obj) { + Control *c = obj->cast_to<Control>(); + c->call("drop_data_fw",p_point,p_data,this); + return; + } + } + if (get_script_instance()) { Variant v=p_point; const Variant *p[2]={&v,&p_data}; @@ -711,7 +744,6 @@ void Control::set_drag_preview(Control *p_control) { - bool Control::is_window_modal_on_top() const { if (!is_inside_tree()) @@ -2273,6 +2305,7 @@ void Control::_bind_methods() { ObjectTypeDB::bind_method(_MD("grab_click_focus"),&Control::grab_click_focus); + ObjectTypeDB::bind_method(_MD("set_drag_forwarding;","target:Control"),&Control::set_drag_forwarding); ObjectTypeDB::bind_method(_MD("set_drag_preview","control:Control"),&Control::set_drag_preview); ObjectTypeDB::bind_method(_MD("warp_mouse","to_pos"),&Control::warp_mouse); @@ -2380,6 +2413,7 @@ Control::Control() { data.rotation=0; data.parent_canvas_item=NULL; data.scale=Vector2(1,1); + data.drag_owner=0; for (int i=0;i<4;i++) { diff --git a/scene/gui/control.h b/scene/gui/control.h index 1e2db7a575..aa9a7612a5 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -129,6 +129,7 @@ private: bool stop_mouse; Control *parent; + ObjectID drag_owner; bool modal; bool modal_exclusive; Ref<Theme> theme; @@ -229,6 +230,7 @@ public: virtual Size2 get_combined_minimum_size() const; virtual bool has_point(const Point2& p_point) const; virtual bool clips_input() const; + virtual void set_drag_forwarding(Control* p_target); virtual Variant get_drag_data(const Point2& p_point); virtual bool can_drop_data(const Point2& p_point,const Variant& p_data) const; virtual void drop_data(const Point2& p_point,const Variant& p_data); diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h index c9c575fd54..2c3f8a5a01 100644 --- a/scene/gui/item_list.h +++ b/scene/gui/item_list.h @@ -69,6 +69,7 @@ protected: static void _bind_methods(); public: + void add_item(const String& p_item,const Ref<Texture>& p_texture=Ref<Texture>(),bool p_selectable=true); void add_icon_item(const Ref<Texture>& p_item,bool p_selectable=true); diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp index b9fd67bc2f..19aa0e79cc 100644 --- a/scene/resources/dynamic_font.cpp +++ b/scene/resources/dynamic_font.cpp @@ -261,6 +261,8 @@ void DynamicFontAtSize::_update_char(CharType p_char) { if (tex_index==-1) { //could not find texture to fit, create one + tex_x = 0; + tex_y = 0; int texsize = MAX(size*8,256); if (mw>texsize) @@ -280,6 +282,7 @@ void DynamicFontAtSize::_update_char(CharType p_char) { { //zero texture DVector<uint8_t>::Write w = tex.imgdata.write(); + ERR_FAIL_COND(texsize*texsize*2 > tex.imgdata.size()); for(int i=0;i<texsize*texsize*2;i++) { w[i]=0; } @@ -305,6 +308,7 @@ void DynamicFontAtSize::_update_char(CharType p_char) { for(int j=0;j<w;j++) { int ofs = ( (i+tex_y+rect_margin)*tex.texture_size+j+tex_x+rect_margin)*2; + ERR_FAIL_COND(ofs >= tex.imgdata.size()); wr[ofs+0]=255; //grayscale as 1 wr[ofs+1]=cpbitmap[i*w+j]; //alpha as 0 } |