diff options
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/button.cpp | 29 | ||||
-rw-r--r-- | scene/gui/graph_edit.cpp | 4 | ||||
-rw-r--r-- | scene/gui/item_list.cpp | 18 | ||||
-rw-r--r-- | scene/gui/item_list.h | 4 | ||||
-rw-r--r-- | scene/gui/line_edit.cpp | 4 | ||||
-rw-r--r-- | scene/gui/option_button.cpp | 19 | ||||
-rw-r--r-- | scene/gui/spin_box.cpp | 7 | ||||
-rw-r--r-- | scene/gui/tab_container.cpp | 9 | ||||
-rw-r--r-- | scene/gui/tool_button.cpp | 4 | ||||
-rw-r--r-- | scene/gui/tool_button.h | 3 |
10 files changed, 75 insertions, 26 deletions
diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp index 6fcc878e11..f57b3d0fd1 100644 --- a/scene/gui/button.cpp +++ b/scene/gui/button.cpp @@ -69,49 +69,48 @@ void Button::_notification(int p_what) { RID ci = get_canvas_item(); Size2 size = get_size(); Color color; + Color icon_color = Color(1, 1, 1); //print_line(get_text()+": "+itos(is_flat())+" hover "+itos(get_draw_mode())); - Ref<StyleBox> style = get_stylebox("normal"); - + String style_name = ""; switch (get_draw_mode()) { case DRAW_NORMAL: { - style = get_stylebox("normal"); - if (!flat) - style->draw(ci, Rect2(Point2(0, 0), size)); + style_name = "normal"; color = get_color("font_color"); + } break; case DRAW_PRESSED: { - style = get_stylebox("pressed"); - style->draw(ci, Rect2(Point2(0, 0), size)); - if (has_color("font_color_pressed")) + style_name = "pressed"; + if (has_color("font_color_pressed")) { color = get_color("font_color_pressed"); - else + icon_color = color; + } else color = get_color("font_color"); } break; case DRAW_HOVER: { - style = get_stylebox("hover"); - style->draw(ci, Rect2(Point2(0, 0), size)); + style_name = "hover"; color = get_color("font_color_hover"); } break; case DRAW_DISABLED: { - style = get_stylebox("disabled"); - style->draw(ci, Rect2(Point2(0, 0), size)); + style_name = "disabled"; color = get_color("font_color_disabled"); } break; } + if (style_name != "" && !flat) get_stylebox(style_name)->draw(ci, Rect2(Point2(0, 0), size)); + + Ref<StyleBox> style = get_stylebox(style_name); if (has_focus()) { - Ref<StyleBox> style = get_stylebox("focus"); style->draw(ci, Rect2(Point2(), size)); } @@ -149,7 +148,7 @@ void Button::_notification(int p_what) { int valign = size.height - style->get_minimum_size().y; - _icon->draw(ci, style->get_offset() + Point2(0, Math::floor((valign - _icon->get_height()) / 2.0)), is_disabled() ? Color(1, 1, 1, 0.4) : Color(1, 1, 1)); + _icon->draw(ci, style->get_offset() + Point2(0, Math::floor((valign - _icon->get_height()) / 2.0)), is_disabled() ? Color(1, 1, 1, 0.4) : icon_color); } } } diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index 0c092a4e17..0bc48677dd 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -579,7 +579,7 @@ void GraphEdit::_bake_segment2d(CanvasItem *p_where, float p_begin, float p_end, if (p_depth >= p_min_depth && (dp < p_tol || p_depth >= p_max_depth)) { - p_where->draw_line(beg, end, p_color.linear_interpolate(p_to_color, mp), 2, true); + p_where->draw_line(beg, end, p_color.linear_interpolate(p_to_color, mp), 4, true); lines++; } else { _bake_segment2d(p_where, p_begin, mp, p_a, p_out, p_b, p_in, p_depth + 1, p_min_depth, p_max_depth, p_tol, p_color, p_to_color, lines); @@ -598,7 +598,7 @@ void GraphEdit::_draw_cos_line(CanvasItem *p_where, const Vector2 &p_from, const int cp_neg_len = get_constant("bezier_len_neg"); if (diff > 0) { - cp_offset = MAX(cp_len, diff * 0.5); + cp_offset = MIN(cp_len, diff * 0.5); } else { cp_offset = MAX(MIN(cp_len - diff, cp_neg_len), -diff * 0.5); } diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index c2d5775b64..1dc4230d2a 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -42,6 +42,7 @@ void ItemList::add_item(const String &p_item, const Ref<Texture> &p_texture, boo item.disabled = false; item.tooltip_enabled = true; item.custom_bg = Color(0, 0, 0, 0); + item.custom_font_color = get_color("font_color"); items.push_back(item); update(); @@ -151,6 +152,20 @@ Color ItemList::get_item_custom_bg_color(int p_idx) const { return items[p_idx].custom_bg; } +void ItemList::set_item_custom_font_color(int p_idx, const Color &p_custom_font_color) { + + ERR_FAIL_INDEX(p_idx, items.size()); + + items[p_idx].custom_font_color = p_custom_font_color; +} + +Color ItemList::get_item_custom_font_color(int p_idx) const { + + ERR_FAIL_INDEX_V(p_idx, items.size(), Color()); + + return items[p_idx].custom_font_color; +} + void ItemList::set_item_tag_icon(int p_idx, const Ref<Texture> &p_tag_icon) { ERR_FAIL_INDEX(p_idx, items.size()); @@ -1013,7 +1028,8 @@ void ItemList::_notification(int p_what) { else max_len = size.x; - Color modulate = items[i].selected ? font_color_selected : font_color; + Color font_color_2 = items[i].custom_font_color; + Color modulate = items[i].selected ? font_color_selected : font_color_2; if (items[i].disabled) modulate.a *= 0.5; diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h index 4b896de77c..96a894d3fd 100644 --- a/scene/gui/item_list.h +++ b/scene/gui/item_list.h @@ -62,6 +62,7 @@ private: Variant metadata; String tooltip; Color custom_bg; + Color custom_font_color; Rect2 rect_cache; Rect2 min_rect_cache; @@ -144,6 +145,9 @@ public: void set_item_custom_bg_color(int p_idx, const Color &p_custom_bg_color); Color get_item_custom_bg_color(int p_idx) const; + void set_item_custom_font_color(int p_idx, const Color &p_custom_font_color); + Color get_item_custom_font_color(int p_idx) const; + void select(int p_idx, bool p_single = true); void unselect(int p_idx); bool is_selected(int p_idx) const; diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 9abf9649c0..0acb7265e3 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -576,7 +576,7 @@ void LineEdit::_notification(int p_what) { RID ci = get_canvas_item(); - Ref<StyleBox> style = get_stylebox("normal"); + Ref<StyleBox> style = has_focus() ? get_stylebox("active") : get_stylebox("normal"); if (!is_editable()) style = get_stylebox("read_only"); @@ -617,7 +617,7 @@ void LineEdit::_notification(int p_what) { int font_ascent = font->get_ascent(); Color selection_color = get_color("selection_color"); - Color font_color = get_color("font_color"); + Color font_color = is_editable() ? has_focus() ? get_color("font_color_active") : get_color("font_color") : get_color("font_color_read_only"); Color font_color_selected = get_color("font_color_selected"); Color cursor_color = get_color("cursor_color"); diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp index 0806d35d48..b967a1a7ce 100644 --- a/scene/gui/option_button.cpp +++ b/scene/gui/option_button.cpp @@ -56,7 +56,24 @@ void OptionButton::_notification(int p_what) { Size2 size = get_size(); Point2 ofs(size.width - arrow->get_width() - get_constant("arrow_margin"), int(Math::abs((size.height - arrow->get_height()) / 2))); - arrow->draw(ci, ofs); + + Color arrow_color = get_color("font_color"); + switch (get_draw_mode()) { + case DRAW_NORMAL: { + arrow_color = get_color("font_color"); + } break; + case DRAW_PRESSED: { + arrow_color = get_color("font_color_pressed"); + } break; + case DRAW_HOVER: { + arrow_color = get_color("font_color_hover"); + } break; + case DRAW_DISABLED: { + arrow_color = get_color("font_color_disabled"); + } break; + } + + arrow->draw(ci, ofs, arrow_color); } break; } diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp index 049adc6fb4..ba8ca63721 100644 --- a/scene/gui/spin_box.cpp +++ b/scene/gui/spin_box.cpp @@ -192,7 +192,12 @@ void SpinBox::_notification(int p_what) { RID ci = get_canvas_item(); Size2i size = get_size(); - updown->draw(ci, Point2i(size.width - updown->get_width(), (size.height - updown->get_height()) / 2)); + Color color = has_focus() ? line_edit->get_color("font_color_active") : line_edit->get_color("font_color"); + if (!is_editable()) + color = line_edit->get_color("font_color_read_only"); + updown->draw(ci, Point2i(size.width - updown->get_width(), (size.height - updown->get_height()) / 2), color); + + } else if (p_what == NOTIFICATION_FOCUS_EXIT) { } else if (p_what == NOTIFICATION_FOCUS_EXIT) { diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index 0c7a58dc16..952f2a9710 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -206,6 +206,9 @@ void TabContainer::_notification(int p_what) { break; } + // Draw the tab area. + panel->draw(canvas, Rect2(0, header_height, size.width, size.height - header_height)); + // Draw all visible tabs. int x = 0; for (int i = 0; i < tab_widths.size(); i++) { @@ -224,7 +227,7 @@ void TabContainer::_notification(int p_what) { // Draw the tab background. int tab_width = tab_widths[i]; - Rect2 tab_rect(tabs_ofs_cache + x, 0, tab_width, header_height); + Rect2 tab_rect(tabs_ofs_cache + x, 2, tab_width, header_height); tab_style->draw(canvas, tab_rect); // Draw the tab contents. @@ -279,8 +282,6 @@ void TabContainer::_notification(int p_what) { Color(1, 1, 1, first_tab_cache > 0 ? 1.0 : 0.5)); } - // Draw the tab area. - panel->draw(canvas, Rect2(0, header_height, size.width, size.height - header_height)); } break; case NOTIFICATION_THEME_CHANGED: { if (get_tab_count() > 0) { @@ -659,7 +660,7 @@ TabContainer::TabContainer() { current = 0; previous = 0; mouse_x_cache = 0; - align = ALIGN_CENTER; + align = ALIGN_LEFT; tabs_visible = true; popup = NULL; }
\ No newline at end of file diff --git a/scene/gui/tool_button.cpp b/scene/gui/tool_button.cpp index 5fc4b6ecf8..7e8a426d15 100644 --- a/scene/gui/tool_button.cpp +++ b/scene/gui/tool_button.cpp @@ -29,6 +29,10 @@ /*************************************************************************/ #include "tool_button.h" +void ToolButton::_notification(int p_what) { + // set_self_modulate(get_color("pressed")); +} + ToolButton::ToolButton() { set_flat(true); } diff --git a/scene/gui/tool_button.h b/scene/gui/tool_button.h index d243b5559f..58948f798f 100644 --- a/scene/gui/tool_button.h +++ b/scene/gui/tool_button.h @@ -37,6 +37,9 @@ class ToolButton : public Button { public: ToolButton(); + +protected: + void _notification(int p_what); }; #endif // TOOL_BUTTON_H |