diff options
Diffstat (limited to 'scene/gui')
50 files changed, 408 insertions, 350 deletions
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp index 45c491cd74..0b40983ddf 100644 --- a/scene/gui/base_button.cpp +++ b/scene/gui/base_button.cpp @@ -64,7 +64,7 @@ void BaseButton::_gui_input(InputEvent p_event) { if (status.pressing_button) break; - if (status.click_on_press) { + if (action_mode==ACTION_MODE_BUTTON_PRESS) { if (b.pressed) { @@ -108,7 +108,7 @@ void BaseButton::_gui_input(InputEvent p_event) { emit_signal("button_up"); /* this is pointless if (status.press_attempt && status.pressing_inside) { -// released(); + //released(); emit_signal("released"); } */ @@ -297,7 +297,7 @@ void BaseButton::_notification(int p_what) { } - if (p_what==NOTIFICATION_VISIBILITY_CHANGED && !is_visible()) { + if (p_what==NOTIFICATION_VISIBILITY_CHANGED && !is_visible_in_tree()) { if (!toggle_mode) { status.pressed = false; @@ -415,14 +415,14 @@ bool BaseButton::is_toggle_mode() const { return toggle_mode; } -void BaseButton::set_click_on_press(bool p_click_on_press) { +void BaseButton::set_action_mode(ActionMode p_mode) { - status.click_on_press=p_click_on_press; + action_mode=p_mode; } -bool BaseButton::get_click_on_press() const { +BaseButton::ActionMode BaseButton::get_action_mode() const { - return status.click_on_press; + return action_mode; } void BaseButton::set_enabled_focus_mode(FocusMode p_mode) { @@ -453,7 +453,7 @@ Ref<ShortCut> BaseButton:: get_shortcut() const { void BaseButton::_unhandled_input(InputEvent p_event) { - if (!is_disabled() && is_visible() && p_event.is_pressed() && !p_event.is_echo() && shortcut.is_valid() && shortcut->is_shortcut(p_event)) { + if (!is_disabled() && is_visible_in_tree() && p_event.is_pressed() && !p_event.is_echo() && shortcut.is_valid() && shortcut->is_shortcut(p_event)) { if (get_viewport()->get_modal_stack_top() && !get_viewport()->get_modal_stack_top()->is_a_parent_of(this)) return; //ignore because of modal window @@ -514,8 +514,8 @@ void BaseButton::_bind_methods() { ClassDB::bind_method(_MD("is_toggle_mode"),&BaseButton::is_toggle_mode); ClassDB::bind_method(_MD("set_disabled","disabled"),&BaseButton::set_disabled); ClassDB::bind_method(_MD("is_disabled"),&BaseButton::is_disabled); - ClassDB::bind_method(_MD("set_click_on_press","enable"),&BaseButton::set_click_on_press); - ClassDB::bind_method(_MD("get_click_on_press"),&BaseButton::get_click_on_press); + ClassDB::bind_method(_MD("set_action_mode","mode"),&BaseButton::set_action_mode); + ClassDB::bind_method(_MD("get_action_mode"),&BaseButton::get_action_mode); ClassDB::bind_method(_MD("get_draw_mode"),&BaseButton::get_draw_mode); ClassDB::bind_method(_MD("set_enabled_focus_mode","mode"),&BaseButton::set_enabled_focus_mode); ClassDB::bind_method(_MD("get_enabled_focus_mode"),&BaseButton::get_enabled_focus_mode); @@ -536,7 +536,7 @@ void BaseButton::_bind_methods() { ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "disabled"), _SCS("set_disabled"), _SCS("is_disabled")); ADD_PROPERTY( PropertyInfo( Variant::BOOL, "toggle_mode"), _SCS("set_toggle_mode"), _SCS("is_toggle_mode")); ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "is_pressed"), _SCS("set_pressed"), _SCS("is_pressed")); - ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "click_on_press"), _SCS("set_click_on_press"), _SCS("get_click_on_press")); + ADD_PROPERTYNO( PropertyInfo( Variant::INT, "action_mode",PROPERTY_HINT_ENUM,"Button Press,Button Release"), _SCS("set_action_mode"), _SCS("get_action_mode")); ADD_PROPERTY( PropertyInfo( Variant::INT,"enabled_focus_mode", PROPERTY_HINT_ENUM, "None,Click,All" ), _SCS("set_enabled_focus_mode"), _SCS("get_enabled_focus_mode") ); ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "shortcut",PROPERTY_HINT_RESOURCE_TYPE,"ShortCut"), _SCS("set_shortcut"), _SCS("get_shortcut")); ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "group",PROPERTY_HINT_RESOURCE_TYPE,"ButtonGroup"), _SCS("set_button_group"), _SCS("get_button_group")); @@ -547,6 +547,10 @@ void BaseButton::_bind_methods() { BIND_CONSTANT( DRAW_HOVER ); BIND_CONSTANT( DRAW_DISABLED ); + BIND_CONSTANT( ACTION_MODE_BUTTON_PRESS ); + BIND_CONSTANT( ACTION_MODE_BUTTON_RELEASE ); + + } BaseButton::BaseButton() { @@ -557,10 +561,10 @@ BaseButton::BaseButton() { status.hovering=false; status.pressing_inside=false; status.disabled = false; - status.click_on_press=false; status.pressing_button=0; set_focus_mode( FOCUS_ALL ); enabled_focus_mode = FOCUS_ALL; + action_mode=ACTION_MODE_BUTTON_RELEASE; if (button_group.is_valid()) { diff --git a/scene/gui/base_button.h b/scene/gui/base_button.h index 898c19e811..def4ff7536 100644 --- a/scene/gui/base_button.h +++ b/scene/gui/base_button.h @@ -40,11 +40,20 @@ class ButtonGroup; class BaseButton : public Control { GDCLASS( BaseButton, Control ); +public: + + enum ActionMode { + ACTION_MODE_BUTTON_PRESS, + ACTION_MODE_BUTTON_RELEASE, + }; + +private: bool toggle_mode; FocusMode enabled_focus_mode; Ref<ShortCut> shortcut; + ActionMode action_mode; struct Status { bool pressed; @@ -53,7 +62,6 @@ class BaseButton : public Control { bool pressing_inside; bool disabled; - bool click_on_press; int pressing_button; } status; @@ -100,8 +108,8 @@ public: void set_disabled(bool p_disabled); bool is_disabled() const; - void set_click_on_press(bool p_click_on_press); - bool get_click_on_press() const; + void set_action_mode(ActionMode p_mode); + ActionMode get_action_mode() const; void set_enabled_focus_mode(FocusMode p_mode); FocusMode get_enabled_focus_mode() const; @@ -120,6 +128,8 @@ public: }; VARIANT_ENUM_CAST( BaseButton::DrawMode ) +VARIANT_ENUM_CAST( BaseButton::ActionMode ) + class ButtonGroup : public Resource { diff --git a/scene/gui/box_container.cpp b/scene/gui/box_container.cpp index f31f51a5cd..7ca44ac27b 100644 --- a/scene/gui/box_container.cpp +++ b/scene/gui/box_container.cpp @@ -55,7 +55,7 @@ void BoxContainer::_resort() { for(int i=0;i<get_child_count();i++) { Control *c=get_child(i)->cast_to<Control>(); - if (!c || !c->is_visible()) + if (!c || !c->is_visible_in_tree()) continue; if (c->is_set_as_toplevel()) continue; @@ -108,7 +108,7 @@ void BoxContainer::_resort() { for(int i=0;i<get_child_count();i++) { Control *c=get_child(i)->cast_to<Control>(); - if (!c || !c->is_visible()) + if (!c || !c->is_visible_in_tree()) continue; if (c->is_set_as_toplevel()) continue; @@ -164,7 +164,7 @@ void BoxContainer::_resort() { for(int i=0;i<get_child_count();i++) { Control *c=get_child(i)->cast_to<Control>(); - if (!c || !c->is_visible()) + if (!c || !c->is_visible_in_tree()) continue; if (c->is_set_as_toplevel()) continue; @@ -227,7 +227,7 @@ Size2 BoxContainer::get_minimum_size() const { if (c->is_set_as_toplevel()) continue; - if (c->is_hidden()) { + if (!c->is_visible()) { continue; } @@ -296,7 +296,7 @@ BoxContainer::BoxContainer(bool p_vertical) { vertical=p_vertical; align = ALIGN_BEGIN; -// set_ignore_mouse(true); + //set_ignore_mouse(true); set_mouse_filter(MOUSE_FILTER_PASS); } diff --git a/scene/gui/center_container.cpp b/scene/gui/center_container.cpp index 4a42695c3a..4d4abb6484 100644 --- a/scene/gui/center_container.cpp +++ b/scene/gui/center_container.cpp @@ -42,7 +42,7 @@ Size2 CenterContainer::get_minimum_size() const { continue; if (c->is_set_as_toplevel()) continue; - if (c->is_hidden()) + if (!c->is_visible()) continue; Size2 minsize = c->get_combined_minimum_size(); ms.width = MAX(ms.width , minsize.width); diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index ac8ce68564..da2fb1bc91 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -75,7 +75,7 @@ void ColorPicker::_update_controls() { } -void ColorPicker::set_color(const Color& p_color) { +void ColorPicker::set_pick_color(const Color& p_color) { color=p_color; if (color != last_hsv) { @@ -121,7 +121,7 @@ void ColorPicker::_value_changed(double) { color.components[i] = scroll[i]->get_value()/(raw_mode_enabled?1.0:255.0); } - set_color(color); + set_pick_color(color); _update_text_value(); @@ -139,7 +139,7 @@ void ColorPicker::_html_entered(const String& p_html) { if (!is_inside_tree()) return; - set_color(color); + set_pick_color(color); emit_signal("color_changed",color); } @@ -208,7 +208,7 @@ void ColorPicker::_text_type_toggled() _update_color(); } -Color ColorPicker::get_color() const { +Color ColorPicker::get_pick_color() const { return color; } @@ -320,7 +320,7 @@ void ColorPicker::_uv_input(const InputEvent &ev) { v=1.0-y/256.0; color.set_hsv(h,s,v,color.a); last_hsv = color; - set_color(color); + set_pick_color(color); _update_color(); emit_signal("color_changed", color); } else { @@ -336,7 +336,7 @@ void ColorPicker::_uv_input(const InputEvent &ev) { v=1.0-y/256.0; color.set_hsv(h,s,v,color.a); last_hsv = color; - set_color(color); + set_pick_color(color); _update_color(); emit_signal("color_changed", color); } @@ -354,7 +354,7 @@ void ColorPicker::_w_input(const InputEvent &ev) { } color.set_hsv(h,s,v,color.a); last_hsv = color; - set_color(color); + set_pick_color(color); _update_color(); emit_signal("color_changed", color); } else if (ev.type == InputEvent::MOUSE_MOTION) { @@ -365,7 +365,7 @@ void ColorPicker::_w_input(const InputEvent &ev) { h=1.0-y/256.0; color.set_hsv(h,s,v,color.a); last_hsv = color; - set_color(color); + set_pick_color(color); _update_color(); emit_signal("color_changed", color); } @@ -376,7 +376,7 @@ void ColorPicker::_preset_input(const InputEvent &ev) { const InputEventMouseButton &bev = ev.mouse_button; if (bev.pressed && bev.button_index==BUTTON_LEFT) { int index = bev.x/(preset->get_size().x/presets.size()); - set_color(presets[index]); + set_pick_color(presets[index]); } else if (bev.pressed && bev.button_index==BUTTON_RIGHT) { int index = bev.x/(preset->get_size().x/presets.size()); presets.erase(presets[index]); @@ -425,7 +425,7 @@ void ColorPicker::_screen_input(const InputEvent &ev) Color c( r[ofs+0]/255.0, r[ofs+1]/255.0, r[ofs+2]/255.0 ); - set_color(c); + set_pick_color(c); } } } @@ -451,8 +451,8 @@ void ColorPicker::_screen_pick_pressed() void ColorPicker::_bind_methods() { - ClassDB::bind_method(_MD("set_color","color"),&ColorPicker::set_color); - ClassDB::bind_method(_MD("get_color"),&ColorPicker::get_color); + ClassDB::bind_method(_MD("set_pick_color","color"),&ColorPicker::set_pick_color); + ClassDB::bind_method(_MD("get_pick_color"),&ColorPicker::get_pick_color); ClassDB::bind_method(_MD("set_raw_mode","mode"),&ColorPicker::set_raw_mode); ClassDB::bind_method(_MD("is_raw_mode"),&ColorPicker::is_raw_mode); ClassDB::bind_method(_MD("set_edit_alpha","show"),&ColorPicker::set_edit_alpha); @@ -487,7 +487,7 @@ ColorPicker::ColorPicker() : btn_pick = memnew( ToolButton ); btn_pick->connect("pressed",this,"_screen_pick_pressed"); - sample = memnew( TextureFrame ); + sample = memnew( TextureRect ); sample->set_h_size_flags(SIZE_EXPAND_FILL); sample->connect("draw",this,"_sample_draw"); @@ -584,13 +584,13 @@ ColorPicker::ColorPicker() : //_update_color(); updating=false; - set_color(Color(1,1,1)); + set_pick_color(Color(1,1,1)); HBoxContainer *bbc = memnew( HBoxContainer ); add_child(bbc); - preset = memnew( TextureFrame ); + preset = memnew( TextureRect ); bbc->add_child(preset); //preset->set_ignore_mouse(false); preset->connect("gui_input", this, "_preset_input"); @@ -632,20 +632,20 @@ void ColorPickerButton::_notification(int p_what) { if (p_what==NOTIFICATION_DRAW) { Ref<StyleBox> normal = get_stylebox("normal" ); - draw_rect(Rect2(normal->get_offset(),get_size()-normal->get_minimum_size()),picker->get_color()); + draw_rect(Rect2(normal->get_offset(),get_size()-normal->get_minimum_size()),picker->get_pick_color()); } } -void ColorPickerButton::set_color(const Color& p_color){ +void ColorPickerButton::set_pick_color(const Color& p_color){ - picker->set_color(p_color); + picker->set_pick_color(p_color); update(); emit_signal("color_changed",p_color); } -Color ColorPickerButton::get_color() const{ +Color ColorPickerButton::get_pick_color() const{ - return picker->get_color(); + return picker->get_pick_color(); } void ColorPickerButton::set_edit_alpha(bool p_show) { @@ -665,15 +665,15 @@ ColorPicker *ColorPickerButton::get_picker() { void ColorPickerButton::_bind_methods(){ - ClassDB::bind_method(_MD("set_color","color"),&ColorPickerButton::set_color); - ClassDB::bind_method(_MD("get_color"),&ColorPickerButton::get_color); + ClassDB::bind_method(_MD("set_pick_color","color"),&ColorPickerButton::set_pick_color); + ClassDB::bind_method(_MD("get_pick_color"),&ColorPickerButton::get_pick_color); ClassDB::bind_method(_MD("get_picker:ColorPicker"),&ColorPickerButton::get_picker); ClassDB::bind_method(_MD("set_edit_alpha","show"),&ColorPickerButton::set_edit_alpha); ClassDB::bind_method(_MD("is_editing_alpha"),&ColorPickerButton::is_editing_alpha); ClassDB::bind_method(_MD("_color_changed"),&ColorPickerButton::_color_changed); ADD_SIGNAL( MethodInfo("color_changed",PropertyInfo(Variant::COLOR,"color"))); - ADD_PROPERTY( PropertyInfo(Variant::COLOR,"color"),_SCS("set_color"),_SCS("get_color") ); + ADD_PROPERTY( PropertyInfo(Variant::COLOR,"color"),_SCS("set_pick_color"),_SCS("get_pick_color") ); ADD_PROPERTY( PropertyInfo(Variant::BOOL,"edit_alpha"),_SCS("set_edit_alpha"),_SCS("is_editing_alpha") ); } diff --git a/scene/gui/color_picker.h b/scene/gui/color_picker.h index c6a8ef7725..d9db9c89f7 100644 --- a/scene/gui/color_picker.h +++ b/scene/gui/color_picker.h @@ -36,7 +36,7 @@ #include "scene/gui/button.h" #include "scene/gui/popup.h" #include "scene/gui/box_container.h" -#include "scene/gui/texture_frame.h" +#include "scene/gui/texture_rect.h" #include "scene/gui/tool_button.h" #include "scene/gui/check_button.h" @@ -50,8 +50,8 @@ private: Image last_capture; Control *uv_edit; Control *w_edit; - TextureFrame *sample; - TextureFrame *preset; + TextureRect *sample; + TextureRect *preset; Button *bt_add_preset; List<Color> presets; ToolButton *btn_pick; @@ -98,8 +98,8 @@ public: void set_edit_alpha(bool p_show); bool is_editing_alpha() const; - void set_color(const Color& p_color); - Color get_color() const; + void set_pick_color(const Color& p_color); + Color get_pick_color() const; void add_preset(const Color& p_color); void set_raw_mode(bool p_enabled); @@ -126,8 +126,8 @@ protected: static void _bind_methods(); public: - void set_color(const Color& p_color); - Color get_color() const; + void set_pick_color(const Color& p_color); + Color get_pick_color() const; void set_edit_alpha(bool p_show); bool is_editing_alpha() const; diff --git a/scene/gui/color_ramp_edit.cpp b/scene/gui/color_ramp_edit.cpp index c3ed3d821d..5d5d6c31a2 100644 --- a/scene/gui/color_ramp_edit.cpp +++ b/scene/gui/color_ramp_edit.cpp @@ -60,7 +60,7 @@ void ColorRampEdit::_show_color_picker() { if (grabbed==-1) return; Size2 ms = Size2(350, picker->get_combined_minimum_size().height+10); - picker->set_color(points[grabbed].color); + picker->set_pick_color(points[grabbed].color); popup->set_pos(get_global_pos()-Vector2(ms.width-get_size().width,ms.height)); popup->set_size(ms); popup->popup(); diff --git a/scene/gui/color_rect.cpp b/scene/gui/color_rect.cpp index fee96d1ca9..99797aa9c1 100644 --- a/scene/gui/color_rect.cpp +++ b/scene/gui/color_rect.cpp @@ -1,36 +1,61 @@ +/*************************************************************************/ +/* color_rect.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #include "color_rect.h" - - -void ColorFrame::set_frame_color(const Color& p_color) { +void ColorRect::set_frame_color(const Color& p_color) { color=p_color; update(); } -Color ColorFrame::get_frame_color() const{ +Color ColorRect::get_frame_color() const{ return color; } -void ColorFrame::_notification(int p_what) { +void ColorRect::_notification(int p_what) { if (p_what==NOTIFICATION_DRAW) { draw_rect(Rect2(Point2(),get_size()),color); } } -void ColorFrame::_bind_methods() { +void ColorRect::_bind_methods() { - ClassDB::bind_method(_MD("set_frame_color","color"),&ColorFrame::set_frame_color); - ClassDB::bind_method(_MD("get_frame_color"),&ColorFrame::get_frame_color); + ClassDB::bind_method(_MD("set_frame_color","color"),&ColorRect::set_frame_color); + ClassDB::bind_method(_MD("get_frame_color"),&ColorRect::get_frame_color); ADD_PROPERTY(PropertyInfo(Variant::COLOR,"color"),_SCS("set_frame_color"),_SCS("get_frame_color") ); } -ColorFrame::ColorFrame() { +ColorRect::ColorRect() { color=Color(1,1,1); } - diff --git a/scene/gui/color_rect.h b/scene/gui/color_rect.h index f313bbc4f9..55e413ce27 100644 --- a/scene/gui/color_rect.h +++ b/scene/gui/color_rect.h @@ -1,10 +1,38 @@ -#ifndef COLORRECT_H -#define COLORRECT_H +/*************************************************************************/ +/* color_rect.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#ifndef COLOR_RECT_H +#define COLOR_RECT_H #include "scene/gui/control.h" -class ColorFrame : public Control { - GDCLASS(ColorFrame,Control) +class ColorRect : public Control { + GDCLASS(ColorRect,Control) Color color; protected: @@ -16,7 +44,7 @@ public: void set_frame_color(const Color& p_color); Color get_frame_color() const; - ColorFrame(); + ColorRect(); }; -#endif // COLORRECT_H +#endif // COLOR_RECT_H diff --git a/scene/gui/container.cpp b/scene/gui/container.cpp index a5a5c61082..de5f35933c 100644 --- a/scene/gui/container.cpp +++ b/scene/gui/container.cpp @@ -147,7 +147,7 @@ void Container::_notification(int p_what) { } break; case NOTIFICATION_VISIBILITY_CHANGED: { - if (is_visible()) { + if (is_visible_in_tree()) { queue_sort(); } } break; diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 054622668b..533d24f998 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -468,10 +468,12 @@ void Control::_notification(int p_notification) { } - //if (data.theme.is_null() && data.parent && data.parent->data.theme_owner) { - // data.theme_owner=data.parent->data.theme_owner; - // notification(NOTIFICATION_THEME_CHANGED); - //} + /* + if (data.theme.is_null() && data.parent && data.parent->data.theme_owner) { + data.theme_owner=data.parent->data.theme_owner; + notification(NOTIFICATION_THEME_CHANGED); + } + */ } break; case NOTIFICATION_EXIT_CANVAS: { @@ -503,10 +505,12 @@ void Control::_notification(int p_notification) { data.parent=NULL; data.parent_canvas_item=NULL; - //if (data.theme_owner && data.theme.is_null()) { - // data.theme_owner=NULL; - //notification(NOTIFICATION_THEME_CHANGED); - //} + /* + if (data.theme_owner && data.theme.is_null()) { + data.theme_owner=NULL; + notification(NOTIFICATION_THEME_CHANGED); + } + */ } break; case NOTIFICATION_MOVED_IN_PARENT: { @@ -565,7 +569,7 @@ void Control::_notification(int p_notification) { } break; case NOTIFICATION_VISIBILITY_CHANGED: { - if (!is_visible()) { + if (!is_visible_in_tree()) { if(get_viewport() != NULL) get_viewport()->_gui_hid_control(this); @@ -1660,7 +1664,7 @@ static Control *_next_control(Control *p_from) { for(int i=(next+1);i<parent->get_child_count();i++) { Control *c = parent->get_child(i)->cast_to<Control>(); - if (!c || !c->is_visible() || c->is_set_as_toplevel()) + if (!c || !c->is_visible_in_tree() || c->is_set_as_toplevel()) continue; return c; @@ -1685,7 +1689,7 @@ Control *Control::find_next_valid_focus() const { for(int i=0;i<from->get_child_count();i++) { Control *c = from->get_child(i)->cast_to<Control>(); - if (!c || !c->is_visible() || c->is_set_as_toplevel()) { + if (!c || !c->is_visible_in_tree() || c->is_set_as_toplevel()) { continue; } @@ -1751,7 +1755,7 @@ static Control *_prev_control(Control *p_from) { for(int i=p_from->get_child_count()-1;i>=0;i--) { Control *c = p_from->get_child(i)->cast_to<Control>(); - if (!c || !c->is_visible() || c->is_set_as_toplevel()) + if (!c || !c->is_visible_in_tree() || c->is_set_as_toplevel()) continue; child=c; @@ -1791,7 +1795,7 @@ Control *Control::find_prev_valid_focus() const { Control *c = from->get_parent()->get_child(i)->cast_to<Control>(); - if (!c || !c->is_visible() || c->is_set_as_toplevel()) { + if (!c || !c->is_visible_in_tree() || c->is_set_as_toplevel()) { continue; } @@ -1875,7 +1879,7 @@ void Control::show_modal(bool p_exclusive) { ERR_FAIL_COND(!is_inside_tree()); ERR_FAIL_COND(!data.SI); - if (is_visible()) + if (is_visible_in_tree()) hide(); ERR_FAIL_COND( data.MI!=NULL ); @@ -1883,7 +1887,7 @@ void Control::show_modal(bool p_exclusive) { raise(); data.modal_exclusive=p_exclusive; data.MI=get_viewport()->_gui_show_modal(this); - data.modal_frame=OS::get_singleton()->get_frames_drawn(); + data.modal_frame=Engine::get_singleton()->get_frames_drawn(); } @@ -2053,7 +2057,7 @@ Control *Control::_get_focus_neighbour(Margin p_margin,int p_count) { return NULL; } bool valid=true; - if (c->is_hidden()) + if (!c->is_visible()) valid=false; if (c->get_focus_mode()==FOCUS_NONE) valid=false; @@ -2126,7 +2130,7 @@ void Control::_window_find_focus_neighbour(const Vector2& p_dir, Node *p_at,cons Control *c = p_at->cast_to<Control>(); - if (c && c !=this && c->get_focus_mode()==FOCUS_ALL && c->is_visible()) { + if (c && c !=this && c->get_focus_mode()==FOCUS_ALL && c->is_visible_in_tree()) { Point2 points[4]; @@ -2444,7 +2448,7 @@ bool Control::is_clipping_contents() { void Control::_bind_methods() { -// ClassDB::bind_method(_MD("_window_resize_event"),&Control::_window_resize_event); + //ClassDB::bind_method(_MD("_window_resize_event"),&Control::_window_resize_event); ClassDB::bind_method(_MD("_size_changed"),&Control::_size_changed); ClassDB::bind_method(_MD("_update_minimum_size"),&Control::_update_minimum_size); diff --git a/scene/gui/dialogs.h b/scene/gui/dialogs.h index c7beeea7a3..6650c5eb5d 100644 --- a/scene/gui/dialogs.h +++ b/scene/gui/dialogs.h @@ -94,7 +94,7 @@ class AcceptDialog : public WindowDialog { HBoxContainer *hbc; Label *label; Button *ok; -// Button *cancel; no more cancel (there is X on tht titlebar) + //Button *cancel; no more cancel (there is X on tht titlebar) bool hide_on_ok; diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index 1cd04551c5..393f14bee2 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -615,7 +615,7 @@ void FileDialog::set_access(Access p_access) { void FileDialog::invalidate() { - if (is_visible()) { + if (is_visible_in_tree()) { update_file_list(); invalidated=false; } else { diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index b919f0649d..ba1ab1afa8 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -295,7 +295,7 @@ void GraphEdit::_notification(int p_what) { zoom_reset->set_icon(get_icon("reset")); zoom_plus->set_icon(get_icon("more")); snap_button->set_icon(get_icon("snap")); -// zoom_icon->set_texture( get_icon("Zoom", "EditorIcons")); + //zoom_icon->set_texture( get_icon("Zoom", "EditorIcons")); } if (p_what==NOTIFICATION_DRAW) { @@ -1054,7 +1054,7 @@ void GraphEdit::set_zoom(float p_zoom) { _update_scroll(); connections_layer->update(); - if (is_visible()) { + if (is_visible_in_tree()) { Vector2 ofs = sbofs*zoom - get_size()/2; h_scroll->set_value( ofs.x ); diff --git a/scene/gui/graph_edit.h b/scene/gui/graph_edit.h index 86b976c4fe..3e9944332f 100644 --- a/scene/gui/graph_edit.h +++ b/scene/gui/graph_edit.h @@ -34,7 +34,7 @@ #include "scene/gui/slider.h" #include "scene/gui/tool_button.h" #include "scene/gui/spin_box.h" -#include "texture_frame.h" +#include "scene/gui/texture_rect.h" class GraphEdit; diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp index 8b7b84910d..aa8c875f40 100644 --- a/scene/gui/graph_node.cpp +++ b/scene/gui/graph_node.cpp @@ -217,8 +217,8 @@ void GraphNode::_notification(int p_what) { sb = get_stylebox( selected ? "selectedframe" : "frame"); } - sb=sb->duplicate(); - sb->call("set_modulate",modulate); + //sb=sb->duplicate(); + //sb->call("set_modulate",modulate); Ref<Texture> port =get_icon("port"); Ref<Texture> close =get_icon("close"); Ref<Texture> resizer =get_icon("resizer"); @@ -675,16 +675,6 @@ void GraphNode::_gui_input(const InputEvent& p_ev) { } -void GraphNode::set_modulate(const Color &p_color) { - - modulate=p_color; - update(); -} - -Color GraphNode::get_modulate() const{ - - return modulate; -} void GraphNode::set_overlay(Overlay p_overlay) { overlay=p_overlay; @@ -758,9 +748,6 @@ void GraphNode::_bind_methods() { ClassDB::bind_method(_MD("get_connection_input_type","idx"),&GraphNode::get_connection_input_type); ClassDB::bind_method(_MD("get_connection_input_color","idx"),&GraphNode::get_connection_input_color); - ClassDB::bind_method(_MD("set_modulate","color"),&GraphNode::set_modulate); - ClassDB::bind_method(_MD("get_modulate"),&GraphNode::get_modulate); - ClassDB::bind_method(_MD("set_show_close_button","show"),&GraphNode::set_show_close_button); ClassDB::bind_method(_MD("is_close_button_visible"),&GraphNode::is_close_button_visible); @@ -788,7 +775,6 @@ GraphNode::GraphNode() { show_close=false; connpos_dirty=true; set_mouse_filter(MOUSE_FILTER_PASS); - modulate=Color(1,1,1,1); comment=false; resizeable=false; resizing=false; diff --git a/scene/gui/graph_node.h b/scene/gui/graph_node.h index a128426d38..9cb46fc49c 100644 --- a/scene/gui/graph_node.h +++ b/scene/gui/graph_node.h @@ -92,8 +92,6 @@ private: Overlay overlay; - Color modulate; - bool has_point(const Point2& p_point) const; protected: @@ -147,9 +145,6 @@ public: Color get_connection_output_color(int p_idx); - void set_modulate(const Color& p_color); - Color get_modulate() const; - void set_overlay(Overlay p_overlay); Overlay get_overlay() const; diff --git a/scene/gui/grid_container.cpp b/scene/gui/grid_container.cpp index 7dffaa2fd5..597169ca83 100644 --- a/scene/gui/grid_container.cpp +++ b/scene/gui/grid_container.cpp @@ -53,7 +53,7 @@ void GridContainer::_notification(int p_what) { for(int i=0;i<get_child_count();i++) { Control *c = get_child(i)->cast_to<Control>(); - if (!c || !c->is_visible()) + if (!c || !c->is_visible_in_tree()) continue; int row = idx / columns; @@ -70,7 +70,7 @@ void GridContainer::_notification(int p_what) { else row_minh[row]=ms.height; - // print_line("store row "+itos(row)+" mw "+itos(ms.height)); + //print_line("store row "+itos(row)+" mw "+itos(ms.height)); if (c->get_h_size_flags()&SIZE_EXPAND) col_expanded.insert(col); @@ -112,7 +112,7 @@ void GridContainer::_notification(int p_what) { for(int i=0;i<get_child_count();i++) { Control *c = get_child(i)->cast_to<Control>(); - if (!c || !c->is_visible()) + if (!c || !c->is_visible_in_tree()) continue; int row = idx / columns; int col = idx % columns; @@ -136,7 +136,7 @@ void GridContainer::_notification(int p_what) { Point2 p(col_ofs,row_ofs); -// print_line("col: "+itos(col)+" row: "+itos(row)+" col_ofs: "+itos(col_ofs)+" row_ofs: "+itos(row_ofs)); + //print_line("col: "+itos(col)+" row: "+itos(row)+" col_ofs: "+itos(col_ofs)+" row_ofs: "+itos(row_ofs)); fit_child_in_rect(c,Rect2(p,s)); //print_line("col: "+itos(col)+" row: "+itos(row)+" rect: "+Rect2(p,s)); @@ -191,7 +191,7 @@ Size2 GridContainer::get_minimum_size() const { for(int i=0;i<get_child_count();i++) { Control *c = get_child(i)->cast_to<Control>(); - if (!c || !c->is_visible()) + if (!c || !c->is_visible_in_tree()) continue; int row = idx / columns; int col = idx % columns; diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index ece6171b6e..a3ed0a91cf 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -801,7 +801,7 @@ void ItemList::_notification(int p_what) { float page = size.height-bg->get_minimum_size().height; int width = size.width-bg->get_minimum_size().width; - if (!scroll_bar->is_hidden()){ + if (scroll_bar->is_visible()){ width-=mw+bg->get_margin(MARGIN_RIGHT); } scroll_bar->set_page(page); diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index e75785b1ff..3a72e0e445 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -96,8 +96,6 @@ void LineEdit::_gui_input(InputEvent p_event) { } } - // if (!editable) - // non_editable_clicked_signal.call(); update(); } else { @@ -853,7 +851,7 @@ void LineEdit::_reset_caret_blink_timer() { void LineEdit::_toggle_draw_caret() { draw_caret = !draw_caret; - if (is_visible() && has_focus() && window_has_focus) { + if (is_visible_in_tree() && has_focus() && window_has_focus) { update(); } } @@ -873,7 +871,7 @@ void LineEdit::delete_char() { if (cursor_pos==window_pos) { - // set_window_pos(cursor_pos-get_window_length()); + //set_window_pos(cursor_pos-get_window_length()); } _text_changed(); diff --git a/scene/gui/margin_container.cpp b/scene/gui/margin_container.cpp index 883364b2fd..be27c40117 100644 --- a/scene/gui/margin_container.cpp +++ b/scene/gui/margin_container.cpp @@ -45,7 +45,7 @@ Size2 MarginContainer::get_minimum_size() const { continue; if (c->is_set_as_toplevel()) continue; - if (c->is_hidden()) + if (!c->is_visible()) continue; Size2 s = c->get_combined_minimum_size(); diff --git a/scene/gui/menu_button.cpp b/scene/gui/menu_button.cpp index 755b296666..4a366c55c6 100644 --- a/scene/gui/menu_button.cpp +++ b/scene/gui/menu_button.cpp @@ -36,7 +36,7 @@ void MenuButton::_unhandled_key_input(InputEvent p_event) { if (p_event.is_pressed() && !p_event.is_echo() && (p_event.type==InputEvent::KEY || p_event.type==InputEvent::ACTION || p_event.type==InputEvent::JOYPAD_BUTTON)) { - if (!get_parent() || !is_visible() || is_disabled()) + if (!get_parent() || !is_visible_in_tree() || is_disabled()) return; bool global_only = (get_viewport()->get_modal_stack_top() && !get_viewport()->get_modal_stack_top()->is_a_parent_of(this)); @@ -67,7 +67,7 @@ void MenuButton::_gui_input(InputEvent p_event) { /*if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==BUTTON_LEFT) { clicked=p_event.mouse_button.pressed; } - if (clicked && p_event.type==InputEvent::MOUSE_MOTION && popup->is_visible()) { + if (clicked && p_event.type==InputEvent::MOUSE_MOTION && popup->is_visible_in_tree()) { Point2 gt = Point2(p_event.mouse_motion.x,p_event.mouse_motion.y); gt = get_global_transform().xform(gt); @@ -117,7 +117,7 @@ MenuButton::MenuButton() { add_child(popup); popup->set_as_toplevel(true); set_process_unhandled_key_input(true); - set_click_on_press(true); + set_action_mode(ACTION_MODE_BUTTON_PRESS); } diff --git a/scene/gui/panel_container.cpp b/scene/gui/panel_container.cpp index 451a85cf48..48270d12c7 100644 --- a/scene/gui/panel_container.cpp +++ b/scene/gui/panel_container.cpp @@ -43,7 +43,7 @@ Size2 PanelContainer::get_minimum_size() const { for(int i=0;i<get_child_count();i++) { Control *c = get_child(i)->cast_to<Control>(); - if (!c || !c->is_visible()) + if (!c || !c->is_visible_in_tree()) continue; if (c->is_set_as_toplevel()) continue; @@ -98,7 +98,7 @@ void PanelContainer::_notification(int p_what) { for(int i=0;i<get_child_count();i++) { Control *c = get_child(i)->cast_to<Control>(); - if (!c || !c->is_visible()) + if (!c || !c->is_visible_in_tree()) continue; if (c->is_set_as_toplevel()) continue; diff --git a/scene/gui/patch_9_frame.cpp b/scene/gui/patch_9_rect.cpp index e32f60a222..4e1856778e 100644 --- a/scene/gui/patch_9_frame.cpp +++ b/scene/gui/patch_9_rect.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* patch_9_frame.cpp */ +/* patch_9_rect.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -26,11 +26,11 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "patch_9_frame.h" +#include "patch_9_rect.h" #include "servers/visual_server.h" -void Patch9Frame::_notification(int p_what) { +void NinePatchRect::_notification(int p_what) { if (p_what==NOTIFICATION_DRAW) { @@ -40,7 +40,7 @@ void Patch9Frame::_notification(int p_what) { Size2 s=get_size(); RID ci = get_canvas_item(); VS::get_singleton()->canvas_item_add_nine_patch(ci,Rect2(Point2(),s),region_rect,texture->get_rid(),Vector2(margin[MARGIN_LEFT],margin[MARGIN_TOP]),Vector2(margin[MARGIN_RIGHT],margin[MARGIN_BOTTOM]),VS::NINE_PATCH_STRETCH,VS::NINE_PATCH_STRETCH,draw_center); -// draw_texture_rect(texture,Rect2(Point2(),s),false,modulate); + //draw_texture_rect(texture,Rect2(Point2(),s),false,modulate); /* Vector<Point2> points; @@ -61,21 +61,21 @@ void Patch9Frame::_notification(int p_what) { } } -Size2 Patch9Frame::get_minimum_size() const { +Size2 NinePatchRect::get_minimum_size() const { return Size2(margin[MARGIN_LEFT]+margin[MARGIN_RIGHT],margin[MARGIN_TOP]+margin[MARGIN_BOTTOM]); } -void Patch9Frame::_bind_methods() { +void NinePatchRect::_bind_methods() { - ClassDB::bind_method(_MD("set_texture","texture"), & Patch9Frame::set_texture ); - ClassDB::bind_method(_MD("get_texture"), & Patch9Frame::get_texture ); - ClassDB::bind_method(_MD("set_patch_margin","margin","value"), & Patch9Frame::set_patch_margin ); - ClassDB::bind_method(_MD("get_patch_margin","margin"), & Patch9Frame::get_patch_margin ); - ClassDB::bind_method(_MD("set_region_rect","rect"),&Patch9Frame::set_region_rect); - ClassDB::bind_method(_MD("get_region_rect"),&Patch9Frame::get_region_rect); - ClassDB::bind_method(_MD("set_draw_center","draw_center"), & Patch9Frame::set_draw_center ); - ClassDB::bind_method(_MD("get_draw_center"), & Patch9Frame::get_draw_center ); + ClassDB::bind_method(_MD("set_texture","texture"), & NinePatchRect::set_texture ); + ClassDB::bind_method(_MD("get_texture"), & NinePatchRect::get_texture ); + ClassDB::bind_method(_MD("set_patch_margin","margin","value"), & NinePatchRect::set_patch_margin ); + ClassDB::bind_method(_MD("get_patch_margin","margin"), & NinePatchRect::get_patch_margin ); + ClassDB::bind_method(_MD("set_region_rect","rect"),&NinePatchRect::set_region_rect); + ClassDB::bind_method(_MD("get_region_rect"),&NinePatchRect::get_region_rect); + ClassDB::bind_method(_MD("set_draw_center","draw_center"), & NinePatchRect::set_draw_center ); + ClassDB::bind_method(_MD("get_draw_center"), & NinePatchRect::get_draw_center ); ADD_SIGNAL(MethodInfo("texture_changed")); @@ -92,26 +92,28 @@ void Patch9Frame::_bind_methods() { } -void Patch9Frame::set_texture(const Ref<Texture>& p_tex) { +void NinePatchRect::set_texture(const Ref<Texture>& p_tex) { if (texture==p_tex) return; texture=p_tex; update(); - //if (texture.is_valid()) - // texture->set_flags(texture->get_flags()&(~Texture::FLAG_REPEAT)); //remove repeat from texture, it looks bad in sprites + /* + if (texture.is_valid()) + texture->set_flags(texture->get_flags()&(~Texture::FLAG_REPEAT)); //remove repeat from texture, it looks bad in sprites + */ minimum_size_changed(); emit_signal("texture_changed"); } -Ref<Texture> Patch9Frame::get_texture() const { +Ref<Texture> NinePatchRect::get_texture() const { return texture; } -void Patch9Frame::set_patch_margin(Margin p_margin,int p_size) { +void NinePatchRect::set_patch_margin(Margin p_margin,int p_size) { ERR_FAIL_INDEX(p_margin,4); margin[p_margin]=p_size; @@ -133,13 +135,13 @@ void Patch9Frame::set_patch_margin(Margin p_margin,int p_size) { } } -int Patch9Frame::get_patch_margin(Margin p_margin) const{ +int NinePatchRect::get_patch_margin(Margin p_margin) const{ ERR_FAIL_INDEX_V(p_margin,4,0); return margin[p_margin]; } -void Patch9Frame::set_region_rect(const Rect2& p_region_rect) { +void NinePatchRect::set_region_rect(const Rect2& p_region_rect) { if (region_rect==p_region_rect) return; @@ -150,23 +152,23 @@ void Patch9Frame::set_region_rect(const Rect2& p_region_rect) { _change_notify("region_rect"); } -Rect2 Patch9Frame::get_region_rect() const { +Rect2 NinePatchRect::get_region_rect() const { return region_rect; } -void Patch9Frame::set_draw_center(bool p_draw) { +void NinePatchRect::set_draw_center(bool p_draw) { draw_center=p_draw; update(); } -bool Patch9Frame::get_draw_center() const{ +bool NinePatchRect::get_draw_center() const{ return draw_center; } -Patch9Frame::Patch9Frame() { +NinePatchRect::NinePatchRect() { margin[MARGIN_LEFT]=0; @@ -179,6 +181,6 @@ Patch9Frame::Patch9Frame() { } -Patch9Frame::~Patch9Frame() +NinePatchRect::~NinePatchRect() { } diff --git a/scene/gui/patch_9_frame.h b/scene/gui/patch_9_rect.h index afbeca5ae8..b87f2f64ec 100644 --- a/scene/gui/patch_9_frame.h +++ b/scene/gui/patch_9_rect.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* patch_9_frame.h */ +/* patch_9_rect.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -33,9 +33,9 @@ /** @author Juan Linietsky <reduzio@gmail.com> */ -class Patch9Frame : public Control { +class NinePatchRect : public Control { - GDCLASS(Patch9Frame,Control); + GDCLASS(NinePatchRect,Control); bool draw_center; int margin[4]; @@ -61,8 +61,8 @@ public: void set_draw_center(bool p_enable); bool get_draw_center() const; - Patch9Frame(); - ~Patch9Frame(); + NinePatchRect(); + ~NinePatchRect(); }; #endif // PATCH_9_FRAME_H diff --git a/scene/gui/popup.cpp b/scene/gui/popup.cpp index 5126568e5f..3f0f76f184 100644 --- a/scene/gui/popup.cpp +++ b/scene/gui/popup.cpp @@ -39,7 +39,7 @@ void Popup::_gui_input(InputEvent p_event) { void Popup::_notification(int p_what) { if (p_what==NOTIFICATION_VISIBILITY_CHANGED) { - if (popped_up && !is_visible()) { + if (popped_up && !is_visible_in_tree()) { popped_up=false; notification(NOTIFICATION_POPUP_HIDE); emit_signal("popup_hide"); @@ -103,7 +103,7 @@ void Popup::set_as_minsize() { Control *c=get_child(i)->cast_to<Control>(); if (!c) continue; - if (c->is_hidden()) + if (!c->is_visible()) continue; Size2 minsize = c->get_combined_minimum_size(); @@ -144,7 +144,7 @@ void Popup::popup_centered_minsize(const Size2& p_minsize) { Control *c=get_child(i)->cast_to<Control>(); if (!c) continue; - if (c->is_hidden()) + if (!c->is_visible()) continue; Size2 minsize = c->get_combined_minimum_size(); @@ -283,7 +283,7 @@ Popup::Popup() { String Popup::get_configuration_warning() const { - if (is_visible()) { + if (is_visible_in_tree()) { return TTR("Popups will hide by default unless you call popup() or any of the popup*() functions. Making them visible for editing is fine though, but they will hide upon running."); } diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index 9eaf393a21..65e7c3ab39 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -136,7 +136,7 @@ int PopupMenu::_get_mouse_over(const Point2& p_over) const { Ref<Font> font = get_font("font"); int vseparation = get_constant("vseparation"); -// int hseparation = get_constant("hseparation"); + //int hseparation = get_constant("hseparation"); float font_h=font->get_height(); @@ -174,7 +174,7 @@ void PopupMenu::_activate_submenu(int over) { Popup *pm = n->cast_to<Popup>(); ERR_EXPLAIN("item subnode is not a Popup: "+items[over].submenu); ERR_FAIL_COND(!pm); - if (pm->is_visible()) + if (pm->is_visible_in_tree()) return; //already visible! diff --git a/scene/gui/progress_bar.cpp b/scene/gui/progress_bar.cpp index ee9369fb3a..0f99d4f19e 100644 --- a/scene/gui/progress_bar.cpp +++ b/scene/gui/progress_bar.cpp @@ -53,7 +53,7 @@ void ProgressBar::_notification(int p_what) { Color font_color=get_color("font_color"); draw_style_box(bg,Rect2(Point2(),get_size())); - float r = get_unit_value(); + float r = get_as_ratio(); int mp = fg->get_minimum_size().width; int p = r*get_size().width-mp; if (p>0) { @@ -62,7 +62,7 @@ void ProgressBar::_notification(int p_what) { } if (percent_visible) { - String txt=itos(int(get_unit_value()*100))+"%"; + String txt=itos(int(get_as_ratio()*100))+"%"; font->draw_halign(get_canvas_item(),Point2(0,font->get_ascent()+(get_size().height-font->get_height())/2),HALIGN_CENTER,get_size().width,txt,font_color); } } diff --git a/scene/gui/range.cpp b/scene/gui/range.cpp index 2f37ed0341..d5c1034c9c 100644 --- a/scene/gui/range.cpp +++ b/scene/gui/range.cpp @@ -135,11 +135,11 @@ double Range::get_page() const { return shared->page; } -void Range::set_unit_value(double p_value) { +void Range::set_as_ratio(double p_value) { double v; - if (shared->exp_unit_value && get_min()>0) { + if (shared->exp_ratio && get_min()>0) { double exp_min = Math::log(get_min())/Math::log(2); double exp_max = Math::log(get_max())/Math::log(2); @@ -156,9 +156,9 @@ void Range::set_unit_value(double p_value) { } set_value( v ); } -double Range::get_unit_value() const { +double Range::get_as_ratio() const { - if (shared->exp_unit_value && get_min()>0) { + if (shared->exp_ratio && get_min()>0) { double exp_min = Math::log(get_min())/Math::log(2); double exp_max = Math::log(get_max())/Math::log(2); @@ -227,17 +227,17 @@ void Range::_bind_methods() { ClassDB::bind_method(_MD("get_max"),&Range::get_max); ClassDB::bind_method(_MD("get_step"),&Range::get_step); ClassDB::bind_method(_MD("get_page"),&Range::get_page); - ClassDB::bind_method(_MD("get_unit_value"),&Range::get_unit_value); + ClassDB::bind_method(_MD("get_as_ratio"),&Range::get_as_ratio); ClassDB::bind_method(_MD("set_value","value"),&Range::set_value); ClassDB::bind_method(_MD("set_min","minimum"),&Range::set_min); ClassDB::bind_method(_MD("set_max","maximum"),&Range::set_max); ClassDB::bind_method(_MD("set_step","step"),&Range::set_step); ClassDB::bind_method(_MD("set_page","pagesize"),&Range::set_page); - ClassDB::bind_method(_MD("set_unit_value","value"),&Range::set_unit_value); - ClassDB::bind_method(_MD("set_rounded_values","enabled"),&Range::set_rounded_values); - ClassDB::bind_method(_MD("is_rounded_values"),&Range::is_rounded_values); - ClassDB::bind_method(_MD("set_exp_unit_value","enabled"),&Range::set_exp_unit_value); - ClassDB::bind_method(_MD("is_unit_value_exp"),&Range::is_unit_value_exp); + ClassDB::bind_method(_MD("set_as_ratio","value"),&Range::set_as_ratio); + ClassDB::bind_method(_MD("set_use_rounded_values","enabled"),&Range::set_use_rounded_values); + ClassDB::bind_method(_MD("is_using_rounded_values"),&Range::is_using_rounded_values); + ClassDB::bind_method(_MD("set_exp_ratio","enabled"),&Range::set_exp_ratio); + ClassDB::bind_method(_MD("is_ratio_exp"),&Range::is_ratio_exp); ClassDB::bind_method(_MD("share","with"),&Range::_share); ClassDB::bind_method(_MD("unshare"),&Range::unshare); @@ -250,29 +250,29 @@ void Range::_bind_methods() { ADD_PROPERTY( PropertyInfo( Variant::REAL, "step" ), _SCS("set_step"), _SCS("get_step") ); ADD_PROPERTY( PropertyInfo( Variant::REAL, "page" ), _SCS("set_page"), _SCS("get_page") ); ADD_PROPERTY( PropertyInfo( Variant::REAL, "value" ), _SCS("set_value"), _SCS("get_value") ); - ADD_PROPERTY( PropertyInfo( Variant::BOOL, "exp_edit" ), _SCS("set_exp_unit_value"), _SCS("is_unit_value_exp") ); - ADD_PROPERTY( PropertyInfo( Variant::BOOL, "rounded" ), _SCS("set_rounded_values"), _SCS("is_rounded_values") ); + ADD_PROPERTY( PropertyInfo( Variant::BOOL, "exp_edit" ), _SCS("set_exp_ratio"), _SCS("is_ratio_exp") ); + ADD_PROPERTY( PropertyInfo( Variant::BOOL, "rounded" ), _SCS("set_use_rounded_values"), _SCS("is_using_rounded_values") ); } -void Range::set_rounded_values(bool p_enable) { +void Range::set_use_rounded_values(bool p_enable) { _rounded_values = p_enable; } -bool Range::is_rounded_values() const { +bool Range::is_using_rounded_values() const { return _rounded_values; } -void Range::set_exp_unit_value(bool p_enable) { +void Range::set_exp_ratio(bool p_enable) { - shared->exp_unit_value=p_enable; + shared->exp_ratio=p_enable; } -bool Range::is_unit_value_exp() const { +bool Range::is_ratio_exp() const { - return shared->exp_unit_value; + return shared->exp_ratio; } @@ -285,7 +285,7 @@ Range::Range() shared->step=1; shared->page=0; shared->owners.insert(this); - shared->exp_unit_value=false; + shared->exp_ratio=false; _rounded_values = false; } diff --git a/scene/gui/range.h b/scene/gui/range.h index 0872254fff..5f274a6901 100644 --- a/scene/gui/range.h +++ b/scene/gui/range.h @@ -41,7 +41,7 @@ class Range : public Control { struct Shared { double val,min,max; double step,page; - bool exp_unit_value; + bool exp_ratio; Set<Range*> owners; void emit_value_changed(); void emit_changed(const char *p_what=""); @@ -71,20 +71,20 @@ public: void set_max(double p_max); void set_step(double p_step); void set_page(double p_page); - void set_unit_value(double p_value); + void set_as_ratio(double p_value); double get_value() const; double get_min() const; double get_max() const; double get_step() const; double get_page() const; - double get_unit_value() const; + double get_as_ratio() const; - void set_rounded_values(bool p_enable); - bool is_rounded_values() const; + void set_use_rounded_values(bool p_enable); + bool is_using_rounded_values() const; - void set_exp_unit_value(bool p_enable); - bool is_unit_value_exp() const; + void set_exp_ratio(bool p_enable); + bool is_ratio_exp() const; void share(Range *p_range); void unshare(); diff --git a/scene/gui/reference_frame.cpp b/scene/gui/reference_rect.cpp index 37bc3ae6fb..ff4cdf04fd 100644 --- a/scene/gui/reference_frame.cpp +++ b/scene/gui/reference_rect.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* reference_frame.cpp */ +/* reference_rect.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -26,9 +26,9 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "reference_frame.h" +#include "reference_rect.h" -void ReferenceFrame::_notification(int p_what) { +void ReferenceRect::_notification(int p_what) { if (p_what==NOTIFICATION_DRAW) { @@ -39,6 +39,6 @@ void ReferenceFrame::_notification(int p_what) { } } -ReferenceFrame::ReferenceFrame() +ReferenceRect::ReferenceRect() { } diff --git a/scene/gui/reference_frame.h b/scene/gui/reference_rect.h index 8b4a16cb43..be493f346c 100644 --- a/scene/gui/reference_frame.h +++ b/scene/gui/reference_rect.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* reference_frame.h */ +/* reference_rect.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -26,20 +26,20 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef REFERENCE_FRAME_H -#define REFERENCE_FRAME_H +#ifndef REFERENCE_RECT_H +#define REFERENCE_RECT_H #include "scene/gui/control.h" -class ReferenceFrame : public Control { +class ReferenceRect : public Control { - GDCLASS( ReferenceFrame, Control); + GDCLASS( ReferenceRect, Control); protected: void _notification(int p_what); public: - ReferenceFrame(); + ReferenceRect(); }; -#endif // REFERENCE_FRAME_H +#endif // REFERENCE_RECT_H diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 790b7500ea..434fb36e24 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -852,32 +852,32 @@ void RichTextLabel::_gui_input(InputEvent p_event) { switch(k.scancode) { case KEY_PAGEUP: { - if (vscroll->is_visible()) + if (vscroll->is_visible_in_tree()) vscroll->set_value( vscroll->get_value() - vscroll->get_page() ); } break; case KEY_PAGEDOWN: { - if (vscroll->is_visible()) + if (vscroll->is_visible_in_tree()) vscroll->set_value( vscroll->get_value() + vscroll->get_page() ); } break; case KEY_UP: { - if (vscroll->is_visible()) + if (vscroll->is_visible_in_tree()) vscroll->set_value( vscroll->get_value() - get_font("normal_font")->get_height() ); } break; case KEY_DOWN: { - if (vscroll->is_visible()) + if (vscroll->is_visible_in_tree()) vscroll->set_value( vscroll->get_value() + get_font("normal_font")->get_height() ); } break; case KEY_HOME: { - if (vscroll->is_visible()) + if (vscroll->is_visible_in_tree()) vscroll->set_value( 0 ); } break; case KEY_END: { - if (vscroll->is_visible()) + if (vscroll->is_visible_in_tree()) vscroll->set_value( vscroll->get_max() ); } break; case KEY_INSERT: @@ -1429,7 +1429,7 @@ bool RichTextLabel::is_scroll_active() const { void RichTextLabel::set_scroll_follow(bool p_follow) { scroll_follow=p_follow; - if (!vscroll->is_visible() || vscroll->get_value()>=(vscroll->get_max()-vscroll->get_page())) + if (!vscroll->is_visible_in_tree() || vscroll->get_value()>=(vscroll->get_max()-vscroll->get_page())) scroll_following=true; } diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp index 2c44e51e5e..fc406ff0f5 100644 --- a/scene/gui/scroll_bar.cpp +++ b/scene/gui/scroll_bar.cpp @@ -51,9 +51,11 @@ void ScrollBar::_gui_input(InputEvent p_event) { if (b.button_index==5 && b.pressed) { - //if (orientation==VERTICAL) - // set_val( get_val() + get_page() / 4.0 ); - //else + /* + if (orientation==VERTICAL) + set_val( get_val() + get_page() / 4.0 ); + else + */ set_value( get_value() + get_page() / 4.0 ); accept_event(); @@ -61,9 +63,11 @@ void ScrollBar::_gui_input(InputEvent p_event) { if (b.button_index==4 && b.pressed) { - //if (orientation==HORIZONTAL) - // set_val( get_val() - get_page() / 4.0 ); - //else + /* + if (orientation==HORIZONTAL) + set_val( get_val() - get_page() / 4.0 ); + else + */ set_value( get_value() - get_page() / 4.0 ); accept_event(); } @@ -112,7 +116,7 @@ void ScrollBar::_gui_input(InputEvent p_event) { drag.active=true; drag.pos_at_click=grabber_ofs+ofs; - drag.value_at_click=get_unit_value(); + drag.value_at_click=get_as_ratio(); update(); } else { @@ -145,7 +149,7 @@ void ScrollBar::_gui_input(InputEvent p_event) { double diff = (ofs-drag.pos_at_click) / get_area_size(); - set_unit_value( drag.value_at_click + diff ); + set_as_ratio( drag.value_at_click + diff ); } else { @@ -425,8 +429,10 @@ double ScrollBar::get_grabber_size() const { return 0; float page = (get_page()>0)? get_page() : 0; -// if (grabber_range < get_step()) -// grabber_range=get_step(); + /* + if (grabber_range < get_step()) + grabber_range=get_step(); + */ double area_size=get_area_size(); double grabber_size = page / range * area_size; @@ -497,7 +503,7 @@ double ScrollBar::get_click_pos(const Point2& p_pos) const { double ScrollBar::get_grabber_offset() const { - return (get_area_size()) * get_unit_value(); + return (get_area_size()) * get_as_ratio(); } @@ -620,12 +626,16 @@ void ScrollBar::_drag_slave_input(const InputEvent& p_input) { if (orientation==HORIZONTAL) set_value(diff.x); - //else - // drag_slave_accum.x=0; + /* + else + drag_slave_accum.x=0; + */ if (orientation==VERTICAL) set_value(diff.y); - //else - // drag_slave_accum.y=0; + /* + else + drag_slave_accum.y=0; + */ time_since_motion=0; } diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp index 43c214b0be..b3ed9b209a 100644 --- a/scene/gui/scroll_container.cpp +++ b/scene/gui/scroll_container.cpp @@ -59,10 +59,10 @@ Size2 ScrollContainer::get_minimum_size() const { } } - if (h_scroll->is_visible()) { + if (h_scroll->is_visible_in_tree()) { min_size.y+=h_scroll->get_minimum_size().y; } - if (v_scroll->is_visible()) { + if (v_scroll->is_visible_in_tree()) { min_size.x+=v_scroll->get_minimum_size().x; } return min_size; @@ -89,19 +89,19 @@ void ScrollContainer::_gui_input(const InputEvent& p_gui_input) { const InputEventMouseButton &mb=p_gui_input.mouse_button; if (mb.button_index==BUTTON_WHEEL_UP && mb.pressed) { - if (h_scroll->is_visible() && !v_scroll->is_visible()){ + if (h_scroll->is_visible_in_tree() && !v_scroll->is_visible_in_tree()){ // only horizontal is enabled, scroll horizontally h_scroll->set_value( h_scroll->get_value()-h_scroll->get_page()/8 ); - } else if (v_scroll->is_visible()) { + } else if (v_scroll->is_visible_in_tree()) { v_scroll->set_value( v_scroll->get_value()-v_scroll->get_page()/8 ); } } if (mb.button_index==BUTTON_WHEEL_DOWN && mb.pressed) { - if (h_scroll->is_visible() && !v_scroll->is_visible()){ + if (h_scroll->is_visible_in_tree() && !v_scroll->is_visible_in_tree()){ // only horizontal is enabled, scroll horizontally h_scroll->set_value( h_scroll->get_value()+h_scroll->get_page()/8 ); - } else if (v_scroll->is_visible()) { + } else if (v_scroll->is_visible_in_tree()) { v_scroll->set_value( v_scroll->get_value()+v_scroll->get_page()/8 ); } } @@ -216,10 +216,10 @@ void ScrollContainer::_notification(int p_what) { child_max_size = Size2(0, 0); Size2 size = get_size(); - if (h_scroll->is_visible()) + if (h_scroll->is_visible_in_tree()) size.y-=h_scroll->get_minimum_size().y; - if (v_scroll->is_visible()) + if (v_scroll->is_visible_in_tree()) size.x-=h_scroll->get_minimum_size().x; for(int i=0;i<get_child_count();i++) { @@ -236,14 +236,14 @@ void ScrollContainer::_notification(int p_what) { child_max_size.y = MAX(child_max_size.y, minsize.y); Rect2 r = Rect2(-scroll,minsize); - if (!(scroll_h || h_scroll->is_visible())) { + if (!(scroll_h || h_scroll->is_visible_in_tree())) { r.pos.x=0; if (c->get_h_size_flags()&SIZE_EXPAND) r.size.width=MAX(size.width,minsize.width); else r.size.width=minsize.width; } - if (!(scroll_v || v_scroll->is_visible())) { + if (!(scroll_v || v_scroll->is_visible_in_tree())) { r.pos.y=0; r.size.height=size.height; if (c->get_v_size_flags()&SIZE_EXPAND) diff --git a/scene/gui/slider.cpp b/scene/gui/slider.cpp index dacfc644ee..ad6e8786d7 100644 --- a/scene/gui/slider.cpp +++ b/scene/gui/slider.cpp @@ -53,11 +53,11 @@ void Slider::_gui_input(InputEvent p_event) { double grab_height = (double)grabber->get_size().height; double max = orientation==VERTICAL ? get_size().height - grab_height : get_size().width - grab_width; if (orientation==VERTICAL) - set_unit_value( 1 - (((double)grab.pos - (grab_height / 2.0)) / max) ); + set_as_ratio( 1 - (((double)grab.pos - (grab_height / 2.0)) / max) ); else - set_unit_value(((double)grab.pos - (grab_width/2.0)) / max); + set_as_ratio(((double)grab.pos - (grab_width/2.0)) / max); grab.active=true; - grab.uvalue=get_unit_value(); + grab.uvalue=get_as_ratio(); } else { grab.active=false; } @@ -81,7 +81,7 @@ void Slider::_gui_input(InputEvent p_event) { if (areasize<=0) return; float umotion = motion / float(areasize); - set_unit_value( grab.uvalue + umotion ); + set_as_ratio( grab.uvalue + umotion ); } } else { @@ -164,8 +164,10 @@ void Slider::_notification(int p_what) { if (orientation==VERTICAL) { style->draw(ci,Rect2i(Point2i(),Size2i(style->get_minimum_size().width+style->get_center_size().width,size.height))); - //if (mouse_inside||has_focus()) - // focus->draw(ci,Rect2i(Point2i(),Size2i(style->get_minimum_size().width+style->get_center_size().width,size.height))); + /* + if (mouse_inside||has_focus()) + focus->draw(ci,Rect2i(Point2i(),Size2i(style->get_minimum_size().width+style->get_center_size().width,size.height))); + */ float areasize = size.height - grabber->get_size().height; if (ticks>1) { int tickarea = size.height - tick->get_height(); @@ -176,11 +178,13 @@ void Slider::_notification(int p_what) { } } - grabber->draw(ci,Point2i(size.width/2-grabber->get_size().width/2,size.height - get_unit_value()*areasize - grabber->get_size().height)); + grabber->draw(ci,Point2i(size.width/2-grabber->get_size().width/2,size.height - get_as_ratio()*areasize - grabber->get_size().height)); } else { style->draw(ci,Rect2i(Point2i(),Size2i(size.width,style->get_minimum_size().height+style->get_center_size().height))); - //if (mouse_inside||has_focus()) - // focus->draw(ci,Rect2i(Point2i(),Size2i(size.width,style->get_minimum_size().height+style->get_center_size().height))); + /* + if (mouse_inside||has_focus()) + focus->draw(ci,Rect2i(Point2i(),Size2i(size.width,style->get_minimum_size().height+style->get_center_size().height))); + */ float areasize = size.width - grabber->get_size().width; if (ticks>1) { @@ -192,7 +196,7 @@ void Slider::_notification(int p_what) { } } - grabber->draw(ci,Point2i(get_unit_value()*areasize,size.height/2-grabber->get_size().height/2)); + grabber->draw(ci,Point2i(get_as_ratio()*areasize,size.height/2-grabber->get_size().height/2)); } } break; diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp index 070f9fc72e..ec6be0d19d 100644 --- a/scene/gui/spin_box.cpp +++ b/scene/gui/spin_box.cpp @@ -49,8 +49,10 @@ void SpinBox::_value_changed(double) { void SpinBox::_text_entered(const String& p_string) { - //if (!p_string.is_numeric()) - // return; + /* + if (!p_string.is_numeric()) + return; + */ String value = p_string; if (prefix!="" && p_string.begins_with(prefix)) value = p_string.substr(prefix.length(), p_string.length()-prefix.length()); diff --git a/scene/gui/split_container.cpp b/scene/gui/split_container.cpp index aae3b3fffa..a39ad2fe99 100644 --- a/scene/gui/split_container.cpp +++ b/scene/gui/split_container.cpp @@ -47,7 +47,7 @@ Control *SplitContainer::_getch(int p_idx) const { for(int i=0;i<get_child_count();i++) { Control *c=get_child(i)->cast_to<Control>(); - if (!c || !c->is_visible()) + if (!c || !c->is_visible_in_tree()) continue; if (c->is_set_as_toplevel()) continue; diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index 11045eaafd..52d26b29de 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -680,7 +680,7 @@ Size2 TabContainer::get_minimum_size() const { if (c->is_set_as_toplevel()) continue; - if (!c->is_visible()) + if (!c->is_visible_in_tree()) continue; Size2 cms = c->get_combined_minimum_size(); diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index cbc0c283de..8efff21fc9 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -3036,7 +3036,7 @@ void TextEdit::adjust_viewport_to_cursor() { cursor.line_ofs=cursor.line; int visible_width=cache.size.width-cache.style_normal->get_minimum_size().width-cache.line_number_w-cache.breakpoint_gutter_width; - if (v_scroll->is_visible()) + if (v_scroll->is_visible_in_tree()) visible_width-=v_scroll->get_combined_minimum_size().width; visible_width-=20; // give it a little more space @@ -3044,7 +3044,7 @@ void TextEdit::adjust_viewport_to_cursor() { //printf("rowofs %i, visrows %i, cursor.line %i\n",cursor.line_ofs,get_visible_rows(),cursor.line); int visible_rows = get_visible_rows(); - if (h_scroll->is_visible()) + if (h_scroll->is_visible_in_tree()) visible_rows-=((h_scroll->get_combined_minimum_size().height-1)/get_row_height()); if (cursor.line>=(cursor.line_ofs+visible_rows)) @@ -3078,12 +3078,12 @@ void TextEdit::center_viewport_to_cursor() { cursor.line_ofs=cursor.line; int visible_width=cache.size.width-cache.style_normal->get_minimum_size().width-cache.line_number_w-cache.breakpoint_gutter_width; - if (v_scroll->is_visible()) + if (v_scroll->is_visible_in_tree()) visible_width-=v_scroll->get_combined_minimum_size().width; visible_width-=20; // give it a little more space int visible_rows = get_visible_rows(); - if (h_scroll->is_visible()) + if (h_scroll->is_visible_in_tree()) visible_rows-=((h_scroll->get_combined_minimum_size().height-1)/get_row_height()); int max_ofs = text.size()-(scroll_past_end_of_file_enabled?1:visible_rows); @@ -3205,9 +3205,9 @@ void TextEdit::_scroll_moved(double p_to_val) { if (updating_scrolls) return; - if (h_scroll->is_visible()) + if (h_scroll->is_visible_in_tree()) cursor.x_ofs=h_scroll->get_value(); - if (v_scroll->is_visible()) + if (v_scroll->is_visible_in_tree()) cursor.line_ofs=v_scroll->get_value(); update(); } @@ -3458,7 +3458,7 @@ void TextEdit::_reset_caret_blink_timer() { void TextEdit::_toggle_draw_caret() { draw_caret = !draw_caret; - if (is_visible() && has_focus() && window_has_focus) { + if (is_visible_in_tree() && has_focus() && window_has_focus) { update(); } } @@ -4357,7 +4357,7 @@ void TextEdit::_update_completion_candidates() { if (completion_options.size()==1) { //one option to complete, just complete it automagically _confirm_completion(); - // insert_text_at_cursor(completion_options[0].substr(s.length(),completion_options[0].length()-s.length())); + //insert_text_at_cursor(completion_options[0].substr(s.length(),completion_options[0].length()-s.length())); _cancel_completion(); return; @@ -4732,8 +4732,8 @@ TextEdit::TextEdit() { tab_size=4; text.set_tab_size(tab_size); text.clear(); - // text.insert(1,"Mongolia.."); - // text.insert(2,"PAIS GENEROSO!!"); + //text.insert(1,"Mongolia.."); + //text.insert(2,"PAIS GENEROSO!!"); text.set_color_regions(&color_regions); h_scroll = memnew( HScrollBar ); diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index c7467f9b13..6113fd72c2 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -294,7 +294,7 @@ class TextEdit : public Control { void _scroll_lines_up(); void _scroll_lines_down(); -// void mouse_motion(const Point& p_pos, const Point& p_rel, int p_button_mask); + //void mouse_motion(const Point& p_pos, const Point& p_rel, int p_button_mask); Size2 get_minimum_size() const; int get_row_height() const; diff --git a/scene/gui/texture_button.cpp b/scene/gui/texture_button.cpp index 83cd853572..03e37e9d9f 100644 --- a/scene/gui/texture_button.cpp +++ b/scene/gui/texture_button.cpp @@ -120,13 +120,13 @@ void TextureButton::_notification(int p_what) { if (texdraw.is_valid()) { Rect2 drect(Point2(),texdraw->get_size()*scale); - draw_texture_rect(texdraw,drect,false,modulate); + draw_texture_rect(texdraw,drect,false); } if (has_focus() && focused.is_valid()) { Rect2 drect(Point2(),focused->get_size()*scale); - draw_texture_rect(focused,drect,false,modulate); + draw_texture_rect(focused,drect,false); }; @@ -143,7 +143,6 @@ void TextureButton::_bind_methods() { ClassDB::bind_method(_MD("set_focused_texture","texture:Texture"),&TextureButton::set_focused_texture); ClassDB::bind_method(_MD("set_click_mask","mask:BitMap"),&TextureButton::set_click_mask); ClassDB::bind_method(_MD("set_texture_scale","scale"),&TextureButton::set_texture_scale); - ClassDB::bind_method(_MD("set_modulate","color"),&TextureButton::set_modulate); ClassDB::bind_method(_MD("get_normal_texture:Texture"),&TextureButton::get_normal_texture); ClassDB::bind_method(_MD("get_pressed_texture:Texture"),&TextureButton::get_pressed_texture); @@ -152,7 +151,6 @@ void TextureButton::_bind_methods() { ClassDB::bind_method(_MD("get_focused_texture:Texture"),&TextureButton::get_focused_texture); ClassDB::bind_method(_MD("get_click_mask:BitMap"),&TextureButton::get_click_mask); ClassDB::bind_method(_MD("get_texture_scale"),&TextureButton::get_texture_scale); - ClassDB::bind_method(_MD("get_modulate"),&TextureButton::get_modulate); ADD_GROUP("Textures","texture_"); ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"texture_normal",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_normal_texture"), _SCS("get_normal_texture")); @@ -241,17 +239,7 @@ Size2 TextureButton::get_texture_scale() const{ return scale; } -void TextureButton::set_modulate(const Color& p_modulate) { - modulate=p_modulate; - update(); -} - -Color TextureButton::get_modulate() const { - return modulate; -} - - TextureButton::TextureButton() { scale=Size2(1.0, 1.0); - modulate=Color(1,1,1); + } diff --git a/scene/gui/texture_button.h b/scene/gui/texture_button.h index b6cb531c71..ef4d4d5b5b 100644 --- a/scene/gui/texture_button.h +++ b/scene/gui/texture_button.h @@ -42,8 +42,6 @@ class TextureButton : public BaseButton { Ref<Texture> focused; Ref<BitMap> click_mask; Size2 scale; - Color modulate; - protected: @@ -71,9 +69,6 @@ public: void set_texture_scale(Size2 p_scale); Size2 get_texture_scale() const; - void set_modulate(const Color& p_modulate); - Color get_modulate() const; - TextureButton(); }; diff --git a/scene/gui/texture_progress.cpp b/scene/gui/texture_progress.cpp index df0512fc96..f6a33b5643 100644 --- a/scene/gui/texture_progress.cpp +++ b/scene/gui/texture_progress.cpp @@ -135,24 +135,24 @@ void TextureProgress::_notification(int p_what){ Size2 s = progress->get_size(); switch (mode) { case FILL_LEFT_TO_RIGHT: { - Rect2 region=Rect2(Point2(),Size2(s.x*get_unit_value(),s.y)); + Rect2 region=Rect2(Point2(),Size2(s.x*get_as_ratio(),s.y)); draw_texture_rect_region(progress,region,region); } break; case FILL_RIGHT_TO_LEFT: { - Rect2 region=Rect2(Point2(s.x-s.x*get_unit_value(),0),Size2(s.x*get_unit_value(),s.y)); + Rect2 region=Rect2(Point2(s.x-s.x*get_as_ratio(),0),Size2(s.x*get_as_ratio(),s.y)); draw_texture_rect_region(progress,region,region); } break; case FILL_TOP_TO_BOTTOM: { - Rect2 region=Rect2(Point2(),Size2(s.x,s.y*get_unit_value())); + Rect2 region=Rect2(Point2(),Size2(s.x,s.y*get_as_ratio())); draw_texture_rect_region(progress,region,region); } break; case FILL_BOTTOM_TO_TOP: { - Rect2 region=Rect2(Point2(0,s.y-s.y*get_unit_value()),Size2(s.x,s.y*get_unit_value())); + Rect2 region=Rect2(Point2(0,s.y-s.y*get_as_ratio()),Size2(s.x,s.y*get_as_ratio())); draw_texture_rect_region(progress,region,region); } break; case FILL_CLOCKWISE: case FILL_COUNTER_CLOCKWISE: { - float val=get_unit_value()*rad_max_degrees/360; + float val=get_as_ratio()*rad_max_degrees/360; if (val==1) { Rect2 region=Rect2(Point2(),s); draw_texture_rect_region(progress,region,region); @@ -192,7 +192,7 @@ void TextureProgress::_notification(int p_what){ } } break; default: - draw_texture_rect_region(progress,Rect2(Point2(),Size2(s.x*get_unit_value(),s.y)),Rect2(Point2(),Size2(s.x*get_unit_value(),s.y))); + draw_texture_rect_region(progress,Rect2(Point2(),Size2(s.x*get_as_ratio(),s.y)),Rect2(Point2(),Size2(s.x*get_as_ratio(),s.y))); } diff --git a/scene/gui/texture_frame.cpp b/scene/gui/texture_rect.cpp index bfa72ef067..cbb077ef5d 100644 --- a/scene/gui/texture_frame.cpp +++ b/scene/gui/texture_rect.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* texture_frame.cpp */ +/* texture_rect.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -26,10 +26,10 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "texture_frame.h" +#include "texture_rect.h" #include "servers/visual_server.h" -void TextureFrame::_notification(int p_what) { +void TextureRect::_notification(int p_what) { if (p_what==NOTIFICATION_DRAW) { @@ -85,22 +85,22 @@ void TextureFrame::_notification(int p_what) { } } -Size2 TextureFrame::get_minimum_size() const { +Size2 TextureRect::get_minimum_size() const { if (!expand && !texture.is_null()) return texture->get_size(); else return Size2(); } -void TextureFrame::_bind_methods() { +void TextureRect::_bind_methods() { - ClassDB::bind_method(_MD("set_texture","texture"), & TextureFrame::set_texture ); - ClassDB::bind_method(_MD("get_texture"), & TextureFrame::get_texture ); - ClassDB::bind_method(_MD("set_expand","enable"), & TextureFrame::set_expand ); - ClassDB::bind_method(_MD("has_expand"), & TextureFrame::has_expand ); - ClassDB::bind_method(_MD("set_stretch_mode","stretch_mode"), & TextureFrame::set_stretch_mode ); - ClassDB::bind_method(_MD("get_stretch_mode"), & TextureFrame::get_stretch_mode ); + ClassDB::bind_method(_MD("set_texture","texture"), & TextureRect::set_texture ); + ClassDB::bind_method(_MD("get_texture"), & TextureRect::get_texture ); + ClassDB::bind_method(_MD("set_expand","enable"), & TextureRect::set_expand ); + ClassDB::bind_method(_MD("has_expand"), & TextureRect::has_expand ); + ClassDB::bind_method(_MD("set_stretch_mode","stretch_mode"), & TextureRect::set_stretch_mode ); + ClassDB::bind_method(_MD("get_stretch_mode"), & TextureRect::get_stretch_mode ); ADD_PROPERTYNZ( PropertyInfo( Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), _SCS("set_texture"),_SCS("get_texture") ); ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "expand" ), _SCS("set_expand"),_SCS("has_expand") ); @@ -117,44 +117,46 @@ void TextureFrame::_bind_methods() { } -void TextureFrame::set_texture(const Ref<Texture>& p_tex) { +void TextureRect::set_texture(const Ref<Texture>& p_tex) { texture=p_tex; update(); - //if (texture.is_valid()) - // texture->set_flags(texture->get_flags()&(~Texture::FLAG_REPEAT)); //remove repeat from texture, it looks bad in sprites + /* + if (texture.is_valid()) + texture->set_flags(texture->get_flags()&(~Texture::FLAG_REPEAT)); //remove repeat from texture, it looks bad in sprites + */ minimum_size_changed(); } -Ref<Texture> TextureFrame::get_texture() const { +Ref<Texture> TextureRect::get_texture() const { return texture; } -void TextureFrame::set_expand(bool p_expand) { +void TextureRect::set_expand(bool p_expand) { expand=p_expand; update(); minimum_size_changed(); } -bool TextureFrame::has_expand() const { +bool TextureRect::has_expand() const { return expand; } -void TextureFrame::set_stretch_mode(StretchMode p_mode) { +void TextureRect::set_stretch_mode(StretchMode p_mode) { stretch_mode=p_mode; update(); } -TextureFrame::StretchMode TextureFrame::get_stretch_mode() const { +TextureRect::StretchMode TextureRect::get_stretch_mode() const { return stretch_mode; } -TextureFrame::TextureFrame() { +TextureRect::TextureRect() { expand=false; @@ -163,7 +165,7 @@ TextureFrame::TextureFrame() { } -TextureFrame::~TextureFrame() +TextureRect::~TextureRect() { } diff --git a/scene/gui/texture_frame.h b/scene/gui/texture_rect.h index c311748708..e95d742759 100644 --- a/scene/gui/texture_frame.h +++ b/scene/gui/texture_rect.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* texture_frame.h */ +/* texture_rect.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -33,9 +33,9 @@ /** @author Juan Linietsky <reduzio@gmail.com> */ -class TextureFrame : public Control { +class TextureRect : public Control { - GDCLASS(TextureFrame,Control); + GDCLASS(TextureRect,Control); public: enum StretchMode { STRETCH_SCALE_ON_EXPAND, //default, for backwards compatibility @@ -69,10 +69,10 @@ public: void set_stretch_mode(StretchMode p_mode); StretchMode get_stretch_mode() const; - TextureFrame(); - ~TextureFrame(); + TextureRect(); + ~TextureRect(); }; -VARIANT_ENUM_CAST( TextureFrame::StretchMode ); +VARIANT_ENUM_CAST( TextureRect::StretchMode ); #endif // TEXTURE_FRAME_H diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 9f5b9f710d..58c829690f 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -949,8 +949,10 @@ void Tree::draw_item_rect(const TreeItem::Cell& p_cell,const Rect2i& p_rect,cons } -// if (p_tool) -// rect.size.x-=Math::floor(rect.size.y/2); + /* + if (p_tool) + rect.size.x-=Math::floor(rect.size.y/2); + */ Ref<Font> font = cache.font; @@ -1029,7 +1031,7 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2& } //draw separation. -// if (p_item->get_parent()!=root || !hide_root) + //if (p_item->get_parent()!=root || !hide_root) Ref<Font> font = cache.font; @@ -1115,7 +1117,7 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2& } else { cache.selected->draw(ci,r ); } - if (text_editor->is_visible()){ + if (text_editor->is_visible_in_tree()){ text_editor->set_pos(get_global_pos() + r.pos); } } @@ -1262,7 +1264,7 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2& } break; case TreeItem::CELL_MODE_CUSTOM: { - // int option = (int)p_item->cells[i].val; + //int option = (int)p_item->cells[i].val; @@ -1414,8 +1416,10 @@ void Tree::select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_c emit_signal("item_selected"); emitted_row=true; } - //if (p_col==i) - // p_current->selected_signal.call(p_col); + /* + if (p_col==i) + p_current->selected_signal.call(p_col); + */ } else if (c.selected) { @@ -1672,9 +1676,11 @@ int Tree::propagate_mouse_event(const Point2i &p_pos,int x_ofs,int y_ofs,bool p_ } } - //if (!c.selected && select_mode==SELECT_MULTI) { - // emit_signal("multi_selected",p_item,col,true); - //} + /* + if (!c.selected && select_mode==SELECT_MULTI) { + emit_signal("multi_selected",p_item,col,true); + } + */ update(); } @@ -1997,7 +2003,7 @@ void Tree::_gui_input(InputEvent p_event) { } break; case KEY_LEFT: { -// TreeItem *next = NULL; + //TreeItem *next = NULL; if (!selected_item) break; if (select_mode==SELECT_ROW) @@ -2027,7 +2033,7 @@ void Tree::_gui_input(InputEvent p_event) { next=selected_item->get_next_visible(); -// if (diff < uint64_t(GLOBAL_DEF("gui/incr_search_max_interval_msec",2000))) { + //if (diff < uint64_t(GLOBAL_DEF("gui/incr_search_max_interval_msec",2000))) { if (last_keypress!=0) { //incr search next int col; @@ -2277,9 +2283,9 @@ void Tree::_gui_input(InputEvent p_event) { mpos.y-=_get_title_button_height(); if (mpos.y>=0) { - if (h_scroll->is_visible()) + if (h_scroll->is_visible_in_tree()) mpos.x+=h_scroll->get_value(); - if (v_scroll->is_visible()) + if (v_scroll->is_visible_in_tree()) mpos.y+=v_scroll->get_value(); int col,h,section; @@ -2470,7 +2476,7 @@ void Tree::_gui_input(InputEvent p_event) { if (!click_handled) { drag_speed=0; drag_accum=0; -// last_drag_accum=0; + //last_drag_accum=0; drag_from=v_scroll->get_value(); drag_touching=OS::get_singleton()->has_touchscreen_ui_hint(); drag_touching_deaccel=false; @@ -2567,7 +2573,7 @@ bool Tree::edit_selected() { value_editor->set_max( c.max ); value_editor->set_step( c.step ); value_editor->set_value( c.val ); - value_editor->set_exp_unit_value( c.expr ); + value_editor->set_exp_ratio( c.expr ); updating_value_editor=false; } @@ -2787,13 +2793,10 @@ void Tree::_notification(int p_what) { } int ofs=0; -// int from_y=exposed.pos.y+bg->get_margin(MARGIN_TOP); -// int size_y=exposed.size.height-bg->get_minimum_size().height; for (int i=0;i<(columns.size()-1-1);i++) { ofs+=get_column_width(i); - //get_painter()->draw_fill_rect( Point2(ofs+cache.hseparation/2, from_y), Size2( 1, size_y ),color( COLOR_TREE_GRID) ); } if (show_column_titles) { @@ -3016,8 +3019,10 @@ int Tree::get_edited_column() const { TreeItem* Tree::get_next_selected( TreeItem* p_item) { - //if (!p_item) - // return NULL; + /* + if (!p_item) + return NULL; + */ if (!root) return NULL; @@ -3069,7 +3074,7 @@ int Tree::get_column_width(int p_column) const { int expand_area=get_size().width-(bg->get_margin(MARGIN_LEFT)+bg->get_margin(MARGIN_RIGHT)); - if (v_scroll->is_visible()) + if (v_scroll->is_visible_in_tree()) expand_area-=v_scroll->get_combined_minimum_size().width; int expanding_columns=0; @@ -3254,9 +3259,9 @@ String Tree::get_column_title(int p_column) const { Point2 Tree::get_scroll() const { Point2 ofs; - if (h_scroll->is_visible()) + if (h_scroll->is_visible_in_tree()) ofs.x=h_scroll->get_value(); - if (v_scroll->is_visible()) + if (v_scroll->is_visible_in_tree()) ofs.y=v_scroll->get_value(); return ofs; @@ -3395,9 +3400,9 @@ int Tree::get_column_at_pos(const Point2& p_pos) const { if (pos.y<0) return -1; - if (h_scroll->is_visible()) + if (h_scroll->is_visible_in_tree()) pos.x+=h_scroll->get_value(); - if (v_scroll->is_visible()) + if (v_scroll->is_visible_in_tree()) pos.y+=v_scroll->get_value(); int col,h,section; @@ -3422,9 +3427,9 @@ int Tree::get_drop_section_at_pos(const Point2& p_pos) const { if (pos.y<0) return -100; - if (h_scroll->is_visible()) + if (h_scroll->is_visible_in_tree()) pos.x+=h_scroll->get_value(); - if (v_scroll->is_visible()) + if (v_scroll->is_visible_in_tree()) pos.y+=v_scroll->get_value(); int col,h,section; @@ -3449,9 +3454,9 @@ TreeItem* Tree::get_item_at_pos(const Point2& p_pos) const { if (pos.y<0) return NULL; - if (h_scroll->is_visible()) + if (h_scroll->is_visible_in_tree()) pos.x+=h_scroll->get_value(); - if (v_scroll->is_visible()) + if (v_scroll->is_visible_in_tree()) pos.y+=v_scroll->get_value(); int col,h,section; @@ -3477,9 +3482,9 @@ String Tree::get_tooltip(const Point2& p_pos) const { if (pos.y<0) return Control::get_tooltip(p_pos); - if (h_scroll->is_visible()) + if (h_scroll->is_visible_in_tree()) pos.x+=h_scroll->get_value(); - if (v_scroll->is_visible()) + if (v_scroll->is_visible_in_tree()) pos.y+=v_scroll->get_value(); int col,h,section; diff --git a/scene/gui/tree.h b/scene/gui/tree.h index 8327e356b3..d715ff4772 100644 --- a/scene/gui/tree.h +++ b/scene/gui/tree.h @@ -334,7 +334,7 @@ friend class TreeItem; int compute_item_height(TreeItem *p_item) const; int get_item_height(TreeItem *p_item) const; -// void draw_item_text(String p_text,const Ref<Texture>& p_icon,int p_icon_max_w,bool p_tool,Rect2i p_rect,const Color& p_color); + //void draw_item_text(String p_text,const Ref<Texture>& p_icon,int p_icon_max_w,bool p_tool,Rect2i p_rect,const Color& p_color); void draw_item_rect(const TreeItem::Cell& p_cell,const Rect2i& p_rect,const Color& p_color); int draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2& p_draw_size,TreeItem *p_item); void select_single_item(TreeItem *p_selected,TreeItem *p_current,int p_col,TreeItem *p_prev=NULL,bool *r_in_range=NULL,bool p_force_deselect=false); diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp index f7d2ad1c63..4c177ea53c 100644 --- a/scene/gui/video_player.cpp +++ b/scene/gui/video_player.cpp @@ -394,7 +394,7 @@ void VideoPlayer::_bind_methods() { ADD_PROPERTY( PropertyInfo(Variant::INT, "audio_track",PROPERTY_HINT_RANGE,"0,128,1"), _SCS("set_audio_track"), _SCS("get_audio_track") ); ADD_PROPERTY( PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE,"VideoStream"), _SCS("set_stream"), _SCS("get_stream") ); -// ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/loop"), _SCS("set_loop"), _SCS("has_loop") ); + //ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/loop"), _SCS("set_loop"), _SCS("has_loop") ); ADD_PROPERTY( PropertyInfo(Variant::REAL, "volume_db", PROPERTY_HINT_RANGE,"-80,24,0.01"), _SCS("set_volume_db"), _SCS("get_volume_db") ); ADD_PROPERTY( PropertyInfo(Variant::BOOL, "autoplay"), _SCS("set_autoplay"), _SCS("has_autoplay") ); ADD_PROPERTY( PropertyInfo(Variant::BOOL, "paused"), _SCS("set_paused"), _SCS("is_paused") ); diff --git a/scene/gui/viewport_container.cpp b/scene/gui/viewport_container.cpp index 37ecd3cb2f..9e89de66dd 100644 --- a/scene/gui/viewport_container.cpp +++ b/scene/gui/viewport_container.cpp @@ -63,7 +63,7 @@ void ViewportContainer::_notification(int p_what) { continue; - if (is_visible()) + if (is_visible_in_tree()) c->set_update_mode(Viewport::UPDATE_ALWAYS); else c->set_update_mode(Viewport::UPDATE_DISABLED); |