diff --git a/ImGuiToolkit.cpp b/ImGuiToolkit.cpp index 7a7c28a..7643770 100644 --- a/ImGuiToolkit.cpp +++ b/ImGuiToolkit.cpp @@ -1086,6 +1086,53 @@ bool ImGuiToolkit::InvisibleSliderInt (const char* label, uint *index, uint min, return value_changed; } +bool ImGuiToolkit::InvisibleSliderFloat (const char* label, float *index, float min, float max, ImVec2 size) +{ + // get window + ImGuiWindow* window = ImGui::GetCurrentWindow(); + if (window->SkipItems) + return false; + + // get id + const ImGuiID id = window->GetID(label); + + ImVec2 pos = window->DC.CursorPos; + ImRect bbox(pos, pos + size); + ImGui::ItemSize(size); + if (!ImGui::ItemAdd(bbox, id)) + return false; + + // read user input from system + const bool left_mouse_press = ImGui::IsMouseDown(ImGuiMouseButton_Left); + const bool hovered = ImGui::ItemHoverable(bbox, id); + bool temp_input_is_active = ImGui::TempInputIsActive(id); + if (!temp_input_is_active) + { + const bool focus_requested = ImGui::FocusableItemRegister(window, id); + if (focus_requested || (hovered && left_mouse_press) ) + { + ImGui::SetActiveID(id, window); + ImGui::SetFocusID(id, window); + ImGui::FocusWindow(window); + } + } + else + return false; + + bool value_changed = false; + + if (ImGui::GetActiveID() == id) { + // Slider behavior + ImRect grab_slider_bb; + float _zero = min; + float _end = max; + value_changed = ImGui::SliderBehavior(bbox, id, ImGuiDataType_Float, index, &_zero, + &_end, "%f", 1.f, ImGuiSliderFlags_None, &grab_slider_bb); + } + + return value_changed; +} + bool ImGuiToolkit::EditPlotLines (const char* label, float *array, int values_count, float values_min, float values_max, const ImVec2 size) { bool array_changed = false; diff --git a/ImGuiToolkit.h b/ImGuiToolkit.h index b2dd1fc..8ef12dc 100644 --- a/ImGuiToolkit.h +++ b/ImGuiToolkit.h @@ -50,6 +50,7 @@ namespace ImGuiToolkit void RenderTimeline (ImVec2 min_bbox, ImVec2 max_bbox, guint64 begin, guint64 end, guint64 step, bool verticalflip = false); void RenderTimelineBPM (ImVec2 min_bbox, ImVec2 max_bbox, double tempo, double quantum, guint64 begin, guint64 end, guint64 step, bool verticalflip = false); bool InvisibleSliderInt(const char* label, uint *index, uint min, uint max, const ImVec2 size); + bool InvisibleSliderFloat(const char* label, float *index, float min, float max, const ImVec2 size); bool EditPlotLines(const char* label, float *array, int values_count, float values_min, float values_max, const ImVec2 size); bool EditPlotHistoLines(const char* label, float *histogram_array, float *lines_array, int values_count, float values_min, float values_max, guint64 begin, guint64 end, bool cut, bool *released, const ImVec2 size); void ShowPlotHistoLines(const char* label, float *histogram_array, float *lines_array, int values_count, float values_min, float values_max, const ImVec2 size); diff --git a/UserInterfaceManager.cpp b/UserInterfaceManager.cpp index c3f7663..d0725b5 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), + timeline_height_(0.f), mediaplayer_height_(0.f), buttons_width_(0.f), buttons_height_(0.f), filter_slider_(0.9), 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,6 +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")) + { + if (ImGuiToolkit::MenuItemIcon(7, 9, "Pre-processed input")) + filter_slider_ = 1.0; + if (ImGuiToolkit::MenuItemIcon(8, 9, "Post-processed image")) + filter_slider_ = 0.0; + ImGui::EndMenu(); + } + // Menu section for list ImGui::Separator(); if (ImGui::MenuItem( ICON_FA_TH " List all")) { @@ -2962,10 +2971,12 @@ void SourceController::RenderSingleSource(Source *s) // in case of a MediaSource MediaSource *ms = dynamic_cast(s); if ( ms != nullptr ) { - RenderMediaPlayer( ms->mediaplayer() ); + RenderMediaPlayer( ms ); } else { + ImDrawList* draw_list = ImGui::GetWindowDrawList(); + ImVec2 top = ImGui::GetCursorScreenPos(); ImVec2 rendersize = ImGui::GetContentRegionAvail() - ImVec2(0, buttons_height_ + scrollbar_ + v_space_); ImVec2 bottom = ImVec2(top.x, top.y + rendersize.y + v_space_); @@ -2991,7 +3002,15 @@ void SourceController::RenderSingleSource(Source *s) /// top += corner; ImGui::SetCursorScreenPos(top); - ImGui::Image((void*)(uintptr_t) s->texture(), framesize); + ImGui::Image((void*)(uintptr_t) s->texture(), framesize * ImVec2(filter_slider_,1.f), ImVec2(0.f,0.f), ImVec2(filter_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(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); /// /// Info overlays @@ -3003,7 +3022,6 @@ void SourceController::RenderSingleSource(Source *s) s->accept(info_); // draw overlay frame and text float tooltip_height = 3.f * ImGui::GetTextLineHeightWithSpacing(); - ImDrawList* draw_list = ImGui::GetWindowDrawList(); draw_list->AddRectFilled(top, top + ImVec2(framesize.x, tooltip_height), IMGUI_COLOR_OVERLAY); ImGui::SetCursorScreenPos(top + ImVec2(h_space_, v_space_)); ImGui::Text("%s", info_.str().c_str()); @@ -3033,9 +3051,9 @@ void SourceController::RenderSingleSource(Source *s) } } -void SourceController::RenderMediaPlayer(MediaPlayer *mp) +void SourceController::RenderMediaPlayer(MediaSource *ms) { - mediaplayer_active_ = mp; + mediaplayer_active_ = ms->mediaplayer(); // for action manager std::ostringstream oss; @@ -3069,7 +3087,15 @@ void SourceController::RenderMediaPlayer(MediaPlayer *mp) /// const ImVec2 top_image = top + corner; ImGui::SetCursorScreenPos(top_image); - ImGui::Image((void*)(uintptr_t) mediaplayer_active_->texture(), framesize); + ImGui::Image((void*)(uintptr_t) ms->texture(), framesize * ImVec2(filter_slider_,1.f), ImVec2(0.f,0.f), ImVec2(filter_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(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); /// /// Info overlays diff --git a/UserInterfaceManager.h b/UserInterfaceManager.h index 2a1430c..1408a13 100644 --- a/UserInterfaceManager.h +++ b/UserInterfaceManager.h @@ -268,6 +268,7 @@ class SourceController : public WorkspaceWindow float mediaplayer_height_; float buttons_width_; float buttons_height_; + float filter_slider_; bool play_toggle_request_, replay_request_; bool pending_; @@ -301,7 +302,7 @@ class SourceController : public WorkspaceWindow bool mediaplayer_mode_; bool mediaplayer_slider_pressed_; float mediaplayer_timeline_zoom_; - void RenderMediaPlayer(MediaPlayer *mp); + void RenderMediaPlayer(MediaSource *ms); public: SourceController(); diff --git a/rsc/images/icons.dds b/rsc/images/icons.dds index 73f0d47..1f0a866 100644 Binary files a/rsc/images/icons.dds and b/rsc/images/icons.dds differ