godot/scene/resources/style_box.h

87 lines
3.6 KiB
C++

/**************************************************************************/
/* style_box.h */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef STYLE_BOX_H
#define STYLE_BOX_H
#include "core/io/resource.h"
#include "core/object/class_db.h"
#include "core/object/gdvirtual.gen.inc"
class CanvasItem;
class StyleBox : public Resource {
GDCLASS(StyleBox, Resource);
RES_BASE_EXTENSION("stylebox");
OBJ_SAVE_TYPE(StyleBox);
float content_margin[4];
protected:
static void _bind_methods();
virtual float get_style_margin(Side p_side) const { return 0; }
GDVIRTUAL2C_REQUIRED(_draw, RID, Rect2)
GDVIRTUAL1RC(Rect2, _get_draw_rect, Rect2)
GDVIRTUAL0RC(Size2, _get_minimum_size)
GDVIRTUAL2RC(bool, _test_mask, Point2, Rect2)
public:
virtual Size2 get_minimum_size() const;
void set_content_margin(Side p_side, float p_value);
void set_content_margin_all(float p_value);
void set_content_margin_individual(float p_left, float p_top, float p_right, float p_bottom);
float get_content_margin(Side p_side) const;
float get_margin(Side p_side) const;
Point2 get_offset() const;
virtual void draw(RID p_canvas_item, const Rect2 &p_rect) const;
virtual Rect2 get_draw_rect(const Rect2 &p_rect) const;
CanvasItem *get_current_item_drawn() const;
virtual bool test_mask(const Point2 &p_point, const Rect2 &p_rect) const;
StyleBox();
};
class StyleBoxEmpty : public StyleBox {
GDCLASS(StyleBoxEmpty, StyleBox);
virtual float get_style_margin(Side p_side) const override { return 0; }
public:
virtual void draw(RID p_canvas_item, const Rect2 &p_rect) const override {}
StyleBoxEmpty() {}
};
#endif // STYLE_BOX_H