diff --git a/ImGuiToolkit.cpp b/ImGuiToolkit.cpp index 16dd97e..1d42049 100644 --- a/ImGuiToolkit.cpp +++ b/ImGuiToolkit.cpp @@ -158,6 +158,34 @@ bool ImGuiToolkit::ButtonIconToggle(int i, int j, int i_toggle, int j_toggle, bo return ret; } + +bool ImGuiToolkit::IconToggle(int i, int j, int i_toggle, int j_toggle, bool* toggle) +{ +// bool ret = false; + ImGui::PushID( i * 20 + j + i_toggle * 20 + j_toggle); + + float frame_height = ImGui::GetFrameHeight(); + float frame_width = frame_height; + ImVec2 draw_pos = ImGui::GetCursorScreenPos(); + + // toggle action : operate on the whole area + ImGui::InvisibleButton("##icontoggle", ImVec2(frame_width, frame_height)); + if (ImGui::IsItemClicked()) + *toggle = !*toggle; + + ImGui::SetCursorScreenPos(draw_pos); + if (*toggle) { + Icon(i_toggle, j_toggle); + } + else { + Icon(i, j); + } + + ImGui::PopID(); + return *toggle; +} + + struct Sum { void operator()(std::pair n) { sum += n.first * 20 + n.second; } diff --git a/ImGuiToolkit.h b/ImGuiToolkit.h index e1c3cd1..4818d96 100644 --- a/ImGuiToolkit.h +++ b/ImGuiToolkit.h @@ -15,19 +15,20 @@ namespace ImGuiToolkit void ShowIconsWindow(bool* p_open); // utility buttons - bool ButtonIcon(int i, int j); - bool ButtonIconToggle(int i, int j, int i_toggle, int j_toggle, bool* toggle); - bool ButtonIconMultistate(std::vector > icons, int* state); - void ButtonToggle( const char* label, bool* toggle ); - void ButtonSwitch(const char* label, bool* toggle , const char *help = nullptr); - void ButtonOpenUrl( const char* url, const ImVec2& size_arg = ImVec2(0,0)); + bool ButtonIcon (int i, int j); + bool ButtonIconToggle (int i, int j, int i_toggle, int j_toggle, bool* toggle); + bool ButtonIconMultistate (std::vector > icons, int* state); + void ButtonToggle (const char* label, bool* toggle ); + void ButtonSwitch (const char* label, bool* toggle , const char *help = nullptr); + bool IconToggle (int i, int j, int i_toggle, int j_toggle, bool* toggle); + void ButtonOpenUrl (const char* url, const ImVec2& size_arg = ImVec2(0,0)); - void HelpMarker(const char* desc); + void HelpMarker (const char* desc); // utility sliders - void Bar(float value, float in, float out, float min, float max, const char* title, bool expand); - bool TimelineSlider(const char* label, guint64 *time, guint64 duration, guint64 step); - bool TimelineSliderEdit(const char* label, guint64 *time, guint64 duration, guint64 step, + void Bar (float value, float in, float out, float min, float max, const char* title, bool expand); + bool TimelineSlider (const char* label, guint64 *time, guint64 duration, guint64 step); + bool TimelineSliderEdit (const char* label, guint64 *time, guint64 duration, guint64 step, std::list >& segments); // fonts from ressources 'fonts/' @@ -38,8 +39,8 @@ namespace ImGuiToolkit FONT_MONO, FONT_LARGE } font_style; - void SetFont(font_style type, const std::string &ttf_font_name, int pointsize, int oversample = 2); - void PushFont(font_style type); + void SetFont (font_style type, const std::string &ttf_font_name, int pointsize, int oversample = 2); + void PushFont (font_style type); // color of gui items typedef enum { @@ -47,10 +48,10 @@ namespace ImGuiToolkit ACCENT_ORANGE, ACCENT_GREY } accent_color; - void SetAccentColor(accent_color color); - struct ImVec4 GetHighlightColor(); + void SetAccentColor (accent_color color); + struct ImVec4 GetHighlightColor (); - void ShowStats(bool* p_open, int* p_corner); + void ShowStats (bool* p_open, int* p_corner); } diff --git a/Mixer.cpp b/Mixer.cpp index 94e49e3..4d54df4 100644 --- a/Mixer.cpp +++ b/Mixer.cpp @@ -292,6 +292,7 @@ void Mixer::insertSource(Source *s) layer_.setDepth(s); // update view to show source created + setCurrentView(View::MIXING); current_view_->update(0); current_view_->restoreSettings(); } diff --git a/PickingVisitor.cpp b/PickingVisitor.cpp index 649895e..2ee7564 100644 --- a/PickingVisitor.cpp +++ b/PickingVisitor.cpp @@ -74,6 +74,8 @@ void PickingVisitor::visit(Handles &n) if (!n.visible_) return; + // TODO fixme ! + // apply inverse transform to the point of interest glm::vec4 P = glm::inverse(modelview_) * glm::vec4( point_, 0.f, 1.f ); @@ -110,7 +112,7 @@ void PickingVisitor::visit(Handles &n) } if ( picked ) - // add this surface to the nodes picked + // add this to the nodes picked nodes_.push_back( std::pair(&n, glm::vec2(P)) ); } diff --git a/UserInterfaceManager.cpp b/UserInterfaceManager.cpp index 623171e..45f4a4a 100644 --- a/UserInterfaceManager.cpp +++ b/UserInterfaceManager.cpp @@ -374,13 +374,17 @@ void UserInterface::handleMouse() Mixer::manager().currentView()->scene.accept(pv); // picking visitor found nodes? - if (pv.picked().empty()) + if (pv.picked().empty()) { Mixer::manager().unsetCurrentSource(); + navigator.hidePannel(); + } else { // top-most Node picked pick = pv.picked().back(); // find source containing the cliced Node Mixer::manager().setCurrentSource( pick.first ); + if (navigator.pannelVisible()) + navigator.showPannelSource( Mixer::manager().indexCurrentSource() ); } } @@ -391,7 +395,7 @@ void UserInterface::handleMouse() } if ( ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left) ) { - // display the info on source in left pannel + // display source in left pannel navigator.showPannelSource( Mixer::manager().indexCurrentSource() ); } @@ -890,52 +894,55 @@ void UserInterface::RenderShaderEditor() Navigator::Navigator() { - clearSelection(); - selected_source_index = -1; - width = 100; - pannel_width = 5.f * width; - height = 100; - padding_width = 100; + // default geometry + width_ = 100; + pannel_width_ = 5.f * width_; + height_ = 100; + padding_width_ = 100; new_source_type_ = 0; - sprintf(new_source_filename_, " "); + + // clean start + clearButtonSelection(); } -void Navigator::toggle(int index) +void Navigator::applyButtonSelection(int index) { - bool s = selected_button[index]; - clearSelection(); - selected_button[index] = s; - if (s) - selected_source_index = index; - else - selected_source_index = -1; + // ensure only one button is active at a time + bool status = selected_button[index]; + clearButtonSelection(); + selected_button[index] = status; + + // set visible if button is active + pannel_visible_ = status; } -void Navigator::clearSelection() +void Navigator::clearButtonSelection() { + // clear all buttons for(int i=0; i -1 ) - selected_button[NAV_MENU] = false; - else + if (pannel_stick_ || pannel_visible_){ + // pannel menu + if (selected_button[NAV_MENU]) + { RenderMainPannel(); - } - // window to create a source - else if (selected_button[NAV_NEW]) - { - // if a source is selected in the meantime, revert to selected source pannel - if (Mixer::manager().indexCurrentSource() > -1 ) - selected_button[NAV_NEW] = false; - else - // show new source pannel + } + // pannel to create a source + else if (selected_button[NAV_NEW]) + { RenderNewPannel(); - } - // window to configure a selected source - else if (selected_source_index > -1) - { - // manipulate current source, and activate corresponding button - clearSelection(); - selected_button[Mixer::manager().indexCurrentSource()] = true; - Source *s = Mixer::manager().currentSource(); - if (s) - RenderSourcePannel(s); + } + // pannel to configure a selected source else - selected_source_index = -1; - } - + { + Source *s = Mixer::manager().currentSource(); + if (s) + RenderSourcePannel(s); + } + } ImGui::PopStyleColor(2); ImGui::PopStyleVar(); @@ -1071,19 +1065,23 @@ void Navigator::Render() void Navigator::RenderSourcePannel(Source *s) { // Next window is a side pannel - ImGui::SetNextWindowPos( ImVec2(width, 0), ImGuiCond_Always ); - ImGui::SetNextWindowSize( ImVec2(pannel_width, height), ImGuiCond_Always ); + ImGui::SetNextWindowPos( ImVec2(width_, 0), ImGuiCond_Always ); + ImGui::SetNextWindowSize( ImVec2(pannel_width_, height_), ImGuiCond_Always ); ImGui::SetNextWindowBgAlpha(0.85f); // Transparent background if (ImGui::Begin("##navigatorSource", NULL, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav)) { // TITLE + ImGui::SetCursorPosY(10); ImGuiToolkit::PushFont(ImGuiToolkit::FONT_LARGE); ImGui::Text("Source"); - ImGui::Text(""); ImGui::PopFont(); + ImGui::SetCursorPos(ImVec2(pannel_width_ - 35.f, 10.f)); + ImGuiToolkit::IconToggle(13,11,11,11,&pannel_stick_); + static char buf5[128]; sprintf ( buf5, "%s", s->name().c_str() ); + ImGui::SetCursorPosY(80); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); if (ImGui::InputText("Name", buf5, 64, ImGuiInputTextFlags_CharsNoBlank)){ Mixer::manager().renameSource(s, buf5); @@ -1148,17 +1146,18 @@ void SourcePreview::draw(float width) void Navigator::RenderNewPannel() { // Next window is a side pannel - ImGui::SetNextWindowPos( ImVec2(width, 0), ImGuiCond_Always ); - ImGui::SetNextWindowSize( ImVec2(pannel_width, height), ImGuiCond_Always ); + ImGui::SetNextWindowPos( ImVec2(width_, 0), ImGuiCond_Always ); + ImGui::SetNextWindowSize( ImVec2(pannel_width_, height_), ImGuiCond_Always ); ImGui::SetNextWindowBgAlpha(0.85f); // Transparent background if (ImGui::Begin("##navigatorNewSource", NULL, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav)) { // TITLE + ImGui::SetCursorPosY(10); ImGuiToolkit::PushFont(ImGuiToolkit::FONT_LARGE); ImGui::Text("New Source"); - ImGui::Text(""); ImGui::PopFont(); + ImGui::SetCursorPosY(80); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); ImGui::Combo("Origin", &new_source_type_, "File\0Software\0Hardware\0"); @@ -1166,7 +1165,7 @@ void Navigator::RenderNewPannel() if (new_source_type_ == 0) { // helper - ImGui::SetCursorPosX(pannel_width - 30 + IMGUI_RIGHT_ALIGN); + ImGui::SetCursorPosX(pannel_width_ - 30 + IMGUI_RIGHT_ALIGN); ImGuiToolkit::HelpMarker("Create a source from a file:\n- Video (*.mpg, *mov, *.avi, etc.)\n- Image (*.jpg, *.png, etc.)\n- Vector graphics (*.svg)\n- vimix session (*.vmx)\n\nEquivalent to dropping the file in the workspace."); // browse for a filename @@ -1203,7 +1202,7 @@ void Navigator::RenderNewPannel() // show preview new_source_preview_.draw(ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN); // or press Validate button - if ( ImGui::Button("Import", ImVec2(pannel_width - padding_width, 0)) ) { + if ( ImGui::Button("Import", ImVec2(pannel_width_ - padding_width_, 0)) ) { Mixer::manager().insertSource(new_source_preview_.getSource()); selected_button[NAV_NEW] = false; } @@ -1213,7 +1212,7 @@ void Navigator::RenderNewPannel() else if (new_source_type_ == 1){ // helper - ImGui::SetCursorPosX(pannel_width - 30 + IMGUI_RIGHT_ALIGN); + ImGui::SetCursorPosX(pannel_width_ - 30 + IMGUI_RIGHT_ALIGN); ImGuiToolkit::HelpMarker("Create a source from a software algorithm or from vimix objects."); // fill new_source_preview with a new source @@ -1239,7 +1238,7 @@ void Navigator::RenderNewPannel() // show preview new_source_preview_.draw(ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN); // ask to import the source in the mixer - if ( ImGui::Button("Import", ImVec2(pannel_width - padding_width, 0)) ) { + if ( ImGui::Button("Import", ImVec2(pannel_width_ - padding_width_, 0)) ) { Mixer::manager().insertSource(new_source_preview_.getSource()); // reset for next time selected_button[NAV_NEW] = false; @@ -1249,7 +1248,7 @@ void Navigator::RenderNewPannel() // Hardware else { // helper - ImGui::SetCursorPosX(pannel_width - 30 + IMGUI_RIGHT_ALIGN); + ImGui::SetCursorPosX(pannel_width_ - 30 + IMGUI_RIGHT_ALIGN); ImGuiToolkit::HelpMarker("Create a source capturing images from an external hardware."); } @@ -1261,20 +1260,21 @@ void Navigator::RenderNewPannel() void Navigator::RenderMainPannel() { // Next window is a side pannel - ImGui::SetNextWindowPos( ImVec2(width, 0), ImGuiCond_Always ); - ImGui::SetNextWindowSize( ImVec2(pannel_width, height), ImGuiCond_Always ); + ImGui::SetNextWindowPos( ImVec2(width_, 0), ImGuiCond_Always ); + ImGui::SetNextWindowSize( ImVec2(pannel_width_, height_), ImGuiCond_Always ); ImGui::SetNextWindowBgAlpha(0.85f); // Transparent background if (ImGui::Begin("##navigatorMain", NULL, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav)) { // TITLE + ImGui::SetCursorPosY(10); ImGuiToolkit::PushFont(ImGuiToolkit::FONT_LARGE); ImGui::Text(APP_NAME); - ImGui::Text(""); ImGui::PopFont(); + ImGui::SetCursorPosY(80); ImGui::Text("Session"); ImGui::SameLine(); - ImGui::SetCursorPosX(pannel_width IMGUI_RIGHT_ALIGN); + ImGui::SetCursorPosX(pannel_width_ IMGUI_RIGHT_ALIGN); if (ImGui::BeginMenu("File")) { UserInterface::manager().showMenuFile(); @@ -1321,16 +1321,16 @@ void Navigator::RenderMainPannel() if ( ImGui::Combo("Accent", &Settings::application.accent_color, "Blue\0Orange\0Grey\0\0")) ImGuiToolkit::SetAccentColor(static_cast(Settings::application.accent_color)); - // Bottom aligned + // Bottom aligned Logo static unsigned int vimixicon = Resource::getTextureImage("images/v-mix_256x256.png"); static float h = 4.f * ImGui::GetTextLineHeightWithSpacing(); - if ( ImGui::GetCursorPosY() + h + 128.f < height ) { - ImGui::SetCursorPos(ImVec2(pannel_width / 2.f - 64.f, height -h - 128.f)); + if ( ImGui::GetCursorPosY() + h + 128.f < height_ ) { + ImGui::SetCursorPos(ImVec2(pannel_width_ / 2.f - 64.f, height_ -h - 128.f)); ImGui::Image((void*)(intptr_t)vimixicon, ImVec2(128, 128)); ImGui::Text(""); } else { - ImGui::SetCursorPosY(height -h); + ImGui::SetCursorPosY(height_ -h); ImGui::Text("About"); } if ( ImGui::Button( ICON_FA_CROW " About vimix", ImVec2(ImGui::GetContentRegionAvail().x, 0)) ) diff --git a/UserInterfaceManager.h b/UserInterfaceManager.h index 4646b66..b9cce7b 100644 --- a/UserInterfaceManager.h +++ b/UserInterfaceManager.h @@ -30,24 +30,25 @@ public: class Navigator { - // geometry left bar - float width; - float pannel_width; - float height; - float sourcelist_height; - float padding_width; + // geometry left bar & pannel + float width_; + float height_; + float pannel_width_; + float sourcelist_height_; + float padding_width_; - // top items : group of buttons openning a pannel - int selected_source_index; + // behavior pannel + bool pannel_visible_; + bool pannel_stick_; bool selected_button[NAV_COUNT]; - void clearSelection(); - void toggle(int index); + void clearButtonSelection(); + void applyButtonSelection(int index); // side pannels void RenderSourcePannel(Source *s); - void RenderNewPannel(); void RenderMainPannel(); + void RenderNewPannel(); int new_source_type_; char new_source_filename_[2048]; @@ -56,11 +57,12 @@ class Navigator public: Navigator(); - void toggleMenu(); + bool pannelVisible() { return pannel_visible_; } void hidePannel(); void showPannelSource(int index); - void Render(); + void toggleMenu(); + void Render(); }; class ToolBox diff --git a/rsc/images/icons.dds b/rsc/images/icons.dds index 82c2879..9e5718f 100644 Binary files a/rsc/images/icons.dds and b/rsc/images/icons.dds differ diff --git a/rsc/mesh/icon_empty.ply b/rsc/mesh/icon_empty.ply new file mode 100644 index 0000000..55a5dd9 --- /dev/null +++ b/rsc/mesh/icon_empty.ply @@ -0,0 +1,30 @@ +ply +format ascii 1.0 +comment Created by Blender 2.82 (sub 7) - www.blender.org, source file: 'icons.blend' +element vertex 8 +property float x +property float y +property float z +property uchar red +property uchar green +property uchar blue +property uchar alpha +element face 8 +property list uchar uint vertex_indices +end_header +-0.122248 -0.092391 0.000000 255 255 255 255 +-0.101952 0.069939 0.000000 255 255 255 255 +-0.122248 0.090230 0.000000 255 255 255 255 +0.121299 0.090230 0.000000 255 255 255 255 +0.101003 0.069939 0.000000 255 255 255 255 +0.121299 -0.092391 0.000000 255 255 255 255 +-0.101952 -0.072100 0.000000 255 255 255 255 +0.101003 -0.072100 0.000000 255 255 255 255 +3 0 1 2 +3 1 3 2 +3 1 4 3 +3 4 5 3 +3 0 6 1 +3 7 5 4 +3 0 7 6 +3 0 5 7 diff --git a/rsc/svg/iconmonstr-control-panel-21.svg b/rsc/svg/iconmonstr-control-panel-21.svg index b77d4e9..f4079e6 100644 --- a/rsc/svg/iconmonstr-control-panel-21.svg +++ b/rsc/svg/iconmonstr-control-panel-21.svg @@ -1 +1,15 @@ - \ No newline at end of file + + + + + + + + + + + + + diff --git a/rsc/svg/iconmonstr-control-panel-22.svg b/rsc/svg/iconmonstr-control-panel-22.svg index 0af036f..0d651b5 100644 --- a/rsc/svg/iconmonstr-control-panel-22.svg +++ b/rsc/svg/iconmonstr-control-panel-22.svg @@ -1 +1,69 @@ - \ No newline at end of file + + + +image/svg+xml + + + + + + + + + \ No newline at end of file diff --git a/rsc/svg/iconmonstr-control-panel-23.svg b/rsc/svg/iconmonstr-control-panel-23.svg index 36dd5ca..8bb989f 100644 --- a/rsc/svg/iconmonstr-control-panel-23.svg +++ b/rsc/svg/iconmonstr-control-panel-23.svg @@ -1 +1,17 @@ - \ No newline at end of file + + + + + + + + + + diff --git a/rsc/svg/iconmonstr-shape-18.svg b/rsc/svg/iconmonstr-shape-18.svg index c55b360..371f63e 100644 --- a/rsc/svg/iconmonstr-shape-18.svg +++ b/rsc/svg/iconmonstr-shape-18.svg @@ -1 +1,60 @@ - \ No newline at end of file + + + + + + image/svg+xml + + + + + + + + + diff --git a/rsc/svg/iconmonstr-shape-22.svg b/rsc/svg/iconmonstr-shape-22.svg index 9b6c5c4..3ee6281 100644 --- a/rsc/svg/iconmonstr-shape-22.svg +++ b/rsc/svg/iconmonstr-shape-22.svg @@ -1 +1,58 @@ - \ No newline at end of file + + + + + + image/svg+xml + + + + + + + + diff --git a/rsc/svg/icons.png b/rsc/svg/icons.png index 51c2331..1817d00 100644 Binary files a/rsc/svg/icons.png and b/rsc/svg/icons.png differ