Support using system titlebar in Imgui backend
Some checks failed
Build / build-deb (push) Blocked by required conditions
Build / build-appimage (push) Blocked by required conditions
Build / build-android (push) Blocked by required conditions
Build / build-windows (push) Blocked by required conditions
Build / build-gentoo (push) Failing after 17s
Build / download-system-deps (push) Successful in 6m37s
Build / get-source-code (push) Has been cancelled
Some checks failed
Build / build-deb (push) Blocked by required conditions
Build / build-appimage (push) Blocked by required conditions
Build / build-android (push) Blocked by required conditions
Build / build-windows (push) Blocked by required conditions
Build / build-gentoo (push) Failing after 17s
Build / download-system-deps (push) Successful in 6m37s
Build / get-source-code (push) Has been cancelled
This commit is contained in:
parent
49ea484034
commit
68e067348b
4 changed files with 90 additions and 47 deletions
|
@ -412,15 +412,24 @@ void RendererBackend::BackendInit() {
|
|||
SDL_ShowWindow(window);
|
||||
started = true;
|
||||
}
|
||||
bool RendererBackend::UsingSystemTitlebar() {
|
||||
return enable_system_title_bar;
|
||||
}
|
||||
void RendererBackend::EnableSystemTitlebar(bool enabled) {
|
||||
enable_system_title_bar = true;
|
||||
SDL_SetWindowBordered(window, enable_system_title_bar ? SDL_TRUE : SDL_FALSE);
|
||||
}
|
||||
bool RendererBackend::BeginMainMenuBar() {
|
||||
main_menu_bar_used = true;
|
||||
if (ImGui::BeginMainMenuBar()) {
|
||||
if (!enable_system_title_bar) {
|
||||
ImVec2 winsize = ImGui::GetWindowSize();
|
||||
float texsize = winsize.y;
|
||||
ImGui::SetCursorPosX(0);
|
||||
ImGui::SetCursorPosY(0);
|
||||
ImGui::Image((ImTextureID)(icon_texture), ImVec2(texsize, texsize));
|
||||
ImGui::TextUnformatted(title_text.c_str());
|
||||
}
|
||||
menubar_start = ImGui::GetCursorPosX();
|
||||
return true;
|
||||
} else {
|
||||
|
@ -436,6 +445,7 @@ bool RendererBackend::is_maximized() {
|
|||
SDL_HitTestResult RendererBackend::HitTest(SDL_Window *window, const SDL_Point *area) {
|
||||
int w, h;
|
||||
bool rtop, rbottom, rleft, rright;
|
||||
if (enable_system_title_bar) return SDL_HITTEST_NORMAL;
|
||||
SDL_GetWindowSize(window, &w, &h);
|
||||
rtop = area->y <= 4;
|
||||
rleft = area->x <= 4;
|
||||
|
@ -485,6 +495,7 @@ void RendererBackend::update_real_title() {
|
|||
}
|
||||
void RendererBackend::EndMainMenuBar() {
|
||||
#ifndef __EMSCRIPTEN__
|
||||
if (!enable_system_title_bar) {
|
||||
menubar_end = ImGui::GetCursorPosX();
|
||||
ImVec2 size = ImGui::GetWindowSize();
|
||||
if (subtitle != "") {
|
||||
|
@ -525,6 +536,7 @@ void RendererBackend::EndMainMenuBar() {
|
|||
if (ImGui::MenuItem(titlebar_icons[2])) {
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
ImGui::EndMainMenuBar();
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ class RendererBackend {
|
|||
int title_btn_start;
|
||||
std::string subtitle;
|
||||
std::string title_text;
|
||||
bool enable_system_title_bar;
|
||||
void update_real_title();
|
||||
public:
|
||||
bool is_fullscreen();
|
||||
|
@ -63,6 +64,8 @@ class RendererBackend {
|
|||
SetSubtitle("");
|
||||
}
|
||||
void SetWindowTitle(const char *title);
|
||||
bool UsingSystemTitlebar();
|
||||
void EnableSystemTitlebar(bool enabled);
|
||||
virtual void Init();
|
||||
virtual void GuiFunction();
|
||||
virtual void Deinit();
|
||||
|
|
|
@ -153,6 +153,7 @@ void MainLoop::Init() {
|
|||
theme = new Theme(darkPath);
|
||||
}
|
||||
}
|
||||
EnableSystemTitlebar(get_option<bool>("ui.imgui.enable_system_titlebar", false));
|
||||
theme->Apply(accent_color, (float)scale);
|
||||
SetWindowTitle("Looper");
|
||||
FileLoaded();
|
||||
|
@ -210,6 +211,29 @@ void MainLoop::FileLoaded() {
|
|||
properties = playback->get_property_list();
|
||||
boolean_properties.clear();
|
||||
double_properties.clear();
|
||||
int_properties.clear();
|
||||
string_properties.clear();
|
||||
for (auto &property : properties) {
|
||||
PropertyType type = property.type();
|
||||
auto name = property.path();
|
||||
auto val_maybe = playback->get_property(name);
|
||||
if (!val_maybe.has_value()) continue;
|
||||
auto val = val_maybe.value();
|
||||
switch (type) {
|
||||
case PropertyType::Int: {
|
||||
int_properties[name] = resolve_value<int>(val);
|
||||
} break;
|
||||
case PropertyType::Boolean: {
|
||||
boolean_properties[name] = resolve_value<bool>(val);
|
||||
} break;
|
||||
case PropertyType::String: {
|
||||
string_properties[name] = resolve_value<std::string>(val);
|
||||
} break;
|
||||
case PropertyType::Double: {
|
||||
double_properties[name] = resolve_value<double>(val);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
}
|
||||
void MainLoop::GuiFunction() {
|
||||
#if defined(__EMSCRIPTEN__)||defined(__ANDROID__)
|
||||
|
@ -573,6 +597,11 @@ void MainLoop::GuiFunction() {
|
|||
if (ImGui::Checkbox(_TR_CTX("Preference | Debug menu enable", "Enable debug menu in release builds"), &debug_mode)) {
|
||||
set_option<bool>("ui.imgui.debug_mode", debug_mode);
|
||||
}
|
||||
bool tmp_enable_system_title_bar = UsingSystemTitlebar();
|
||||
if (ImGui::Checkbox(_TR_CTX("Preference | System title bar", "Enable system title bar"), &tmp_enable_system_title_bar)) {
|
||||
EnableSystemTitlebar(tmp_enable_system_title_bar);
|
||||
set_option<bool>("ui.imgui.enable_system_titlebar", tmp_enable_system_title_bar);
|
||||
}
|
||||
if (ImGui::Button(_TRI_CTX(ICON_FK_MAGIC, "Preference | Related non-preference button", "Theme Editor"), ImVec2(ImGui::GetWindowWidth() - (ImGui::GetStyle().WindowPadding.x * 2.0f), 0))) {
|
||||
theme_editor = true;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
using namespace std::filesystem;
|
||||
using std::string;
|
||||
#define IMGUI_FRONTEND
|
||||
|
||||
class MainLoop : public RendererBackend {
|
||||
bool show_demo_window = false;
|
||||
FileBrowser fileDialog = FileBrowser(false);
|
||||
|
|
Loading…
Add table
Reference in a new issue