ShitEngine 1.4.2
基于 C++20 与 SDL3 的轻量级 2D 游戏引擎
载入中...
搜索中...
未找到
UIImage.h
浏览该文件的文档.
1#pragma once
3#include "../Render/Sprite.h"
4#include "../Math.h"
5#include <string>
6#include <optional>
7
8namespace Shit {
18 public:
19 UIImage() = default;
20 explicit UIImage(const std::string& texturePath);
21 ~UIImage() override;
22
23void onRender(const SDL_FRect& screenRect) override;
24 void onDestroy() override;
25
26 // --- getter & setter ---
27 void setTexturePath(const std::string& texturePath) { m_sprite.setTexturePath(texturePath); }
28 const std::string& getTexturePath() const { return m_sprite.getTexturePath(); }
29
30 void setSourceRect(const std::optional<Rect>& sourceRect) { m_sprite.setSourceRect(sourceRect); }
31 const std::optional<Rect>& getSourceRect() const { return m_sprite.getSourceRect(); }
32
33 void setFlipped(bool flipped) { m_sprite.setFlipped(flipped); }
34 bool isFlipped() const { return m_sprite.isFlipped(); }
35
36 const Color& getColor() const { return m_color; }
37 void setColor(const Color& color) { m_color = color; }
38
39 private:
40 SHIT_META(({.displayName = "Sprite", .readOnly = true}))
41 Sprite m_sprite;
42 SHIT_META(({.displayName = "Color", .tooltip = "颜色叠加(用于按钮状态切换着色)"}))
43 Color m_color;
44 };
45}
#define SHIT_API
定义 Core.h:14
#define SHIT_REFLECT_BODY(Type)
定义 Macros.h:89
#define SHIT_REFLECT(Mode)
定义 Macros.h:86
#define SHIT_META(...)
定义 Macros.h:95
const Color & getColor() const
定义 UIImage.h:36
void setTexturePath(const std::string &texturePath)
定义 UIImage.h:27
void setColor(const Color &color)
定义 UIImage.h:37
UIImage()=default
void onRender(const SDL_FRect &screenRect) override
子类实现:在给定屏幕矩形内绘制自身(通过 Renderer 静态 API 绘制)
void setSourceRect(const std::optional< Rect > &sourceRect)
定义 UIImage.h:30
const std::string & getTexturePath() const
定义 UIImage.h:28
UIImage(const std::string &texturePath)
~UIImage() override
void setFlipped(bool flipped)
定义 UIImage.h:33
void onDestroy() override
const std::optional< Rect > & getSourceRect() const
定义 UIImage.h:31
bool isFlipped() const
定义 UIImage.h:34
定义 AnimationClip.h:12
RGBA 颜色(每通道 8 位)
定义 Core.h:26