Add ColorFrame control (2.1)

- cherry-pick from 95eb7466df
This commit is contained in:
William Tumeo 2017-02-02 18:22:03 -02:00
parent 34b6caa433
commit f3bc5d443c
4 changed files with 60 additions and 0 deletions

36
scene/gui/color_rect.cpp Normal file
View file

@ -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);
}

22
scene/gui/color_rect.h Normal file
View file

@ -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

View file

@ -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>();

Binary file not shown.

After

Width:  |  Height:  |  Size: 360 B