aboutsummaryrefslogtreecommitdiff
path: root/extension/src/openvic-extension/classes/GFXButtonStateTexture.hpp
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2024-02-24 14:17:07 +0100
committer hop311 <hop3114@gmail.com>2024-02-24 14:17:07 +0100
commit843edde55306e3fbdb5e37ef9b7c09c7b53f50c4 (patch)
tree487fea19d42106c08b60f5bba99bc76485073002 /extension/src/openvic-extension/classes/GFXButtonStateTexture.hpp
parent5d7c6eafe35e2c6e952bc0b3f91d27d760c8e75e (diff)
Added GUIScrollbar and GFXCorneredTileSupportingTexturescrollbar
Diffstat (limited to 'extension/src/openvic-extension/classes/GFXButtonStateTexture.hpp')
-rw-r--r--extension/src/openvic-extension/classes/GFXButtonStateTexture.hpp35
1 files changed, 29 insertions, 6 deletions
diff --git a/extension/src/openvic-extension/classes/GFXButtonStateTexture.hpp b/extension/src/openvic-extension/classes/GFXButtonStateTexture.hpp
index c98159d..b57ea46 100644
--- a/extension/src/openvic-extension/classes/GFXButtonStateTexture.hpp
+++ b/extension/src/openvic-extension/classes/GFXButtonStateTexture.hpp
@@ -6,8 +6,26 @@
#include <openvic-simulation/utility/Getters.hpp>
namespace OpenVic {
- class GFXButtonStateTexture : public godot::ImageTexture {
- GDCLASS(GFXButtonStateTexture, godot::ImageTexture)
+ class GFXCorneredTileSupportingTexture : public godot::AtlasTexture {
+ GDCLASS(GFXCorneredTileSupportingTexture, godot::AtlasTexture)
+
+ protected:
+ godot::Vector2i PROPERTY_ACCESS(cornered_tile_border_size, protected);
+
+ static void _bind_methods();
+
+ public:
+ GFXCorneredTileSupportingTexture();
+
+ /* Returns true if the texture has a non-zero 9 patch border. */
+ bool is_cornered_tile_texture() const;
+
+ /* Equivalent to draw_rect, but draws a 9 patch texture if this is a cornered tile texture. */
+ void draw_rect_cornered(godot::RID const& to_canvas_item, godot::Rect2 const& rect) const;
+ };
+
+ class GFXButtonStateTexture : public GFXCorneredTileSupportingTexture {
+ GDCLASS(GFXButtonStateTexture, GFXCorneredTileSupportingTexture)
public:
enum ButtonState {
@@ -20,6 +38,7 @@ namespace OpenVic {
private:
ButtonState PROPERTY(button_state);
godot::Ref<godot::Image> state_image;
+ godot::Ref<godot::ImageTexture> state_texture;
protected:
static void _bind_methods();
@@ -29,7 +48,8 @@ namespace OpenVic {
/* Create a GFXButtonStateTexture using the specified godot::Image. Returns nullptr if generate_state_image fails. */
static godot::Ref<GFXButtonStateTexture> make_gfx_button_state_texture(
- ButtonState button_state, godot::Ref<godot::Image> const& source_image, godot::Rect2i const& region
+ ButtonState button_state, godot::Ref<godot::Image> const& source_image, godot::Rect2i const& region,
+ godot::Vector2i const& cornered_tile_border_size
);
/* Set the ButtonState to be generated by this class (calling this does not trigger state image generation). */
@@ -37,14 +57,17 @@ namespace OpenVic {
/* Generate a modified version of the given region of source_image
* and update the underlying godot::ImageTexture to use it. */
- godot::Error generate_state_image(godot::Ref<godot::Image> const& source_image, godot::Rect2i const& region);
+ godot::Error generate_state_image(
+ godot::Ref<godot::Image> const& source_image, godot::Rect2i const& region,
+ godot::Vector2i const& new_cornered_tile_border_size
+ );
static godot::StringName const& button_state_to_theme_name(ButtonState button_state);
godot::StringName const& get_button_state_theme() const;
};
- class GFXButtonStateHavingTexture : public godot::AtlasTexture {
- GDCLASS(GFXButtonStateHavingTexture, godot::AtlasTexture)
+ class GFXButtonStateHavingTexture : public GFXCorneredTileSupportingTexture {
+ GDCLASS(GFXButtonStateHavingTexture, GFXCorneredTileSupportingTexture)
std::array<godot::Ref<GFXButtonStateTexture>, GFXButtonStateTexture::BUTTON_STATE_COUNT> button_state_textures;