EditorSDL
This commit is contained in:
31
editor/button.h
Normal file
31
editor/button.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#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
|
||||
Reference in New Issue
Block a user