From f66d73e385d6a46ad1812f3d81946a9b04c67ecd Mon Sep 17 00:00:00 2001 From: Bruno Herbelin Date: Tue, 3 May 2022 20:04:02 +0200 Subject: [PATCH] Improved and added settings for MediaPlayer split view slider --- Settings.cpp | 2 ++ Settings.h | 2 ++ UserInterfaceManager.cpp | 45 +++++++++++++++++++++++---------------- UserInterfaceManager.h | 1 - rsc/images/icons.dds | Bin 1638528 -> 1638528 bytes 5 files changed, 31 insertions(+), 19 deletions(-) diff --git a/Settings.cpp b/Settings.cpp index 3318978..5c6ed90 100644 --- a/Settings.cpp +++ b/Settings.cpp @@ -126,6 +126,7 @@ void Settings::Save(uint64_t runtime) widgetsNode->SetAttribute("media_player", application.widget.media_player); widgetsNode->SetAttribute("media_player_view", application.widget.media_player_view); widgetsNode->SetAttribute("timeline_editmode", application.widget.media_player_timeline_editmode); + widgetsNode->SetAttribute("media_player_slider", application.widget.media_player_slider); widgetsNode->SetAttribute("shader_editor", application.widget.shader_editor); widgetsNode->SetAttribute("shader_editor_view", application.widget.shader_editor_view); widgetsNode->SetAttribute("stats", application.widget.stats); @@ -365,6 +366,7 @@ void Settings::Load() widgetsNode->QueryBoolAttribute("media_player", &application.widget.media_player); widgetsNode->QueryIntAttribute("media_player_view", &application.widget.media_player_view); widgetsNode->QueryBoolAttribute("timeline_editmode", &application.widget.media_player_timeline_editmode); + widgetsNode->QueryFloatAttribute("media_player_slider", &application.widget.media_player_slider); widgetsNode->QueryBoolAttribute("shader_editor", &application.widget.shader_editor); widgetsNode->QueryIntAttribute("shader_editor_view", &application.widget.shader_editor_view); widgetsNode->QueryBoolAttribute("stats", &application.widget.stats); diff --git a/Settings.h b/Settings.h index 39afa51..d4db863 100644 --- a/Settings.h +++ b/Settings.h @@ -23,6 +23,7 @@ struct WidgetsConfig bool media_player; int media_player_view; bool media_player_timeline_editmode; + float media_player_slider; bool timer; int timer_view; bool inputs; @@ -42,6 +43,7 @@ struct WidgetsConfig media_player = false; media_player_view = -1; media_player_timeline_editmode = false; + media_player_slider = 1.f; toolbox = false; help = false; timer = false; diff --git a/UserInterfaceManager.cpp b/UserInterfaceManager.cpp index d0725b5..5b0e715 100644 --- a/UserInterfaceManager.cpp +++ b/UserInterfaceManager.cpp @@ -2062,7 +2062,7 @@ void WorkspaceWindow::Update() /// SourceController::SourceController() : WorkspaceWindow("SourceController"), min_width_(0.f), h_space_(0.f), v_space_(0.f), scrollbar_(0.f), - timeline_height_(0.f), mediaplayer_height_(0.f), buttons_width_(0.f), buttons_height_(0.f), filter_slider_(0.9), + timeline_height_(0.f), mediaplayer_height_(0.f), buttons_width_(0.f), buttons_height_(0.f), play_toggle_request_(false), replay_request_(false), pending_(false), active_label_(LABEL_AUTO_MEDIA_PLAYER), active_selection_(-1), selection_context_menu_(false), selection_mediaplayer_(nullptr), selection_target_slower_(0), selection_target_faster_(0), @@ -2195,12 +2195,15 @@ void SourceController::Render() if (ImGui::MenuItem( ICON_FA_PLAY " Play | Pause", "Space")) play_toggle_request_ = true; - if (ImGui::BeginMenu( ICON_FA_IMAGE " Show")) + // Menu section for displayed image + if (ImGui::BeginMenu( ICON_FA_IMAGE " Displayed image")) { - if (ImGuiToolkit::MenuItemIcon(7, 9, "Pre-processed input")) - filter_slider_ = 1.0; - if (ImGuiToolkit::MenuItemIcon(8, 9, "Post-processed image")) - filter_slider_ = 0.0; + if (ImGuiToolkit::MenuItemIcon(7, 9, " Pre-processed")) + Settings::application.widget.media_player_slider = 1.0; + if (ImGuiToolkit::MenuItemIcon(6, 9, " Split view")) + Settings::application.widget.media_player_slider = 0.5; + if (ImGuiToolkit::MenuItemIcon(8, 9, " Post-processed")) + Settings::application.widget.media_player_slider = 0.0; ImGui::EndMenu(); } @@ -3002,15 +3005,18 @@ void SourceController::RenderSingleSource(Source *s) /// top += corner; ImGui::SetCursorScreenPos(top); - ImGui::Image((void*)(uintptr_t) s->texture(), framesize * ImVec2(filter_slider_,1.f), ImVec2(0.f,0.f), ImVec2(filter_slider_,1.f)); + ImGui::Image((void*)(uintptr_t) s->texture(), framesize * ImVec2(Settings::application.widget.media_player_slider,1.f), ImVec2(0.f,0.f), ImVec2(Settings::application.widget.media_player_slider,1.f)); - ImGui::SetCursorScreenPos(top + ImVec2(filter_slider_ * framesize.x, 0.f)); - ImGui::Image((void*)(uintptr_t) s->frame()->texture(), framesize * ImVec2(1.f-filter_slider_,1.f), ImVec2(filter_slider_,0.f), ImVec2(1.f,1.f)); + ImGui::SetCursorScreenPos(top + ImVec2(Settings::application.widget.media_player_slider * framesize.x, 0.f)); + ImGui::Image((void*)(uintptr_t) s->frame()->texture(), framesize * ImVec2(1.f-Settings::application.widget.media_player_slider,1.f), ImVec2(Settings::application.widget.media_player_slider,0.f), ImVec2(1.f,1.f)); + + draw_list->AddCircleFilled(top + framesize * ImVec2(Settings::application.widget.media_player_slider,0.5f), 20.f, IM_COL32(255, 255, 255, 150), 26); + draw_list->AddLine(top + framesize * ImVec2(Settings::application.widget.media_player_slider,0.0f), top + framesize * ImVec2(Settings::application.widget.media_player_slider,1.f), IM_COL32(255, 255, 255, 150), 1); ImGui::SetCursorScreenPos(top + ImVec2(0.f, 0.5f * framesize.y - 20.0f)); - ImGuiToolkit::InvisibleSliderFloat("#filter_slider", &filter_slider_, 0.f, 1.f, ImVec2(framesize.x, 40.0f) ); - draw_list->AddCircleFilled(top + framesize * ImVec2(filter_slider_,0.5f), 20.f, IM_COL32(255, 255, 255, 150), 26); - draw_list->AddLine(top + framesize * ImVec2(filter_slider_,0.0f), top + framesize * ImVec2(filter_slider_,1.f), IM_COL32(255, 255, 255, 150), 1); + ImGuiToolkit::InvisibleSliderFloat("#filter_slider", &Settings::application.widget.media_player_slider, 0.f, 1.f, ImVec2(framesize.x, 40.0f) ); + if (ImGui::IsItemHovered() || ImGui::IsItemFocused()) + ImGui::SetMouseCursor(ImGuiMouseCursor_ResizeEW); /// /// Info overlays @@ -3087,15 +3093,18 @@ void SourceController::RenderMediaPlayer(MediaSource *ms) /// const ImVec2 top_image = top + corner; ImGui::SetCursorScreenPos(top_image); - ImGui::Image((void*)(uintptr_t) ms->texture(), framesize * ImVec2(filter_slider_,1.f), ImVec2(0.f,0.f), ImVec2(filter_slider_,1.f)); + ImGui::Image((void*)(uintptr_t) ms->texture(), framesize * ImVec2(Settings::application.widget.media_player_slider,1.f), ImVec2(0.f,0.f), ImVec2(Settings::application.widget.media_player_slider,1.f)); - ImGui::SetCursorScreenPos(top_image + ImVec2(filter_slider_ * framesize.x, 0.f)); - ImGui::Image((void*)(uintptr_t) ms->frame()->texture(), framesize * ImVec2(1.f-filter_slider_,1.f), ImVec2(filter_slider_,0.f), ImVec2(1.f,1.f)); + ImGui::SetCursorScreenPos(top_image + ImVec2(Settings::application.widget.media_player_slider * framesize.x, 0.f)); + ImGui::Image((void*)(uintptr_t) ms->frame()->texture(), framesize * ImVec2(1.f-Settings::application.widget.media_player_slider,1.f), ImVec2(Settings::application.widget.media_player_slider,0.f), ImVec2(1.f,1.f)); + + draw_list->AddCircleFilled(top_image + framesize * ImVec2(Settings::application.widget.media_player_slider,0.5f), 20.f, IM_COL32(255, 255, 255, 150), 26); + draw_list->AddLine(top_image + framesize * ImVec2(Settings::application.widget.media_player_slider,0.0f), top_image + framesize * ImVec2(Settings::application.widget.media_player_slider,1.f), IM_COL32(255, 255, 255, 150), 1); ImGui::SetCursorScreenPos(top_image + ImVec2(0.f, 0.5f * framesize.y - 20.0f)); - ImGuiToolkit::InvisibleSliderFloat("#filter_slider_2", &filter_slider_, 0.f, 1.f, ImVec2(framesize.x, 40.0f) ); - draw_list->AddCircleFilled(top_image + framesize * ImVec2(filter_slider_,0.5f), 20.f, IM_COL32(255, 255, 255, 150), 26); - draw_list->AddLine(top_image + framesize * ImVec2(filter_slider_,0.0f), top_image + framesize * ImVec2(filter_slider_,1.f), IM_COL32(255, 255, 255, 150), 1); + ImGuiToolkit::InvisibleSliderFloat("#Settings::application.widget.media_player_slider2", &Settings::application.widget.media_player_slider, 0.f, 1.f, ImVec2(framesize.x, 40.0f) ); + if (ImGui::IsItemHovered() || ImGui::IsItemFocused()) + ImGui::SetMouseCursor(ImGuiMouseCursor_ResizeEW); /// /// Info overlays diff --git a/UserInterfaceManager.h b/UserInterfaceManager.h index 1408a13..6a92892 100644 --- a/UserInterfaceManager.h +++ b/UserInterfaceManager.h @@ -268,7 +268,6 @@ class SourceController : public WorkspaceWindow float mediaplayer_height_; float buttons_width_; float buttons_height_; - float filter_slider_; bool play_toggle_request_, replay_request_; bool pending_; diff --git a/rsc/images/icons.dds b/rsc/images/icons.dds index 1f0a866be4015627b39538aa809525be2b1497d1..3219d19267cb06b818fe81badb2957c9ed3f6105 100644 GIT binary patch delta 952 zcmZ`&T}TvB6h5=&&eomUS$EXTht_)8@IhAu4HnuUS%tKphd?MbDAthJSwehl#R<2b zTGqHd$f8jo1%;K}AR$Fm#PBEUSr#%|khQ0@ANO`<^qTw7IrG7MbH6#?oqNtiyRSv@ zG9<%hq=J864bZedfDytAa0ba;pa{x5A{ z!_UZqkdBf-g$GnP9hnt-&hj-LdN^7u_#AKEa&N#(!4qSlK#n<9e7{ri;uRGF@JL8O zEztX4%})!S?oYb?Py&L_Bz!$vKPY?wU^@g?D9Gg};{e>K1 zsZ}yy9bABpZxT<%yjf{G%x3q_CNJ?89yXtte6-jNW(XdSdK@eKKCk=(UlZRnZ;nMX z8~;tltm@TtL{a=s91AOVs>P$enn65V^TB^J4?d|PxwMf`vD{zgmM-v6BaC_m7|TrNru0lCzK1TDRBX76Up%s$CJ z@5l4LGkGVG+?!yZg)GUEEuU3oRa+~p8tWnJ;ct}iOL*uPrPdccezS2|WYMVl060O%XM{Wqs>cO7%Tx&MNfaP)>RxH`9~**gI3 ze?wx0y~;s5X|B5gS78i#L>hHyk<#)l@oo@Q!z$Pgsjjoz$;hB`TQ`{kyaxY?3^1eD zZdOY3jPLNmgc^!m+9U!fEgs(Sz=2N~I+yU;uoE4o=2|?{eOjPb=rLE7YmQ>H%GZS7 zBB&jY{fHhX8LXVuTkpXiU_)%V5dT~5o&Inl6oFly>N=d?A|F{9E5RIWT&_>|XAieM zhPNi``bqkfa#_due~jRx^EBzzA4ZN$SI~&4WG4){wJnW@K9i;-$l~`tM$eG+G|x?T zsK(m6a9)Jc-E@>)sv|f60vTjX?novM5BU7JI;{7nqMwHFzFxf!AB;%7WPVe67>}EZ&I5ohgN<};iIR|Y>qxKD|}qFcVoW`KaT~diV5DcbHXXm z@;l~(0!+IBhP{!u6DE#l(Cg$|znW#uY#Eu6+d4HiH3cDYo-S5qru>jznV9}d7`P;l z6N~d=6@89Q< z+qf%(x=HG3^-iUuM$L53