diff --git a/file_browser.cpp b/file_browser.cpp index b0ff2cc..73ba71c 100644 --- a/file_browser.cpp +++ b/file_browser.cpp @@ -4,7 +4,6 @@ FileBrowser::FileBrowser(bool save, ImGuiFileBrowserFlags extra_fallback_flags) { #ifdef PORTALS - g_set_application_name("Neko Player"); main_context = g_main_context_default(); main_loop = g_main_loop_new(main_context, true); portal = xdp_portal_new(); diff --git a/imgui b/imgui index d2291df..dc3e531 160000 --- a/imgui +++ b/imgui @@ -1 +1 @@ -Subproject commit d2291df55190e2f070af2635863f47a96d378a52 +Subproject commit dc3e531ff28450bff73fde0163b1d076b6bb5605 diff --git a/main.cpp b/main.cpp index 3fea10c..6f16eb1 100644 --- a/main.cpp +++ b/main.cpp @@ -68,6 +68,9 @@ string TimeToString(double time_code, uint8_t min_components = 1) { // Main code int main(int, char**) { + #ifdef PORTALS + g_set_application_name("Neko Player"); + #endif bool enable_kms = std::getenv("LAP_KMS") != nullptr; SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "false"); SDL_SetHint(SDL_HINT_APP_NAME, NAME); @@ -359,7 +362,7 @@ int main(int, char**) ImGui::PopItemWidth(); } ImGui::End(); - if (prefs_window) { + if (prefs_window) {/* ImVec2 min_size; min_size.x = ImGui::GetFontSize() * 18; min_size.y = (ImGui::GetFrameHeightWithSpacing() * 8) + (ImGui::GetFontSize()); @@ -367,6 +370,8 @@ int main(int, char**) max_size.x = 99999997952; // The compiler says that if this were just 9s it would be turned into this anyways. max_size.y = 99999997952; ImGui::SetNextWindowSizeConstraints(min_size, max_size); + */ + ImGui::SetNextWindowDockID(dockid); ImGui::Begin("Preferences...", &prefs_window); { if (ImGui::Checkbox("Enable VSync", &vsync)) { @@ -411,17 +416,17 @@ int main(int, char**) } ImGui::EndTable(); } - ImGui::EndChildFrame(); } + ImGui::EndChildFrame(); ImGui::SetNextItemWidth(ImGui::GetWindowWidth() - (ImGui::GetStyle().FramePadding.x * 4)); if (ImGui::SliderFloat("##AccentColor", &accent_color, 0.0, 360.0, "UI hue: %.0f°", ImGuiSliderFlags_NoRoundToFormat)) { theme->Apply(accent_color); - } + } } ImGui::End(); } if (theme_editor) { - Theme::ShowEditor(&theme_editor, theme); + Theme::ShowEditor(&theme_editor, theme, dockid, window_width, window_height); theme->Apply(accent_color); } if (fileDialog.IsOpened()) { diff --git a/theme.cpp b/theme.cpp index 7bd1f55..21eb890 100644 --- a/theme.cpp +++ b/theme.cpp @@ -26,11 +26,12 @@ ImVec4 change_accent_color(ImVec4 in, float hue) { ImGui::ColorConvertHSVtoRGB(hsv.x, hsv.y, hsv.z, out.x, out.y, out.z); return out; } -bool Theme::ShowEditor(bool* open, Theme* &theme) { - static FileBrowser importDialog(false); - static FileBrowser exportDialog(true); +bool Theme::ShowEditor(bool* open, Theme* &theme, ImGuiID dockid, int window_width, int window_height) { + static FileBrowser importDialog(false, ImGuiFileBrowserFlags_NoTitleBar|ImGuiFileBrowserFlags_NoMove|ImGuiFileBrowserFlags_NoResize); + static FileBrowser exportDialog(true, ImGuiFileBrowserFlags_NoTitleBar|ImGuiFileBrowserFlags_NoMove|ImGuiFileBrowserFlags_NoResize); static bool loadOpen = false; static bool saveAsOpen = false; + ImGui::SetNextWindowDockID(dockid); ImGui::Begin("Theme Editor", open); ImGuiStyle& style = theme->style; ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.50f); @@ -79,6 +80,14 @@ bool Theme::ShowEditor(bool* open, Theme* &theme) { exportDialog.SetPwd(userdir); exportDialog.Open(); } + if (importDialog.IsOpened()) { + importDialog.SetWindowSize(window_width, window_height); + importDialog.SetWindowPos(0, 0); + } + if (exportDialog.IsOpened()) { + exportDialog.SetWindowSize(window_width, window_height); + exportDialog.SetWindowPos(0, 0); + } importDialog.Display(); exportDialog.Display(); if (!theme->file_path.empty()) { diff --git a/theme.h b/theme.h index 4340d6d..962385b 100644 --- a/theme.h +++ b/theme.h @@ -17,7 +17,7 @@ class Theme { static const char* prefPath; string file_path; std::set HueEnabledColors; - static bool ShowEditor(bool *open, Theme* &theme); + static bool ShowEditor(bool *open, Theme* &theme, ImGuiID dockid, int window_width, int window_height); void Apply(float hue); void Save(string path); void Save(path path);