diff options
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/control.cpp | 50 | ||||
-rw-r--r-- | scene/gui/control.h | 2 | ||||
-rw-r--r-- | scene/gui/rich_text_label.cpp | 7 | ||||
-rw-r--r-- | scene/gui/split_container.cpp | 2 | ||||
-rw-r--r-- | scene/gui/split_container.h | 2 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 18 | ||||
-rw-r--r-- | scene/gui/text_edit.h | 2 |
7 files changed, 60 insertions, 23 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index dfad7d1432..666ac88055 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -437,11 +437,17 @@ void Control::_notification(int p_notification) { if (is_set_as_toplevel()) { data.SI=get_viewport()->_gui_add_subwindow_control(this); + + if (data.theme.is_null() && data.parent && data.parent->data.theme_owner) { + data.theme_owner=data.parent->data.theme_owner; + notification(NOTIFICATION_THEME_CHANGED); + } + } else { Node *parent=this; //meh - Node *parent_control=NULL; + Control *parent_control=NULL; bool subwindow=false; while(parent) { @@ -457,8 +463,9 @@ void Control::_notification(int p_notification) { break; } - if (parent->cast_to<Control>()) { - parent_control=parent->cast_to<Control>(); + parent_control=parent->cast_to<Control>(); + + if (parent_control) { break; } else if (ci) { @@ -470,6 +477,10 @@ void Control::_notification(int p_notification) { if (parent_control) { //do nothing, has a parent control + if (data.theme.is_null() && parent_control->data.theme_owner) { + data.theme_owner=parent_control->data.theme_owner; + notification(NOTIFICATION_THEME_CHANGED); + } } else if (subwindow) { //is a subwindow (process input before other controls for that canvas) data.SI=get_viewport()->_gui_add_subwindow_control(this); @@ -1829,18 +1840,29 @@ void Control::_modal_stack_remove() { } -void Control::_propagate_theme_changed(Control *p_owner) { +void Control::_propagate_theme_changed(CanvasItem *p_at,Control *p_owner) { + + Control *c = p_at->cast_to<Control>(); + + if (c && c!=p_owner && c->data.theme.is_valid()) // has a theme, this can't be propagated + return; + + for(int i=0;i<p_at->get_child_count();i++) { - for(int i=0;i<get_child_count();i++) { + CanvasItem *child = p_at->get_child(i)->cast_to<CanvasItem>(); + if (child) { + _propagate_theme_changed(child,p_owner); + } - Control *child = get_child(i)->cast_to<Control>(); - if (child && child->data.theme.is_null()) //has no theme, propagate - child->_propagate_theme_changed(p_owner); } - data.theme_owner=p_owner; - _notification(NOTIFICATION_THEME_CHANGED); - update(); + + if (c) { + + c->data.theme_owner=p_owner; + c->_notification(NOTIFICATION_THEME_CHANGED); + c->update(); + } } void Control::set_theme(const Ref<Theme>& p_theme) { @@ -1849,15 +1871,15 @@ void Control::set_theme(const Ref<Theme>& p_theme) { data.theme=p_theme; if (!p_theme.is_null()) { - _propagate_theme_changed(this); + _propagate_theme_changed(this,this); } else { Control *parent = get_parent()?get_parent()->cast_to<Control>():NULL; if (parent && parent->data.theme_owner) { - _propagate_theme_changed(parent->data.theme_owner); + _propagate_theme_changed(this,parent->data.theme_owner); } else { - _propagate_theme_changed(NULL); + _propagate_theme_changed(this,NULL); } } diff --git a/scene/gui/control.h b/scene/gui/control.h index 59704ae29b..69ee41f180 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -169,7 +169,7 @@ private: float _get_range(int p_idx) const; float _s2a(float p_val, AnchorType p_anchor,float p_range) const; float _a2s(float p_val, AnchorType p_anchor,float p_range) const; - void _propagate_theme_changed(Control *p_owner); + void _propagate_theme_changed(CanvasItem *p_at, Control *p_owner); void _change_notify_margins(); void _update_minimum_size(); diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 80949b4eb4..786ce27a0c 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -278,6 +278,11 @@ if (m_height > line_height) {\ if (c[end]=='\t') { cw=tab_size*font->get_char_size(' ').width; } + + if (end>0 && w+cw+begin > p_width ) { + break; //don't allow lines longer than assigned width + } + w+=cw; if (c[end]==' ') { @@ -340,10 +345,12 @@ if (m_height > line_height) {\ int cw=font->get_char_size(c[i],c[i+1]).x; + if (c[i]=='\t') { cw=tab_size*font->get_char_size(' ').width; } + if (p_click_pos.x-cw/2>p_ofs.x+align_ofs+pofs) { rchar=int((&c[i])-cf); diff --git a/scene/gui/split_container.cpp b/scene/gui/split_container.cpp index d22f6a0229..6b36a60ea2 100644 --- a/scene/gui/split_container.cpp +++ b/scene/gui/split_container.cpp @@ -351,7 +351,7 @@ void SplitContainer::_input_event(const InputEvent& p_event) { } -Control::CursorShape SplitContainer::get_cursor_shape(const Point2& p_pos) { +Control::CursorShape SplitContainer::get_cursor_shape(const Point2& p_pos) const { if (collapsed) return Control::get_cursor_shape(p_pos); diff --git a/scene/gui/split_container.h b/scene/gui/split_container.h index f721d16310..d2dc42165e 100644 --- a/scene/gui/split_container.h +++ b/scene/gui/split_container.h @@ -75,7 +75,7 @@ public: void set_dragger_visibility(DraggerVisibility p_visibility); DraggerVisibility get_dragger_visibility() const; - virtual CursorShape get_cursor_shape(const Point2& p_pos=Point2i()); + virtual CursorShape get_cursor_shape(const Point2& p_pos=Point2i()) const; virtual Size2 get_minimum_size() const; diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 3e374ef888..49d7527786 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -2892,7 +2892,7 @@ int TextEdit::get_char_count() { return totalsize; // omit last \n } -Size2 TextEdit::get_minimum_size() { +Size2 TextEdit::get_minimum_size() const { return cache.style_normal->get_minimum_size(); } @@ -3825,12 +3825,16 @@ void TextEdit::undo() { _do_text_op(op, true); current_op.version=op.prev_version; if(undo_stack_pos->get().chain_backward) { - do { + while(true) { + ERR_BREAK(!undo_stack_pos->prev()); undo_stack_pos = undo_stack_pos->prev(); op = undo_stack_pos->get(); _do_text_op(op, true); current_op.version = op.prev_version; - } while(!undo_stack_pos->get().chain_forward); + if (undo_stack_pos->get().chain_forward) { + break; + } + } } cursor_set_line(undo_stack_pos->get().from_line); @@ -3849,12 +3853,16 @@ void TextEdit::redo() { _do_text_op(op, false); current_op.version = op.version; if(undo_stack_pos->get().chain_forward) { - do { + + while(true) { + ERR_BREAK(!undo_stack_pos->next()); undo_stack_pos=undo_stack_pos->next(); op = undo_stack_pos->get(); _do_text_op(op, false); current_op.version = op.version; - } while(!undo_stack_pos->get().chain_backward); + if (undo_stack_pos->get().chain_backward) + break; + } } cursor_set_line(undo_stack_pos->get().to_line); cursor_set_column(undo_stack_pos->get().to_column); diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index 24a72afd48..22f024c491 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -278,7 +278,7 @@ class TextEdit : public Control { void _scroll_lines_down(); // void mouse_motion(const Point& p_pos, const Point& p_rel, int p_button_mask); - Size2 get_minimum_size(); + Size2 get_minimum_size() const; int get_row_height() const; |