diff options
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/color_picker.cpp | 125 | ||||
-rw-r--r-- | scene/gui/color_picker.h | 8 | ||||
-rw-r--r-- | scene/gui/control.cpp | 15 | ||||
-rw-r--r-- | scene/gui/control.h | 7 | ||||
-rw-r--r-- | scene/gui/graph_edit.cpp | 106 | ||||
-rw-r--r-- | scene/gui/graph_edit.h | 13 | ||||
-rw-r--r-- | scene/gui/graph_node.cpp | 1 | ||||
-rw-r--r-- | scene/gui/item_list.cpp | 29 | ||||
-rw-r--r-- | scene/gui/line_edit.cpp | 9 | ||||
-rw-r--r-- | scene/gui/tabs.cpp | 1 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 6 | ||||
-rw-r--r-- | scene/gui/tree.cpp | 30 | ||||
-rw-r--r-- | scene/gui/tree.h | 6 | ||||
-rw-r--r-- | scene/gui/video_player.cpp | 2 |
14 files changed, 265 insertions, 93 deletions
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index 8685ec1c99..f1b910d23f 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -34,7 +34,7 @@ #include "os/input.h" #include "os/keyboard.h" -void update_material(Ref<CanvasItemMaterial>mat,const Color& p_color) { +void update_material(Ref<CanvasItemMaterial>mat,const Color& p_color,float h,float s,float v) { if (!mat.is_valid()) return; Ref<Shader> sdr = mat->get_shader(); @@ -44,9 +44,9 @@ void update_material(Ref<CanvasItemMaterial>mat,const Color& p_color) { mat->set_shader_param("R",p_color.r); mat->set_shader_param("G",p_color.g); mat->set_shader_param("B",p_color.b); - mat->set_shader_param("H",p_color.get_h()); - mat->set_shader_param("S",p_color.get_s()); - mat->set_shader_param("V",p_color.get_v()); + mat->set_shader_param("H",h); + mat->set_shader_param("S",s); + mat->set_shader_param("V",v); mat->set_shader_param("A",p_color.a); } @@ -57,14 +57,25 @@ void ColorPicker::_notification(int p_what) { case NOTIFICATION_THEME_CHANGED: { uv_material->set_shader(get_shader("uv_editor")); w_material->set_shader(get_shader("w_editor")); - update_material(uv_material,color); - update_material(w_material,color); + update_material(uv_material,color,h,s,v); + update_material(w_material,color,h,s,v); _update_controls(); } break; case NOTIFICATION_ENTER_TREE: { btn_pick->set_icon(get_icon("screen_picker", "ColorPicker")); + update_material(uv_material, color,h,s,v); + update_material(w_material, color,h,s,v); + + uv_edit->get_child(0)->cast_to<Control>()->update(); + w_edit->get_child(0)->cast_to<Control>()->update(); + _update_color(); } + + case NOTIFICATION_VISIBILITY_CHANGED: { + c_text->call_deferred("grab_focus"); + c_text->call_deferred("select"); + } break; } } @@ -85,11 +96,19 @@ void ColorPicker::_update_controls() { void ColorPicker::set_color(const Color& p_color) { color=p_color; - h=color.get_h(); - s=color.get_s(); - v=color.get_v(); - update_material(uv_material, color); - update_material(w_material, color); + if (color != last_hsv) { + h=color.get_h(); + s=color.get_s(); + v=color.get_v(); + last_hsv = color; + } + + if (!is_inside_tree()) + return; + + update_material(uv_material, color,h,s,v); + update_material(w_material, color,h,s,v); + uv_edit->get_child(0)->cast_to<Control>()->update(); w_edit->get_child(0)->cast_to<Control>()->update(); _update_color(); @@ -100,6 +119,10 @@ void ColorPicker::set_edit_alpha(bool p_show) { edit_alpha=p_show; _update_controls(); + + if (!is_inside_tree()) + return; + _update_color(); sample->update(); } @@ -119,12 +142,9 @@ void ColorPicker::_value_changed(double) { } color.components[3] = scroll[3]->get_val()/255.0; - update_material(uv_material,color); - update_material(w_material,color); - - html->set_text(color.to_html(edit_alpha && color.a<1)); + set_color(color); - sample->update(); + c_text->set_text(color.to_html(edit_alpha && color.a<1)); emit_signal("color_changed",color); @@ -136,6 +156,10 @@ void ColorPicker::_html_entered(const String& p_html) { return; color = Color::html(p_html); + + if (!is_inside_tree()) + return; + _update_color(); emit_signal("color_changed",color); } @@ -153,7 +177,16 @@ void ColorPicker::_update_color() { scroll[i]->set_val(color.components[i]*255); } - html->set_text(color.to_html(edit_alpha && color.a<1)); + if (text_is_constructor) { + String t = "Color("+String::num(color.r)+","+String::num(color.g)+","+String::num(color.b); + if (edit_alpha && color.a<1) + t+=(","+String::num(color.a)+")") ; + else + t+=")"; + c_text->set_text(t); + } else { + c_text->set_text(color.to_html(edit_alpha && color.a<1)); + } sample->update(); updating=false; @@ -173,6 +206,21 @@ void ColorPicker::_update_presets() preset->set_texture(t); } +void ColorPicker::_text_type_toggled() +{ + if (!get_tree()->is_editor_hint()) + return; + text_is_constructor = !text_is_constructor; + if (text_is_constructor) { + text_type->set_text(""); + text_type->set_icon(get_icon("Script", "EditorIcons")); + } else { + text_type->set_text("#"); + text_type->set_icon(NULL); + } + _update_color(); +} + Color ColorPicker::get_color() const { return color; @@ -199,6 +247,9 @@ void ColorPicker::set_raw_mode(bool p_enabled) { if (btn_mode->is_pressed()!=p_enabled) btn_mode->set_pressed(p_enabled); + if (!is_inside_tree()) + return; + _update_controls(); _update_color(); } @@ -217,15 +268,17 @@ void ColorPicker::_hsv_draw(int p_wich,Control* c) if (!c) return; if (p_wich==0) { - int x=c->get_size().x*color.get_s(); - int y=c->get_size().y-c->get_size().y*color.get_v(); - c->draw_line(Point2(x,0),Point2(x,c->get_size().y),color.inverted()); - c->draw_line(Point2(0,y),Point2(c->get_size().x,y),color.inverted()); + int x=c->get_size().x*s; + int y=c->get_size().y-c->get_size().y*v; + Color col = color; + col.a=1; + c->draw_line(Point2(x,0),Point2(x,c->get_size().y),col.inverted()); + c->draw_line(Point2(0,y),Point2(c->get_size().x,y),col.inverted()); c->draw_line(Point2(x,y),Point2(x,y),Color(1,1,1),2); } else if (p_wich==1) { - int y=c->get_size().y-c->get_size().y*color.get_h(); + int y=c->get_size().y-c->get_size().y*h; Color col=Color(); - col.set_hsv(color.get_h(),1,1); + col.set_hsv(h,1,1); c->draw_line(Point2(0,y),Point2(c->get_size().x,y),col.inverted()); } } @@ -240,6 +293,7 @@ void ColorPicker::_uv_input(const InputEvent &ev) { s=x/256; v=1.0-y/256.0; color.set_hsv(h,s,v,color.a); + last_hsv = color; set_color(color); _update_color(); emit_signal("color_changed", color); @@ -255,6 +309,7 @@ void ColorPicker::_uv_input(const InputEvent &ev) { s=x/256; v=1.0-y/256.0; color.set_hsv(h,s,v,color.a); + last_hsv = color; set_color(color); _update_color(); emit_signal("color_changed", color); @@ -272,6 +327,7 @@ void ColorPicker::_w_input(const InputEvent &ev) { changing_color = false; } color.set_hsv(h,s,v,color.a); + last_hsv = color; set_color(color); _update_color(); emit_signal("color_changed", color); @@ -282,6 +338,7 @@ void ColorPicker::_w_input(const InputEvent &ev) { float y = CLAMP((float)bev.y,0,256); h=1.0-y/256.0; color.set_hsv(h,s,v,color.a); + last_hsv = color; set_color(color); _update_color(); emit_signal("color_changed", color); @@ -364,6 +421,7 @@ void ColorPicker::_bind_methods() { ObjectTypeDB::bind_method(_MD("add_preset"), &ColorPicker::add_preset); ObjectTypeDB::bind_method(_MD("_value_changed"),&ColorPicker::_value_changed); ObjectTypeDB::bind_method(_MD("_html_entered"),&ColorPicker::_html_entered); + ObjectTypeDB::bind_method(_MD("_text_type_toggled"),&ColorPicker::_text_type_toggled); ObjectTypeDB::bind_method(_MD("_add_preset_pressed"), &ColorPicker::_add_preset_pressed); ObjectTypeDB::bind_method(_MD("_screen_pick_pressed"), &ColorPicker::_screen_pick_pressed); ObjectTypeDB::bind_method(_MD("_sample_draw"),&ColorPicker::_sample_draw); @@ -381,6 +439,7 @@ ColorPicker::ColorPicker() : updating=true; edit_alpha=true; + text_is_constructor = false; raw_mode_enabled=false; changing_color=false; screen=NULL; @@ -490,18 +549,20 @@ ColorPicker::ColorPicker() : btn_mode->connect("toggled", this, "set_raw_mode"); hhb->add_child(btn_mode); vbr->add_child(hhb); - html_num = memnew( Label ); - hhb->add_child(html_num); + text_type = memnew( Button ); + text_type->set_flat(true); + text_type->connect("pressed", this, "_text_type_toggled"); + hhb->add_child(text_type); - html = memnew( LineEdit ); - hhb->add_child(html); - html->connect("text_entered",this,"_html_entered"); - html_num->set_text("#"); - html->set_h_size_flags(SIZE_EXPAND_FILL); + c_text = memnew( LineEdit ); + hhb->add_child(c_text); + c_text->connect("text_entered",this,"_html_entered"); + text_type->set_text("#"); + c_text->set_h_size_flags(SIZE_EXPAND_FILL); _update_controls(); - _update_color(); + //_update_color(); updating=false; uv_material.instance(); @@ -564,6 +625,8 @@ void ColorPickerButton::pressed() { popup->set_pos(get_global_pos()-Size2(0,ms.height)); popup->set_size(ms); popup->popup(); + + } void ColorPickerButton::_notification(int p_what) { diff --git a/scene/gui/color_picker.h b/scene/gui/color_picker.h index c6c7fe537d..4559bc7391 100644 --- a/scene/gui/color_picker.h +++ b/scene/gui/color_picker.h @@ -62,22 +62,25 @@ private: HSlider *scroll[4]; SpinBox *values[4]; Label *labels[4]; - Label *html_num; - LineEdit *html; + Button *text_type; + LineEdit *c_text; bool edit_alpha; Size2i ms; + bool text_is_constructor; Color color; bool raw_mode_enabled; bool updating; bool changing_color; float h,s,v; + Color last_hsv; void _html_entered(const String& p_html); void _value_changed(double); void _update_controls(); void _update_color(); void _update_presets(); + void _text_type_toggled(); void _sample_draw(); void _hsv_draw(int p_wich,Control *c); @@ -87,6 +90,7 @@ private: void _screen_input(const InputEvent& p_input); void _add_preset_pressed(); void _screen_pick_pressed(); + protected: void _notification(int); diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index dce0a4ac0e..af3b37bec2 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -85,9 +85,14 @@ Size2 Control::edit_get_minimum_size() const { void Control::edit_set_rect(const Rect2& p_edit_rect) { - Rect2 new_rect=get_rect(); + Matrix32 postxf; + postxf.set_rotation_and_scale(data.rotation,data.scale); + Vector2 new_pos = postxf.xform(p_edit_rect.pos); + + Vector2 pos = get_pos()+new_pos; - new_rect.pos+=p_edit_rect.pos.snapped(Vector2(1,1)); + Rect2 new_rect=get_rect(); + new_rect.pos=pos.snapped(Vector2(1,1)); new_rect.size=p_edit_rect.size.snapped(Vector2(1,1)); set_pos(new_rect.pos); @@ -1597,7 +1602,9 @@ bool Control::has_focus() const { void Control::grab_focus() { - ERR_FAIL_COND(!is_inside_tree()); + if (!is_inside_tree()){ + ERR_FAIL_COND(!is_inside_tree()); + } if (data.focus_mode==FOCUS_NONE) return; @@ -2071,6 +2078,8 @@ Control *Control::get_root_parent_control() const { return const_cast<Control*>(root); } + + void Control::_bind_methods() { diff --git a/scene/gui/control.h b/scene/gui/control.h index a16d88a6df..74d40b7579 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -97,7 +97,12 @@ private: struct CComparator { - bool operator()(const Control* p_a, const Control* p_b) const { return p_b->is_greater_than(p_a); } + bool operator()(const Control* p_a, const Control* p_b) const { + if (p_a->get_canvas_layer()==p_b->get_canvas_layer()) + return p_b->is_greater_than(p_a); + else + return p_a->get_canvas_layer() < p_b->get_canvas_layer(); + } }; struct Data { diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index 9472c589ca..c9c9dbd1d2 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -4,6 +4,12 @@ #include "scene/gui/box_container.h" +#define ZOOM_SCALE 1.2 + +#define MIN_ZOOM (((1/ZOOM_SCALE)/ZOOM_SCALE)/ZOOM_SCALE) +#define MAX_ZOOM (1*ZOOM_SCALE*ZOOM_SCALE*ZOOM_SCALE) + + bool GraphEditFilter::has_point(const Point2& p_point) const { return ge->_filter_input(p_point); @@ -85,9 +91,10 @@ void GraphEdit::_update_scroll_offset() { if (!gn) continue; - Point2 pos=gn->get_offset(); + Point2 pos=gn->get_offset()*zoom; pos-=Point2(h_scroll->get_val(),v_scroll->get_val()); gn->set_pos(pos); + gn->set_scale(Vector2(zoom,zoom)); } } @@ -106,8 +113,8 @@ void GraphEdit::_update_scroll() { continue; Rect2 r; - r.pos=gn->get_offset(); - r.size=gn->get_size(); + r.pos=gn->get_offset()*zoom; + r.size=gn->get_size()*zoom; screen = screen.merge(r); } @@ -193,10 +200,11 @@ void GraphEdit::_notification(int p_what) { h_scroll->set_anchor_and_margin(MARGIN_TOP,ANCHOR_END,hmin.height); h_scroll->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END,0); - zoom_icon->set_texture( get_icon("Zoom", "EditorIcons")); +// zoom_icon->set_texture( get_icon("Zoom", "EditorIcons")); } if (p_what==NOTIFICATION_DRAW) { + draw_style_box( get_stylebox("bg"),Rect2(Point2(),get_size()) ); VS::get_singleton()->canvas_item_set_clip(get_canvas_item(),true); } @@ -516,7 +524,7 @@ void GraphEdit::_input_event(const InputEvent& p_ev) { for(int i=get_child_count()-1;i>=0;i--) { GraphNode *gn=get_child(i)->cast_to<GraphNode>(); if (gn && gn->is_selected()) - gn->set_offset(gn->get_drag_from()+drag_accum); + gn->set_offset((gn->get_drag_from()*zoom+drag_accum)/zoom); } } @@ -650,6 +658,8 @@ void GraphEdit::_input_event(const InputEvent& p_ev) { } else { if (_filter_input(Vector2(b.x,b.y))) return; + if (Input::get_singleton()->is_key_pressed(KEY_SPACE)) + return; box_selecting = true; box_selecting_from = get_local_mouse_pos(); @@ -697,11 +707,13 @@ void GraphEdit::_input_event(const InputEvent& p_ev) { } if (b.button_index==BUTTON_WHEEL_UP && b.pressed) { - sl_zoom->set_val(zoom/0.9); + //too difficult to get right + //set_zoom(zoom*ZOOM_SCALE); } if (b.button_index==BUTTON_WHEEL_DOWN && b.pressed) { - sl_zoom->set_val(zoom*0.9); + //too difficult to get right + //set_zoom(zoom/ZOOM_SCALE); } } @@ -725,21 +737,29 @@ void GraphEdit::clear_connections() { void GraphEdit::set_zoom(float p_zoom) { - if (p_zoom<0.01) p_zoom=0.01; - if (p_zoom>4) p_zoom=4; + p_zoom=CLAMP(p_zoom,MIN_ZOOM,MAX_ZOOM); if (zoom == p_zoom) return; + zoom_minus->set_disabled(zoom==MIN_ZOOM); + zoom_plus->set_disabled(zoom==MAX_ZOOM); + + Vector2 sbofs = (Vector2( h_scroll->get_val(), v_scroll->get_val() ) + get_size()/2)/zoom; + float prev_zoom = zoom; zoom = p_zoom; - for (int i = 0; i < get_child_count(); i++) { - GraphNode *child = get_child(i)->cast_to<GraphNode>(); - if (!child) - continue; - Point2 ofs = child->get_offset() / prev_zoom * zoom; - child->set_scale(Vector2(zoom,zoom)); - child->set_offset(ofs); + top_layer->update(); + + _update_scroll(); + + if (is_visible()) { + + Vector2 ofs = sbofs*zoom - get_size()/2; + h_scroll->set_val( ofs.x ); + v_scroll->set_val( ofs.y ); } + + update(); } @@ -772,6 +792,26 @@ Array GraphEdit::_get_connection_list() const { } return arr; } + + + +void GraphEdit::_zoom_minus() { + + + set_zoom(zoom/ZOOM_SCALE); +} +void GraphEdit::_zoom_reset() { + + + set_zoom(1); +} + +void GraphEdit::_zoom_plus() { + + set_zoom(zoom*ZOOM_SCALE); +} + + void GraphEdit::_bind_methods() { ObjectTypeDB::bind_method(_MD("connect_node:Error","from","from_port","to","to_port"),&GraphEdit::connect_node); @@ -792,6 +832,9 @@ void GraphEdit::_bind_methods() { ObjectTypeDB::bind_method(_MD("_top_layer_input"),&GraphEdit::_top_layer_input); ObjectTypeDB::bind_method(_MD("_top_layer_draw"),&GraphEdit::_top_layer_draw); ObjectTypeDB::bind_method(_MD("_scroll_moved"),&GraphEdit::_scroll_moved); + ObjectTypeDB::bind_method(_MD("_zoom_minus"),&GraphEdit::_zoom_minus); + ObjectTypeDB::bind_method(_MD("_zoom_reset"),&GraphEdit::_zoom_reset); + ObjectTypeDB::bind_method(_MD("_zoom_plus"),&GraphEdit::_zoom_plus); ObjectTypeDB::bind_method(_MD("_input_event"),&GraphEdit::_input_event); @@ -837,18 +880,25 @@ GraphEdit::GraphEdit() { zoom = 1; - HBoxContainer* tools = memnew( HBoxContainer ); - add_child(tools); + HBoxContainer *zoom_hb = memnew( HBoxContainer ); + top_layer->add_child(zoom_hb); + zoom_hb->set_pos(Vector2(10,10)); + + + zoom_minus = memnew( ToolButton ); + zoom_hb->add_child(zoom_minus); + zoom_minus->connect("pressed",this,"_zoom_minus"); + zoom_minus->set_icon(get_icon("minus")); + + zoom_reset = memnew( ToolButton ); + zoom_hb->add_child(zoom_reset); + zoom_reset->connect("pressed",this,"_zoom_reset"); + zoom_reset->set_icon(get_icon("reset")); + + zoom_plus = memnew( ToolButton ); + zoom_hb->add_child(zoom_plus); + zoom_plus->connect("pressed",this,"_zoom_plus"); + zoom_plus->set_icon(get_icon("more")); - zoom_icon = memnew( TextureFrame ); - tools->add_child(zoom_icon); - sl_zoom = memnew( HSlider ); - sl_zoom->set_min(0.01); - sl_zoom->set_max(4); - sl_zoom->set_val(1); - sl_zoom->set_step(0.01); - sl_zoom->connect("value_changed", this, "set_zoom"); - tools->add_child(sl_zoom); - sl_zoom->set_custom_minimum_size(Size2(200,0)); } diff --git a/scene/gui/graph_edit.h b/scene/gui/graph_edit.h index fe9c36cee4..a189c10046 100644 --- a/scene/gui/graph_edit.h +++ b/scene/gui/graph_edit.h @@ -4,7 +4,9 @@ #include "scene/gui/graph_node.h" #include "scene/gui/scroll_bar.h" #include "scene/gui/slider.h" +#include "scene/gui/tool_button.h" #include "texture_frame.h" + class GraphEdit; class GraphEditFilter : public Control { @@ -35,8 +37,15 @@ public: }; private: - TextureFrame* zoom_icon; - HSlider* sl_zoom; + + ToolButton *zoom_minus; + ToolButton *zoom_reset; + ToolButton *zoom_plus; + + void _zoom_minus(); + void _zoom_reset(); + void _zoom_plus(); + HScrollBar* h_scroll; VScrollBar* v_scroll; diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp index 762afb158a..eef1bf79c4 100644 --- a/scene/gui/graph_node.cpp +++ b/scene/gui/graph_node.cpp @@ -591,4 +591,5 @@ void GraphNode::_bind_methods() { GraphNode::GraphNode() { show_close=false; connpos_dirty=true; + set_stop_mouse(false); } diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index f035cb7722..2d2cabfc01 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -826,22 +826,25 @@ void ItemList::_notification(int p_what) { if (current_columns==1) { rcache.size.width = width-rcache.pos.x; } - if (items[i].custom_bg.a>0.001) { - Rect2 r=rcache; - r.pos+=base_ofs; - draw_rect(r,items[i].custom_bg); - } - if (items[i].selected) { - Rect2 r=rcache; - r.pos+=base_ofs; - r.pos.x-=sbsel->get_margin(MARGIN_LEFT); - r.size.x+=sbsel->get_margin(MARGIN_LEFT)+sbsel->get_margin(MARGIN_RIGHT); - r.pos.y-=sbsel->get_margin(MARGIN_TOP); - r.size.y+=sbsel->get_margin(MARGIN_TOP)+sbsel->get_margin(MARGIN_BOTTOM); + Rect2 r=rcache; + r.pos+=base_ofs; - draw_style_box(sbsel,r); + // Use stylebox to dimension potential bg color, even if not selected + r.pos.x-=sbsel->get_margin(MARGIN_LEFT); + r.size.x+=sbsel->get_margin(MARGIN_LEFT)+sbsel->get_margin(MARGIN_RIGHT); + r.pos.y-=sbsel->get_margin(MARGIN_TOP); + r.size.y+=sbsel->get_margin(MARGIN_TOP)+sbsel->get_margin(MARGIN_BOTTOM); + if (items[i].selected) { + draw_style_box(sbsel,r); + } + if (items[i].custom_bg.a>0.001) { + r.pos.x+=2; + r.size.x-=4; + r.pos.y+=2; + r.size.y-=4; + draw_rect(r,items[i].custom_bg); } diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index fdced3f62f..2a62ab30fc 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -80,8 +80,8 @@ void LineEdit::_input_event(InputEvent p_event) { selection.creating=false; selection.doubleclick=false; - // notify to show soft keyboard - notification(NOTIFICATION_FOCUS_ENTER); + if (OS::get_singleton()->has_virtual_keyboard()) + OS::get_singleton()->show_virtual_keyboard(get_text(),get_global_rect()); } update(); @@ -230,8 +230,9 @@ void LineEdit::_input_event(InputEvent p_event) { case KEY_RETURN: { emit_signal( "text_entered",text ); - // notify to hide soft keyboard - notification(NOTIFICATION_FOCUS_EXIT); + if (OS::get_singleton()->has_virtual_keyboard()) + OS::get_singleton()->hide_virtual_keyboard(); + return; } break; diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp index ecce71bdbd..c3e75842c3 100644 --- a/scene/gui/tabs.cpp +++ b/scene/gui/tabs.cpp @@ -633,7 +633,6 @@ int Tabs::get_tab_width(int p_idx) const { x+=tab_bg->get_minimum_size().width; if (tabs[p_idx].right_button.is_valid()) { - print_line("has right"); Ref<Texture> rb=tabs[p_idx].right_button; Size2 bms = rb->get_size();//+get_stylebox("button")->get_minimum_size(); bms.width+=get_constant("hseparation"); diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 7f7c8c023c..bf012b7a03 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1197,6 +1197,12 @@ void TextEdit::_input_event(const InputEvent& p_input_event) { if (mb.button_index==BUTTON_WHEEL_DOWN) { v_scroll->set_val( v_scroll->get_val() +3 ); } + if (mb.button_index==BUTTON_WHEEL_LEFT) { + h_scroll->set_val( h_scroll->get_val() -3 ); + } + if (mb.button_index==BUTTON_WHEEL_RIGHT) { + h_scroll->set_val( h_scroll->get_val() +3 ); + } if (mb.button_index==BUTTON_LEFT) { int row,col; diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index e81c08dbea..05b1e8bcea 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -482,7 +482,7 @@ void TreeItem::deselect(int p_column) { _cell_deselected(p_column); } -void TreeItem::add_button(int p_column,const Ref<Texture>& p_button,int p_id) { +void TreeItem::add_button(int p_column, const Ref<Texture>& p_button, int p_id, bool p_disabled) { ERR_FAIL_INDEX( p_column, cells.size() ); @@ -492,6 +492,7 @@ void TreeItem::add_button(int p_column,const Ref<Texture>& p_button,int p_id) { if (p_id<0) p_id=cells[p_column].buttons.size(); button.id=p_id; + button.disabled=p_disabled; cells[p_column].buttons.push_back(button); _changed_notify(p_column); } @@ -533,6 +534,15 @@ int TreeItem::get_button_by_id(int p_column,int p_id) const { return -1; } + +bool TreeItem::is_button_disabled(int p_column, int p_idx) const { + + ERR_FAIL_INDEX_V( p_column, cells.size(), false ); + ERR_FAIL_INDEX_V( p_idx, cells[p_column].buttons.size(), false ); + + return cells[p_column].buttons[p_idx].disabled; + +} void TreeItem::set_button(int p_column,int p_idx,const Ref<Texture>& p_button){ ERR_FAIL_COND( p_button.is_null() ); @@ -672,10 +682,11 @@ void TreeItem::_bind_methods() { ObjectTypeDB::bind_method(_MD("clear_custom_bg_color","column"),&TreeItem::clear_custom_bg_color); ObjectTypeDB::bind_method(_MD("get_custom_bg_color","column"),&TreeItem::get_custom_bg_color); - ObjectTypeDB::bind_method(_MD("add_button","column","button:Texture","button_idx"),&TreeItem::add_button); + ObjectTypeDB::bind_method(_MD("add_button","column","button:Texture","button_idx","disabled"),&TreeItem::add_button,DEFVAL(-1),DEFVAL(false)); ObjectTypeDB::bind_method(_MD("get_button_count","column"),&TreeItem::get_button_count); ObjectTypeDB::bind_method(_MD("get_button:Texture","column","button_idx"),&TreeItem::get_button); ObjectTypeDB::bind_method(_MD("erase_button","column","button_idx"),&TreeItem::erase_button); + ObjectTypeDB::bind_method(_MD("is_button_disabled","column","button_idx"),&TreeItem::is_button_disabled); ObjectTypeDB::bind_method(_MD("set_tooltip","column","tooltip"),&TreeItem::set_tooltip); ObjectTypeDB::bind_method(_MD("get_tooltip","column"),&TreeItem::get_tooltip); @@ -1015,14 +1026,15 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2& Point2i o = Point2i( ofs+w-s.width, p_pos.y )-cache.offset+p_draw_ofs; - if (cache.click_type==Cache::CLICK_BUTTON && cache.click_item==p_item && cache.click_column==i) { + if (cache.click_type==Cache::CLICK_BUTTON && cache.click_item==p_item && cache.click_column==i && !p_item->cells[i].buttons[j].disabled) { //being pressed cache.button_pressed->draw(get_canvas_item(),Rect2(o,s)); } o.y+=(label_h-s.height)/2; o+=cache.button_pressed->get_offset(); - b->draw(ci,o); + + b->draw(ci,o,p_item->cells[i].buttons[j].disabled?Color(1,1,1,0.5):Color(1,1,1,1)); w-=s.width+cache.button_margin; bw+=s.width+cache.button_margin; } @@ -1472,7 +1484,13 @@ int Tree::propagate_mouse_event(const Point2i &p_pos,int x_ofs,int y_ofs,bool p_ for(int j=c.buttons.size()-1;j>=0;j--) { Ref<Texture> b=c.buttons[j].texture; int w = b->get_size().width + cache.button_pressed->get_minimum_size().width; + if (x>col_width-w) { + if (c.buttons[j].disabled) { + pressed_button=-1; + cache.click_type=Cache::CLICK_NONE; + return -1; + } pressed_button=j; cache.click_type=Cache::CLICK_BUTTON; cache.click_index=j; @@ -1730,6 +1748,8 @@ void Tree::_text_editor_modal_close() { return; } + if (value_editor->has_point(value_editor->get_local_mouse_pos())) + return; text_editor_enter(text_editor->get_text()); } @@ -2316,7 +2336,7 @@ bool Tree::edit_selected() { return false; Rect2 rect; - rect.pos.y = get_item_offset(s) - v_scroll->get_val(); + rect.pos.y = get_item_offset(s) - get_scroll().y; for(int i=0;i<col;i++) { diff --git a/scene/gui/tree.h b/scene/gui/tree.h index e4d349978c..e5c95b4d66 100644 --- a/scene/gui/tree.h +++ b/scene/gui/tree.h @@ -86,8 +86,9 @@ friend class Tree; struct Button { int id; + bool disabled; Ref<Texture> texture; - Button() { id=0; } + Button() { id=0; disabled=false; } }; Vector< Button > buttons; @@ -172,12 +173,13 @@ public: void set_icon_max_width(int p_column,int p_max); int get_icon_max_width(int p_column) const; - void add_button(int p_column,const Ref<Texture>& p_button,int p_id=-1); + void add_button(int p_column,const Ref<Texture>& p_button,int p_id=-1,bool p_disabled=false); int get_button_count(int p_column) const; Ref<Texture> get_button(int p_column,int p_idx) const; int get_button_id(int p_column,int p_idx) const; void erase_button(int p_column,int p_idx); int get_button_by_id(int p_column,int p_id) const; + bool is_button_disabled(int p_column,int p_idx) const; void set_button(int p_column,int p_idx,const Ref<Texture>& p_button); /* range works for mode number or mode combo */ diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp index 517cd414c5..fc7cc0a362 100644 --- a/scene/gui/video_player.cpp +++ b/scene/gui/video_player.cpp @@ -393,7 +393,7 @@ void VideoPlayer::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_buffering_msec","msec"),&VideoPlayer::set_buffering_msec); ObjectTypeDB::bind_method(_MD("get_buffering_msec"),&VideoPlayer::get_buffering_msec); - ObjectTypeDB::bind_method(_MD("get_video_texutre:Texture"), &VideoPlayer::get_video_texture ); + ObjectTypeDB::bind_method(_MD("get_video_texture:Texture"), &VideoPlayer::get_video_texture ); ADD_PROPERTY( PropertyInfo(Variant::INT, "stream/audio_track",PROPERTY_HINT_RANGE,"0,128,1"), _SCS("set_audio_track"), _SCS("get_audio_track") ); ADD_PROPERTY( PropertyInfo(Variant::OBJECT, "stream/stream", PROPERTY_HINT_RESOURCE_TYPE,"VideoStream"), _SCS("set_stream"), _SCS("get_stream") ); |