summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorDaniel J. Ramirez <djrmuv@gmail.com>2017-07-18 01:09:19 -0500
committerDaniel J. Ramirez <djrmuv@gmail.com>2017-07-18 01:09:19 -0500
commit17c3422431c3312d6e124b0afa871fd166928669 (patch)
treebcac22081d9ca67fb74aa5317cb3c68126cf06b5 /scene
parent69a4ea34c4f630c1ca353a135d768872bb54cd41 (diff)
Added separators using StyleBoxLine, some theme style fixes, added variant icon
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/dialogs.cpp1
-rw-r--r--scene/gui/option_button.cpp17
-rw-r--r--scene/resources/style_box.cpp78
-rw-r--r--scene/resources/style_box.h34
4 files changed, 129 insertions, 1 deletions
diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp
index d5e852f840..8885bec03c 100644
--- a/scene/gui/dialogs.cpp
+++ b/scene/gui/dialogs.cpp
@@ -584,5 +584,6 @@ Button *ConfirmationDialog::get_cancel() {
ConfirmationDialog::ConfirmationDialog() {
set_title(RTR("Please Confirm..."));
+ set_custom_minimum_size(Size2(200, 70));
cancel = add_cancel();
}
diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp
index f75e0986c1..b842419eab 100644
--- a/scene/gui/option_button.cpp
+++ b/scene/gui/option_button.cpp
@@ -52,11 +52,26 @@ void OptionButton::_notification(int p_what) {
RID ci = get_canvas_item();
Ref<Texture> arrow = Control::get_icon("arrow");
Ref<StyleBox> normal = get_stylebox("normal");
+ Color clr = Color(1, 1, 1);
+ if (get_constant("modulate_arrow"))
+ switch (get_draw_mode()) {
+ case DRAW_PRESSED:
+ clr = get_color("font_color_pressed");
+ break;
+ case DRAW_HOVER:
+ clr = get_color("font_color_hover");
+ break;
+ case DRAW_DISABLED:
+ clr = get_color("font_color_disabled");
+ break;
+ default:
+ clr = get_color("font_color");
+ }
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);
+ arrow->draw(ci, ofs, clr);
} break;
}
diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp
index 2714ffec10..f108809c83 100644
--- a/scene/resources/style_box.cpp
+++ b/scene/resources/style_box.cpp
@@ -437,3 +437,81 @@ StyleBoxFlat::StyleBoxFlat() {
}
StyleBoxFlat::~StyleBoxFlat() {
}
+
+void StyleBoxLine::set_color(const Color &p_color) {
+ color = p_color;
+ emit_changed();
+}
+Color StyleBoxLine::get_color() const {
+ return color;
+}
+
+void StyleBoxLine::set_thickness(int p_thickness) {
+ thickness = p_thickness;
+ emit_changed();
+}
+int StyleBoxLine::get_thickness() const {
+ return thickness;
+}
+
+void StyleBoxLine::set_vertical(bool p_vertical) {
+ vertical = p_vertical;
+}
+bool StyleBoxLine::is_vertical() const {
+ return vertical;
+}
+
+void StyleBoxLine::set_grow(float p_grow) {
+ grow = p_grow;
+ emit_changed();
+}
+float StyleBoxLine::get_grow() const {
+ return grow;
+}
+
+void StyleBoxLine::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("set_color", "color"), &StyleBoxLine::set_color);
+ ClassDB::bind_method(D_METHOD("get_color"), &StyleBoxLine::get_color);
+ ClassDB::bind_method(D_METHOD("set_thickness", "thickness"), &StyleBoxLine::set_thickness);
+ ClassDB::bind_method(D_METHOD("get_thickness"), &StyleBoxLine::get_thickness);
+ ClassDB::bind_method(D_METHOD("set_grow", "grow"), &StyleBoxLine::set_grow);
+ ClassDB::bind_method(D_METHOD("get_grow"), &StyleBoxLine::get_grow);
+ ClassDB::bind_method(D_METHOD("set_vertical", "vertical"), &StyleBoxLine::set_vertical);
+ ClassDB::bind_method(D_METHOD("is_vertical"), &StyleBoxLine::is_vertical);
+
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_color", "get_color");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "thickness", PROPERTY_HINT_RANGE, "0,10"), "set_thickness", "get_thickness");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "vertical"), "set_vertical", "get_vertical");
+}
+float StyleBoxLine::get_style_margin(Margin p_margin) const {
+ return thickness;
+}
+Size2 StyleBoxLine::get_center_size() const {
+ return Size2();
+}
+
+void StyleBoxLine::draw(RID p_canvas_item, const Rect2 &p_rect) const {
+ VisualServer *vs = VisualServer::get_singleton();
+ Rect2i r = p_rect;
+
+ if (vertical) {
+ r.position.y -= grow;
+ r.size.y += grow * 2;
+ r.size.x = thickness;
+ } else {
+ r.position.x -= grow;
+ r.size.x += grow * 2;
+ r.size.y = thickness;
+ }
+
+ vs->canvas_item_add_rect(p_canvas_item, r, color);
+}
+
+StyleBoxLine::StyleBoxLine() {
+ grow = 1.0;
+ thickness = 1;
+ color = Color(0.0, 0.0, 0.0);
+ vertical = false;
+}
+StyleBoxLine::~StyleBoxLine() {}
diff --git a/scene/resources/style_box.h b/scene/resources/style_box.h
index 7547c2ea81..64ce3528aa 100644
--- a/scene/resources/style_box.h
+++ b/scene/resources/style_box.h
@@ -164,4 +164,38 @@ public:
~StyleBoxFlat();
};
+// just used to draw lines.
+class StyleBoxLine : public StyleBox {
+
+ GDCLASS(StyleBoxLine, StyleBox);
+ Color color;
+ int thickness;
+ bool vertical;
+ float grow;
+
+protected:
+ virtual float get_style_margin(Margin p_margin) const;
+ static void _bind_methods();
+
+public:
+ void set_color(const Color &p_color);
+ Color get_color() const;
+
+ void set_thickness(int p_thickness);
+ int get_thickness() const;
+
+ void set_vertical(bool p_vertical);
+ bool is_vertical() const;
+
+ void set_grow(float p_grow);
+ float get_grow() const;
+
+ virtual Size2 get_center_size() const;
+
+ virtual void draw(RID p_canvas_item, const Rect2 &p_rect) const;
+
+ StyleBoxLine();
+ ~StyleBoxLine();
+};
+
#endif