Add subtitle system to imgui backend, and use it.
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
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
This commit is contained in:
parent
84b324e01c
commit
0bcb5d42d2
3 changed files with 36 additions and 8 deletions
|
@ -17,6 +17,8 @@
|
||||||
#include <log.hpp>
|
#include <log.hpp>
|
||||||
#include <options.hpp>
|
#include <options.hpp>
|
||||||
#include <web_functions.hpp>
|
#include <web_functions.hpp>
|
||||||
|
#include <fmt/core.h>
|
||||||
|
#include <fmt/format.h>
|
||||||
using std::vector;
|
using std::vector;
|
||||||
using namespace Looper::Options;
|
using namespace Looper::Options;
|
||||||
void RendererBackend::on_resize() {
|
void RendererBackend::on_resize() {
|
||||||
|
@ -222,7 +224,8 @@ RendererBackend::~RendererBackend() {
|
||||||
renderer_backend = nullptr;
|
renderer_backend = nullptr;
|
||||||
}
|
}
|
||||||
void RendererBackend::SetWindowTitle(const char *title) {
|
void RendererBackend::SetWindowTitle(const char *title) {
|
||||||
SDL_SetWindowTitle(window, title);
|
this->title_text = title;
|
||||||
|
update_real_title();
|
||||||
}
|
}
|
||||||
void RendererBackend::GuiFunction() {
|
void RendererBackend::GuiFunction() {
|
||||||
// Do nothing by default.
|
// Do nothing by default.
|
||||||
|
@ -417,8 +420,7 @@ bool RendererBackend::BeginMainMenuBar() {
|
||||||
ImGui::SetCursorPosX(0);
|
ImGui::SetCursorPosX(0);
|
||||||
ImGui::SetCursorPosY(0);
|
ImGui::SetCursorPosY(0);
|
||||||
ImGui::Image((ImTextureID)(icon_texture), ImVec2(texsize, texsize));
|
ImGui::Image((ImTextureID)(icon_texture), ImVec2(texsize, texsize));
|
||||||
//ImGui::SetCursorPosY((winsize.y - ImGui::GetFrameHeight()) / 2);
|
ImGui::TextUnformatted(title_text.c_str());
|
||||||
ImGui::TextUnformatted(SDL_GetWindowTitle(window));
|
|
||||||
menubar_start = ImGui::GetCursorPosX();
|
menubar_start = ImGui::GetCursorPosX();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -470,10 +472,28 @@ SDL_HitTestResult RendererBackend::HitTest(SDL_Window *window, const SDL_Point *
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
void RendererBackend::SetSubtitle(const char *subtitle) {
|
||||||
|
this->subtitle = subtitle;
|
||||||
|
update_real_title();
|
||||||
|
}
|
||||||
|
void RendererBackend::update_real_title() {
|
||||||
|
if (subtitle == "") {
|
||||||
|
SDL_SetWindowTitle(window, title_text.c_str());
|
||||||
|
} else {
|
||||||
|
SDL_SetWindowTitle(window, fmt::format("{} - {}", subtitle, title_text).c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
void RendererBackend::EndMainMenuBar() {
|
void RendererBackend::EndMainMenuBar() {
|
||||||
#ifndef __EMSCRIPTEN__
|
#ifndef __EMSCRIPTEN__
|
||||||
menubar_end = ImGui::GetCursorPosX();
|
menubar_end = ImGui::GetCursorPosX();
|
||||||
ImVec2 size = ImGui::GetWindowSize();
|
ImVec2 size = ImGui::GetWindowSize();
|
||||||
|
if (subtitle != "") {
|
||||||
|
ImVec4 text_color = ImGui::GetStyleColorVec4(ImGuiCol_Text);
|
||||||
|
text_color.w *= 0.5;
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_Text, text_color);
|
||||||
|
ImGui::TextUnformatted(subtitle.c_str());
|
||||||
|
ImGui::PopStyleColor();
|
||||||
|
}
|
||||||
float btnw = size.y;
|
float btnw = size.y;
|
||||||
int btn_count = 3;
|
int btn_count = 3;
|
||||||
ImVec2 btn_size(btnw, btnw);
|
ImVec2 btn_size(btnw, btnw);
|
||||||
|
|
|
@ -30,6 +30,9 @@ class RendererBackend {
|
||||||
int menubar_start;
|
int menubar_start;
|
||||||
int menubar_end;
|
int menubar_end;
|
||||||
int title_btn_start;
|
int title_btn_start;
|
||||||
|
std::string subtitle;
|
||||||
|
std::string title_text;
|
||||||
|
void update_real_title();
|
||||||
public:
|
public:
|
||||||
bool is_fullscreen();
|
bool is_fullscreen();
|
||||||
bool is_maximized();
|
bool is_maximized();
|
||||||
|
@ -55,6 +58,10 @@ class RendererBackend {
|
||||||
const char *prefPath;
|
const char *prefPath;
|
||||||
ImVec4 accent_color = ImVec4(0.75, 1.0, 1.0, 1.0);
|
ImVec4 accent_color = ImVec4(0.75, 1.0, 1.0, 1.0);
|
||||||
int Run();
|
int Run();
|
||||||
|
void SetSubtitle(const char *subtitle);
|
||||||
|
inline void ClearSubtitle() {
|
||||||
|
SetSubtitle("");
|
||||||
|
}
|
||||||
void SetWindowTitle(const char *title);
|
void SetWindowTitle(const char *title);
|
||||||
virtual void Init();
|
virtual void Init();
|
||||||
virtual void GuiFunction();
|
virtual void GuiFunction();
|
||||||
|
|
|
@ -154,6 +154,7 @@ void MainLoop::Init() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
theme->Apply(accent_color, (float)scale);
|
theme->Apply(accent_color, (float)scale);
|
||||||
|
SetWindowTitle("Looper");
|
||||||
FileLoaded();
|
FileLoaded();
|
||||||
}
|
}
|
||||||
void MainLoop::Drop(std::string file) {
|
void MainLoop::Drop(std::string file) {
|
||||||
|
@ -201,9 +202,9 @@ void MainLoop::FileLoaded() {
|
||||||
auto file_maybe = playback->get_current_title();
|
auto file_maybe = playback->get_current_title();
|
||||||
if (file_maybe.has_value()) {
|
if (file_maybe.has_value()) {
|
||||||
auto name = file_maybe.value();
|
auto name = file_maybe.value();
|
||||||
SetWindowTitle((name + std::string(" - Looper")).c_str());
|
SetSubtitle(name.c_str());
|
||||||
} else {
|
} else {
|
||||||
SetWindowTitle("Looper");
|
ClearSubtitle();
|
||||||
}
|
}
|
||||||
streams = playback->get_streams();
|
streams = playback->get_streams();
|
||||||
properties = playback->get_property_list();
|
properties = playback->get_property_list();
|
||||||
|
|
Loading…
Reference in a new issue