aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde2017-02-07 14:16:47 +0100
committerGitHub2017-02-07 14:16:47 +0100
commitbe0350704fa36bce8207c7c72ef2b64e5c8017ee (patch)
tree97ddb06a7fd732d9b32ac71eea14f3c41cf2d616
parent34b6caa43303c46f178e0375aa50bfaf5ac903e7 (diff)
parentf3bc5d443cac02be8eac458f467bd3c8d41b0345 (diff)
downloadgodot-be0350704fa36bce8207c7c72ef2b64e5c8017ee.tar.gz
godot-be0350704fa36bce8207c7c72ef2b64e5c8017ee.tar.zst
godot-be0350704fa36bce8207c7c72ef2b64e5c8017ee.zip
Merge pull request #7711 from williamd1k0/cherrypick-colorframe
Add ColorFrame control (2.1)
-rw-r--r--scene/gui/color_rect.cpp36
-rw-r--r--scene/gui/color_rect.h22
-rw-r--r--scene/register_scene_types.cpp2
-rw-r--r--tools/editor/icons/icon_color_frame.pngbin0 -> 360 bytes
4 files changed, 60 insertions, 0 deletions
diff --git a/scene/gui/color_rect.cpp b/scene/gui/color_rect.cpp
new file mode 100644
index 000000000..a0e4df66b
--- /dev/null
+++ b/scene/gui/color_rect.cpp
@@ -0,0 +1,36 @@
+#include "color_rect.h"
+
+
+
+
+void ColorFrame::set_frame_color(const Color& p_color) {
+
+ color=p_color;
+ update();
+}
+
+Color ColorFrame::get_frame_color() const{
+
+ return color;
+}
+
+void ColorFrame::_notification(int p_what) {
+
+ if (p_what==NOTIFICATION_DRAW) {
+ draw_rect(Rect2(Point2(),get_size()),color);
+ }
+}
+
+void ColorFrame::_bind_methods() {
+
+ ObjectTypeDB::bind_method(_MD("set_frame_color","color"),&ColorFrame::set_frame_color);
+ ObjectTypeDB::bind_method(_MD("get_frame_color"),&ColorFrame::get_frame_color);
+
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR,"color"),_SCS("set_frame_color"),_SCS("get_frame_color") );
+}
+
+ColorFrame::ColorFrame() {
+
+ color=Color(1,1,1);
+}
+
diff --git a/scene/gui/color_rect.h b/scene/gui/color_rect.h
new file mode 100644
index 000000000..3816d4405
--- /dev/null
+++ b/scene/gui/color_rect.h
@@ -0,0 +1,22 @@
+#ifndef COLORRECT_H
+#define COLORRECT_H
+
+#include "scene/gui/control.h"
+
+class ColorFrame : public Control {
+ OBJ_TYPE(ColorFrame,Control)
+
+ Color color;
+protected:
+
+ void _notification(int p_what);
+ static void _bind_methods();
+public:
+
+ void set_frame_color(const Color& p_color);
+ Color get_frame_color() const;
+
+ ColorFrame();
+};
+
+#endif // COLORRECT_H
diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp
index 76a697c14..0dda56946 100644
--- a/scene/register_scene_types.cpp
+++ b/scene/register_scene_types.cpp
@@ -55,6 +55,7 @@
#include "scene/gui/option_button.h"
#include "scene/gui/color_picker.h"
#include "scene/gui/texture_frame.h"
+#include "scene/gui/color_rect.h"
#include "scene/gui/patch_9_frame.h"
#include "scene/gui/menu_button.h"
#include "scene/gui/check_box.h"
@@ -338,6 +339,7 @@ void register_scene_types() {
OS::get_singleton()->yield(); //may take time to init
ObjectTypeDB::register_type<TextureFrame>();
+ ObjectTypeDB::register_type<ColorFrame>();
ObjectTypeDB::register_type<Patch9Frame>();
ObjectTypeDB::register_type<TabContainer>();
ObjectTypeDB::register_type<Tabs>();
diff --git a/tools/editor/icons/icon_color_frame.png b/tools/editor/icons/icon_color_frame.png
new file mode 100644
index 000000000..a82eefc10
--- /dev/null
+++ b/tools/editor/icons/icon_color_frame.png
Binary files differ