Files
HuajisheTools/editor/button.h
2025-12-24 13:15:25 +08:00

32 lines
808 B
C++

#ifndef BUTTON_H_
#define BUTTON_H_
#include <SDL3/SDL.h>
class Button {
public:
// Constructor: Initializes the button's dimensions and state
Button(float x, float y, float w, float h);
// Core Loop Functions
void handleEvent(const SDL_Event& e);
void update(); // Optional: used if you have animations or timers
void render(SDL_Renderer* renderer);
// State Observers (Getters)
bool isHovered() const { return hovered; }
bool isPressed() const { return pressed; }
bool isClicked() const { return clicked; }
private:
SDL_FRect rect; // SDL3 prefers SDL_FRect (floats) for better precision
bool hovered = false;
bool pressed = false;
bool clicked = false;
// Internal logic helper
void updateHover(float mouseX, float mouseY);
};
#endif