mirror of
https://github.com/zhenyan121/SporeBG-Conid.git
synced 2026-04-10 14:24:10 +08:00
Added UI class and UI rendering class
This commit is contained in:
33
src/ui/components/Button.cpp
Normal file
33
src/ui/components/Button.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include "Button.h"
|
||||
|
||||
Button::Button()
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Button::setText(const std::string& text, TextStyle style) {
|
||||
m_buttonData.text = text;
|
||||
m_buttonData.textstytle = style;
|
||||
}
|
||||
|
||||
void Button::setBackgroundColor(SDL_Color normal) {
|
||||
m_buttonData.backgroundColor = normal;
|
||||
}
|
||||
|
||||
void Button::setBorder(int thickness, SDL_Color color) {
|
||||
m_buttonData.borderThickness = thickness;
|
||||
m_buttonData.borderColor = color;
|
||||
}
|
||||
|
||||
|
||||
void Button::update(float deltaTime) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
48
src/ui/components/Button.h
Normal file
48
src/ui/components/Button.h
Normal file
@@ -0,0 +1,48 @@
|
||||
#pragma once
|
||||
#include "ui/base/UIRenderData.h"
|
||||
#include "ui/base/UIComponent.h"
|
||||
class Button : public UIComponent{
|
||||
public:
|
||||
Button();
|
||||
~Button() override = default;
|
||||
|
||||
// 实现UIComponent接口
|
||||
|
||||
void update(float deltaTime) override;
|
||||
|
||||
/**
|
||||
* @brief 设置按钮文本
|
||||
* @param text 按钮文本
|
||||
* @param style 文本样式
|
||||
*/
|
||||
void setText(const std::string& text, TextStyle style);
|
||||
|
||||
/**
|
||||
* @brief 设置背景颜色
|
||||
* @param normal 正常状态颜色
|
||||
* @param hovered 悬停状态颜色(可选,默认透明)
|
||||
* @param pressed 按下状态颜色(可选,默认透明)
|
||||
*/
|
||||
void setBackgroundColor(SDL_Color normal);
|
||||
/**
|
||||
* @brief 设置边框
|
||||
* @param thickness 边框厚度(像素)
|
||||
* @param color 边框颜色
|
||||
*/
|
||||
void setBorder(int thickness, SDL_Color color);
|
||||
|
||||
|
||||
ButtonData& getButtonDate() {
|
||||
m_buttonData.rect = m_rect;
|
||||
return m_buttonData;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
|
||||
ButtonData m_buttonData;
|
||||
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user