mirror of
https://github.com/godotengine/godot.git
synced 2024-11-21 03:18:37 +08:00
100 lines
4.2 KiB
C++
100 lines
4.2 KiB
C++
/**************************************************************************/
|
|
/* style_box_texture.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_TEXTURE_H
|
|
#define STYLE_BOX_TEXTURE_H
|
|
|
|
#include "scene/resources/style_box.h"
|
|
#include "scene/resources/texture.h"
|
|
|
|
class StyleBoxTexture : public StyleBox {
|
|
GDCLASS(StyleBoxTexture, StyleBox);
|
|
|
|
public:
|
|
enum AxisStretchMode {
|
|
AXIS_STRETCH_MODE_STRETCH,
|
|
AXIS_STRETCH_MODE_TILE,
|
|
AXIS_STRETCH_MODE_TILE_FIT,
|
|
};
|
|
|
|
private:
|
|
float expand_margin[4] = {};
|
|
float texture_margin[4] = {};
|
|
Rect2 region_rect;
|
|
Ref<Texture2D> texture;
|
|
bool draw_center = true;
|
|
Color modulate = Color(1, 1, 1, 1);
|
|
AxisStretchMode axis_h = AXIS_STRETCH_MODE_STRETCH;
|
|
AxisStretchMode axis_v = AXIS_STRETCH_MODE_STRETCH;
|
|
|
|
protected:
|
|
virtual float get_style_margin(Side p_side) const override;
|
|
static void _bind_methods();
|
|
|
|
public:
|
|
void set_texture(Ref<Texture2D> p_texture);
|
|
Ref<Texture2D> get_texture() const;
|
|
|
|
void set_texture_margin(Side p_side, float p_size);
|
|
void set_texture_margin_all(float p_size);
|
|
void set_texture_margin_individual(float p_left, float p_top, float p_right, float p_bottom);
|
|
float get_texture_margin(Side p_side) const;
|
|
|
|
void set_expand_margin(Side p_expand_side, float p_size);
|
|
void set_expand_margin_all(float p_expand_margin_size);
|
|
void set_expand_margin_individual(float p_left, float p_top, float p_right, float p_bottom);
|
|
float get_expand_margin(Side p_expand_side) const;
|
|
|
|
void set_region_rect(const Rect2 &p_region_rect);
|
|
Rect2 get_region_rect() const;
|
|
|
|
void set_draw_center(bool p_enabled);
|
|
bool is_draw_center_enabled() const;
|
|
|
|
void set_h_axis_stretch_mode(AxisStretchMode p_mode);
|
|
AxisStretchMode get_h_axis_stretch_mode() const;
|
|
|
|
void set_v_axis_stretch_mode(AxisStretchMode p_mode);
|
|
AxisStretchMode get_v_axis_stretch_mode() const;
|
|
|
|
void set_modulate(const Color &p_modulate);
|
|
Color get_modulate() const;
|
|
|
|
virtual Rect2 get_draw_rect(const Rect2 &p_rect) const override;
|
|
virtual void draw(RID p_canvas_item, const Rect2 &p_rect) const override;
|
|
|
|
StyleBoxTexture();
|
|
~StyleBoxTexture();
|
|
};
|
|
|
|
VARIANT_ENUM_CAST(StyleBoxTexture::AxisStretchMode)
|
|
|
|
#endif // STYLE_BOX_TEXTURE_H
|