virtualx-engine/scene/resources/style_box.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

87 lines
3.6 KiB
C++
Raw Normal View History

2014-02-10 02:10:30 +01:00
/**************************************************************************/
/* 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. */
/**************************************************************************/
2014-02-10 02:10:30 +01:00
#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"
2019-08-10 14:28:17 +02:00
class CanvasItem;
2014-02-10 02:10:30 +01:00
class StyleBox : public Resource {
GDCLASS(StyleBox, Resource);
RES_BASE_EXTENSION("stylebox");
2014-02-10 02:10:30 +01:00
OBJ_SAVE_TYPE(StyleBox);
float content_margin[4];
2016-03-09 00:00:52 +01:00
protected:
2014-02-10 02:10:30 +01:00
static void _bind_methods();
virtual float get_style_margin(Side p_side) const { return 0; }
2016-03-09 00:00:52 +01:00
GDVIRTUAL2C(_draw, RID, Rect2)
GDVIRTUAL1RC(Rect2, _get_draw_rect, Rect2)
GDVIRTUAL0RC(Size2, _get_minimum_size)
GDVIRTUAL2RC(bool, _test_mask, Point2, Rect2)
2014-02-10 02:10:30 +01:00
public:
virtual Size2 get_minimum_size() const;
2016-03-09 00:00:52 +01:00
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;
2020-12-22 17:24:29 +01:00
float get_margin(Side p_side) const;
Point2 get_offset() const;
2016-03-09 00:00:52 +01:00
virtual void draw(RID p_canvas_item, const Rect2 &p_rect) const;
virtual Rect2 get_draw_rect(const Rect2 &p_rect) const;
2016-03-09 00:00:52 +01:00
CanvasItem *get_current_item_drawn() const;
virtual bool test_mask(const Point2 &p_point, const Rect2 &p_rect) const;
2016-03-09 00:00:52 +01:00
2014-02-10 02:10:30 +01:00
StyleBox();
};
class StyleBoxEmpty : public StyleBox {
GDCLASS(StyleBoxEmpty, StyleBox);
2020-12-22 17:24:29 +01:00
virtual float get_style_margin(Side p_side) const override { return 0; }
2016-03-09 00:00:52 +01:00
2014-02-10 02:10:30 +01:00
public:
2020-07-10 12:34:39 +02:00
virtual void draw(RID p_canvas_item, const Rect2 &p_rect) const override {}
2014-02-10 02:10:30 +01:00
StyleBoxEmpty() {}
};
#endif // STYLE_BOX_H