2023-01-05 12:25:55 +00: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. */
|
|
|
|
/**************************************************************************/
|
2018-01-04 23:50:27 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
#ifndef STYLE_BOX_H
|
|
|
|
#define STYLE_BOX_H
|
|
|
|
|
2020-11-07 22:33:38 +00:00
|
|
|
#include "core/io/resource.h"
|
2023-07-14 20:35:39 +00:00
|
|
|
#include "core/object/class_db.h"
|
|
|
|
#include "core/object/gdvirtual.gen.inc"
|
2019-08-10 12:28:17 +00:00
|
|
|
|
2019-01-24 13:21:56 +00:00
|
|
|
class CanvasItem;
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
class StyleBox : public Resource {
|
2017-01-03 02:03:46 +00:00
|
|
|
GDCLASS(StyleBox, Resource);
|
2017-06-15 22:44:11 +00:00
|
|
|
RES_BASE_EXTENSION("stylebox");
|
2014-02-10 01:10:30 +00:00
|
|
|
OBJ_SAVE_TYPE(StyleBox);
|
2023-07-14 20:35:39 +00:00
|
|
|
|
2023-01-19 16:14:09 +00:00
|
|
|
float content_margin[4];
|
2016-03-08 23:00:52 +00:00
|
|
|
|
|
|
|
protected:
|
2014-02-10 01:10:30 +00:00
|
|
|
static void _bind_methods();
|
2023-07-14 20:35:39 +00:00
|
|
|
virtual float get_style_margin(Side p_side) const { return 0; }
|
2016-03-08 23:00:52 +00:00
|
|
|
|
2022-03-10 07:17:38 +00:00
|
|
|
GDVIRTUAL2C(_draw, RID, Rect2)
|
2023-01-19 16:14:09 +00:00
|
|
|
GDVIRTUAL1RC(Rect2, _get_draw_rect, Rect2)
|
|
|
|
GDVIRTUAL0RC(Size2, _get_minimum_size)
|
|
|
|
GDVIRTUAL2RC(bool, _test_mask, Point2, Rect2)
|
2022-03-10 07:17:38 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
public:
|
2023-01-19 16:14:09 +00:00
|
|
|
virtual Size2 get_minimum_size() const;
|
2016-03-08 23:00:52 +00:00
|
|
|
|
2023-01-19 16:14:09 +00: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;
|
2022-03-12 04:38:44 +00:00
|
|
|
|
2020-12-22 16:24:29 +00:00
|
|
|
float get_margin(Side p_side) const;
|
2023-01-19 16:14:09 +00:00
|
|
|
Point2 get_offset() const;
|
2016-03-08 23:00:52 +00:00
|
|
|
|
2022-03-10 07:17:38 +00:00
|
|
|
virtual void draw(RID p_canvas_item, const Rect2 &p_rect) const;
|
2023-01-19 16:14:09 +00:00
|
|
|
virtual Rect2 get_draw_rect(const Rect2 &p_rect) const;
|
2016-03-08 23:00:52 +00:00
|
|
|
|
2019-01-24 13:21:56 +00:00
|
|
|
CanvasItem *get_current_item_drawn() const;
|
|
|
|
|
2023-01-19 16:14:09 +00:00
|
|
|
virtual bool test_mask(const Point2 &p_point, const Rect2 &p_rect) const;
|
2016-03-08 23:00:52 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
StyleBox();
|
|
|
|
};
|
|
|
|
|
|
|
|
class StyleBoxEmpty : public StyleBox {
|
2017-01-03 02:03:46 +00:00
|
|
|
GDCLASS(StyleBoxEmpty, StyleBox);
|
2020-12-22 16:24:29 +00:00
|
|
|
virtual float get_style_margin(Side p_side) const override { return 0; }
|
2016-03-08 23:00:52 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
public:
|
2020-07-10 10:34:39 +00:00
|
|
|
virtual void draw(RID p_canvas_item, const Rect2 &p_rect) const override {}
|
2014-02-10 01:10:30 +00:00
|
|
|
StyleBoxEmpty() {}
|
|
|
|
};
|
|
|
|
|
2022-07-23 21:41:51 +00:00
|
|
|
#endif // STYLE_BOX_H
|