diff --git a/scene/gui/color_rect.cpp b/scene/gui/color_rect.cpp new file mode 100644 index 00000000000..a0e4df66b5b --- /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 00000000000..3816d440521 --- /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 76a697c148e..0dda5694646 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(); + ObjectTypeDB::register_type(); ObjectTypeDB::register_type(); ObjectTypeDB::register_type(); ObjectTypeDB::register_type(); diff --git a/tools/editor/icons/icon_color_frame.png b/tools/editor/icons/icon_color_frame.png new file mode 100644 index 00000000000..a82eefc10a6 Binary files /dev/null and b/tools/editor/icons/icon_color_frame.png differ