combine with desktop project

Signed-off-by: Peter Siegmund <developer@mars3142.org>
This commit is contained in:
2025-04-10 23:20:19 +02:00
parent b6fb4eb65c
commit b3bf03999b
72 changed files with 65538 additions and 132 deletions

32
src/ui/widgets/Button.cpp Normal file
View File

@@ -0,0 +1,32 @@
#include "ui/widgets/Button.h"
#include <functional>
#include <utility>
#include <SDL3_image/SDL_image.h>
#include "ResourceManager.h"
auto pressed = false;
Button::Button(
void* appState,
const float x,
const float y,
const float width,
std::function<void()> callback)
: UIWidget(appState)
, m_x(x)
, m_y(y)
, m_width(width)
, m_callback(std::move(callback)) {
}
void Button::render() const {
const auto button = ResourceManager::getInstance().get_texture(get_context()->renderer(), "assets/button_normal.png");
const auto overlay =ResourceManager::getInstance().get_texture(get_context()->renderer(), "assets/button_pressed_overlay.png");
const auto dst = SDL_FRect(m_x, m_y, m_width, m_width);
SDL_RenderTexture(get_context()->renderer(), button, nullptr, &dst);
if(pressed) {
SDL_RenderTexture(get_context()->renderer(), overlay, nullptr, &dst);
}
}