looper/backends/ui/imgui/RendererBackend.h
Zachary Hall 0bcb5d42d2
Some checks failed
Build / build-gentoo (push) Successful in 2m0s
Build / download-system-deps (push) Successful in 5m23s
Build / get-source-code (push) Successful in 13m49s
Build / build-deb (push) Failing after 5m19s
Build / build-appimage (push) Successful in 4m35s
Build / build-android (push) Failing after 2m50s
Build / build-windows (push) Failing after 7m18s
Add subtitle system to imgui backend, and use it.
2025-01-15 08:54:52 -08:00

82 lines
2.2 KiB
C++

#pragma once
#include "imgui/imgui.h"
#include <functional>
#if defined(IMGUI_IMPL_OPENGL_ES2)
#include <SDL_opengles2.h>
#else
#include <SDL_opengl.h>
#endif
#include <SDL.h>
#include <SDL_video.h>
#ifdef __EMSCRIPTEN__
#include "emscripten_mainloop_stub.h"
#include <emscripten.h>
#include <emscripten/html5.h>
#endif
#include <string>
#include "theme.h"
static const char* NAME = "Looper";
class RendererBackend {
void BackendDeinit();
void LoopFunction();
void BackendInit();
bool started = false;
//SDL_GLContext gl_context;
bool resize_needed = true;
void on_resize();
bool update_scale = false;
SDL_Texture *icon_texture;
bool main_menu_bar_used = false;
int menubar_start;
int menubar_end;
int title_btn_start;
std::string subtitle;
std::string title_text;
void update_real_title();
public:
bool is_fullscreen();
bool is_maximized();
int window_border_radius = 8;
SDL_HitTestResult HitTest(SDL_Window *window, const SDL_Point *area);
std::optional<bool> touchScreenModeOverride;
std::optional<double> scaleOverride;
bool isTouchScreenMode();
static void resize_static();
double scale = 1.0;
SDL_Window *window;
SDL_Renderer *rend;
int window_width = 475;
int window_height = 354;
bool done = false;
Theme *theme;
bool vsync = false;
std::string lang;
std::string userdir;
int framerate = 60;
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
ImFont *title;
const char *prefPath;
ImVec4 accent_color = ImVec4(0.75, 1.0, 1.0, 1.0);
int Run();
void SetSubtitle(const char *subtitle);
inline void ClearSubtitle() {
SetSubtitle("");
}
void SetWindowTitle(const char *title);
virtual void Init();
virtual void GuiFunction();
virtual void Deinit();
virtual void Drop(std::string file);
void OnScale(float scale);
void UpdateScale();
void QueueUpdateScale();
void AddFonts();
void SetWindowSize(int w, int h);
void GetWindowsize(int *w, int *h);
bool BeginMainMenuBar();
void EndMainMenuBar();
RendererBackend();
virtual ~RendererBackend();
friend void main_loop();
friend void backend_init(void *userdata);
};