Minor UI improvements

This commit is contained in:
Bruno Herbelin
2023-09-17 18:22:32 +02:00
parent a430d39849
commit 6452ff78c0
4 changed files with 46 additions and 31 deletions

View File

@@ -481,9 +481,10 @@ void ImGuiVisitor::visit (Source& s)
width = height * s.frame()->aspectRatio() * ( s.frame()->projectionArea().x / s.frame()->projectionArea().y); width = height * s.frame()->aspectRatio() * ( s.frame()->projectionArea().x / s.frame()->projectionArea().y);
} }
// centered image // centered image
ImGui::SetCursorPos( ImVec2(pos.x + 0.5f * (preview_width-width), pos.y + 0.5f * (preview_height-height-space)) ); if (s.ready()) {
ImGui::Image((void*)(uintptr_t) s.frame()->texture(), ImVec2(width, height)); ImGui::SetCursorPos( ImVec2(pos.x + 0.5f * (preview_width-width), pos.y + 0.5f * (preview_height-height-space)) );
ImGui::Image((void*)(uintptr_t) s.frame()->texture(), ImVec2(width, height));
}
// inform on visibility status // inform on visibility status
ImGui::SetCursorPos( ImVec2(preview_width + 20, pos.y ) ); ImGui::SetCursorPos( ImVec2(preview_width + 20, pos.y ) );
if (s.active()) { if (s.active()) {
@@ -703,7 +704,7 @@ void ImGuiVisitor::visit (MediaSource& s)
top.x += ImGui::GetFrameHeight(); top.x += ImGui::GetFrameHeight();
} }
ImGui::SetCursorPos(top); ImGui::SetCursorPos(top);
if (ImGuiToolkit::IconButton(ICON_FA_FOLDER_OPEN, "Show in finder")) if (ImGuiToolkit::IconButton(2, 5, "Show in finder"))
SystemToolkit::open(SystemToolkit::path_filename(s.path())); SystemToolkit::open(SystemToolkit::path_filename(s.path()));
ImGui::SetCursorPos(botom); ImGui::SetCursorPos(botom);
@@ -866,7 +867,7 @@ void ImGuiVisitor::visit (SessionFileSource& s)
} }
ImGui::SetCursorPos(top); ImGui::SetCursorPos(top);
if (ImGuiToolkit::IconButton(ICON_FA_FOLDER_OPEN, "Show in finder")) if (ImGuiToolkit::IconButton(2, 5, "Show in finder"))
SystemToolkit::open(SystemToolkit::path_filename(s.path())); SystemToolkit::open(SystemToolkit::path_filename(s.path()));
} }
@@ -1668,7 +1669,7 @@ void ImGuiVisitor::visit (MultiFileSource& s)
// offer to open file browser at location // offer to open file browser at location
ImGui::SetCursorPos(top); ImGui::SetCursorPos(top);
if (ImGuiToolkit::IconButton(ICON_FA_FOLDER_OPEN, "Show in finder")) if (ImGuiToolkit::IconButton(2, 5, "Show in finder"))
SystemToolkit::open(SystemToolkit::path_filename( s.sequence().location )); SystemToolkit::open(SystemToolkit::path_filename( s.sequence().location ));
ImGui::SetCursorPos(botom); ImGui::SetCursorPos(botom);

View File

@@ -1097,10 +1097,13 @@ ImRect DrawSourceWithSlider(Source *s, ImVec2 top, ImVec2 rendersize, bool with_
/// ///
const ImVec2 top_image = top + corner; const ImVec2 top_image = top + corner;
ImGui::SetCursorScreenPos(top_image); ImGui::SetCursorScreenPos(top_image);
// 100% opacity for the image (ensure true colors)
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 1.f); if (s->ready()) {
DrawSource(s, framesize, top_image, true, with_inspector); // 100% opacity for the image (ensure true colors)
ImGui::PopStyleVar(); ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 1.f);
DrawSource(s, framesize, top_image, true, with_inspector);
ImGui::PopStyleVar();
}
return ImRect( top_image, top_image + framesize); return ImRect( top_image, top_image + framesize);
} }
@@ -1125,7 +1128,8 @@ int SourceControlWindow::SourceButton(Source *s, ImVec2 framesize)
ImU32 icon_color = ImGui::GetColorU32(ImGuiCol_NavWindowingHighlight); ImU32 icon_color = ImGui::GetColorU32(ImGuiCol_NavWindowingHighlight);
// 1. draw texture of source // 1. draw texture of source
DrawSource(s, framesize, frame_top); if (s->ready())
DrawSource(s, framesize, frame_top);
// 2. interactive centered button Play / Pause // 2. interactive centered button Play / Pause
if (s->active() && s->playable()) { if (s->active() && s->playable()) {

View File

@@ -755,15 +755,20 @@ void TextureView::draw()
if (mask_cursor_paint_ > 0) { if (mask_cursor_paint_ > 0) {
ImGui::SameLine(0, 50); ImGui::SameLine(0, 50);
ImGui::SetNextItemWidth( ImGui::GetTextLineHeight() * 2.6); if (ImGui::Button(ICON_FA_PEN ICON_FA_SORT_DOWN ))
const char* items[] = { ICON_FA_CIRCLE, ICON_FA_SQUARE }; ImGui::OpenPopup("brush_shape_popup");
static int item = 0;
item = (int) round(Settings::application.brush.z);
if(ImGui::Combo("##BrushShape", &item, items, IM_ARRAYSIZE(items))) {
Settings::application.brush.z = float(item);
}
if (ImGui::IsItemHovered()) if (ImGui::IsItemHovered())
ImGuiToolkit::ToolTip("Shape"); ImGuiToolkit::ToolTip("Shape");
if (ImGui::BeginPopup( "brush_shape_popup" ))
{
ImGuiToolkit::PushFont(ImGuiToolkit::FONT_DEFAULT);
if (ImGui::Selectable( ICON_FA_CIRCLE " Circle"))
Settings::application.brush.z = 0.f;
if (ImGui::Selectable( ICON_FA_SQUARE " Square"))
Settings::application.brush.z = 1.f;
ImGui::PopFont();
ImGui::EndPopup();
}
ImGui::SameLine(); ImGui::SameLine();
show_cursor_forced_ = false; show_cursor_forced_ = false;
@@ -778,7 +783,7 @@ void TextureView::draw()
int pixel_size = int(Settings::application.brush.x * edit_source_->frame()->height() ); int pixel_size = int(Settings::application.brush.x * edit_source_->frame()->height() );
show_cursor_forced_ = true; show_cursor_forced_ = true;
ImGuiToolkit::PushFont(ImGuiToolkit::FONT_DEFAULT); ImGuiToolkit::PushFont(ImGuiToolkit::FONT_DEFAULT);
ImGuiToolkit::Indication("Large ", 16, 1, ICON_FA_ARROW_RIGHT); ImGuiToolkit::Indication("Large ", 16, 1);
if (ImGui::VSliderInt("##BrushSize", ImVec2(30,260), &pixel_size, pixel_size_min, pixel_size_max, "") ){ if (ImGui::VSliderInt("##BrushSize", ImVec2(30,260), &pixel_size, pixel_size_min, pixel_size_max, "") ){
Settings::application.brush.x = CLAMP(float(pixel_size) / edit_source_->frame()->height(), BRUSH_MIN_SIZE, BRUSH_MAX_SIZE); Settings::application.brush.x = CLAMP(float(pixel_size) / edit_source_->frame()->height(), BRUSH_MIN_SIZE, BRUSH_MAX_SIZE);
} }
@@ -787,7 +792,7 @@ void TextureView::draw()
ImGui::Text("%d px", pixel_size); ImGui::Text("%d px", pixel_size);
ImGui::EndTooltip(); ImGui::EndTooltip();
} }
ImGuiToolkit::Indication("Small ", 15, 1, ICON_FA_ARROW_LEFT); ImGuiToolkit::Indication("Small ", 15, 1);
ImGui::PopFont(); ImGui::PopFont();
ImGui::EndPopup(); ImGui::EndPopup();
} }
@@ -804,14 +809,14 @@ void TextureView::draw()
if (ImGui::BeginPopup("brush_pressure_popup", ImGuiWindowFlags_NoMove)) if (ImGui::BeginPopup("brush_pressure_popup", ImGuiWindowFlags_NoMove))
{ {
ImGuiToolkit::PushFont(ImGuiToolkit::FONT_DEFAULT); ImGuiToolkit::PushFont(ImGuiToolkit::FONT_DEFAULT);
ImGuiToolkit::Indication("Light ", ICON_FA_FEATHER_ALT, ICON_FA_ARROW_UP); ImGuiToolkit::Indication("Light ", ICON_FA_FEATHER_ALT);
ImGui::VSliderFloat("##BrushPressure", ImVec2(30,260), &Settings::application.brush.y, BRUSH_MAX_PRESS, BRUSH_MIN_PRESS, "", 0.3f); ImGui::VSliderFloat("##BrushPressure", ImVec2(30,260), &Settings::application.brush.y, BRUSH_MAX_PRESS, BRUSH_MIN_PRESS, "", 0.3f);
if (ImGui::IsItemHovered() || ImGui::IsItemActive() ) { if (ImGui::IsItemHovered() || ImGui::IsItemActive() ) {
ImGui::BeginTooltip(); ImGui::BeginTooltip();
ImGui::Text("%.1f%%", Settings::application.brush.y * 100.0); ImGui::Text("%.1f%%", Settings::application.brush.y * 100.0);
ImGui::EndTooltip(); ImGui::EndTooltip();
} }
ImGuiToolkit::Indication("Heavy ", ICON_FA_WEIGHT_HANGING, ICON_FA_ARROW_DOWN); ImGuiToolkit::Indication("Heavy ", ICON_FA_WEIGHT_HANGING);
ImGui::PopFont(); ImGui::PopFont();
ImGui::EndPopup(); ImGui::EndPopup();
} }
@@ -924,7 +929,10 @@ void TextureView::draw()
ImGuiToolkit::ToolTip("Select shape"); ImGuiToolkit::ToolTip("Select shape");
ImGui::SameLine(0, 20); ImGui::SameLine(0, 20);
if (ImGui::Button(ICON_FA_RADIATION_ALT ICON_FA_SORT_DOWN ))
char buf[128];
snprintf(buf, 128, "%d%%" ICON_FA_SORT_DOWN, blur_percent);
if (ImGui::Button(buf))
ImGui::OpenPopup("shape_smooth_popup"); ImGui::OpenPopup("shape_smooth_popup");
if (ImGui::IsItemHovered()) if (ImGui::IsItemHovered())
ImGuiToolkit::ToolTip("Blur"); ImGuiToolkit::ToolTip("Blur");
@@ -932,7 +940,7 @@ void TextureView::draw()
{ {
static bool smoothchanged = false; static bool smoothchanged = false;
ImGuiToolkit::PushFont(ImGuiToolkit::FONT_DEFAULT); ImGuiToolkit::PushFont(ImGuiToolkit::FONT_DEFAULT);
ImGuiToolkit::Indication("Blured ", 7, 16, ICON_FA_ARROW_UP); ImGuiToolkit::Indication("Blurry ", 7, 16);
if (ImGui::VSliderInt("##shapeblur", ImVec2(30,260), &blur_percent, 0, 100, "") ){ if (ImGui::VSliderInt("##shapeblur", ImVec2(30,260), &blur_percent, 0, 100, "") ){
edit_source_->maskShader()->blur = float(blur_percent) / 100.f; edit_source_->maskShader()->blur = float(blur_percent) / 100.f;
edit_source_->touch(Source::SourceUpdate_Mask); edit_source_->touch(Source::SourceUpdate_Mask);
@@ -948,10 +956,10 @@ void TextureView::draw()
} }
if (ImGui::IsItemHovered() || ImGui::IsItemActive() ) { if (ImGui::IsItemHovered() || ImGui::IsItemActive() ) {
ImGui::BeginTooltip(); ImGui::BeginTooltip();
ImGui::Text("%.d%%", blur_percent); ImGui::Text("%.d%% blur", blur_percent);
ImGui::EndTooltip(); ImGui::EndTooltip();
} }
ImGuiToolkit::Indication("Sharp ", 8, 16, ICON_FA_ARROW_DOWN); ImGuiToolkit::Indication("Sharp ", 8, 16);
ImGui::PopFont(); ImGui::PopFont();
ImGui::EndPopup(); ImGui::EndPopup();
} }

View File

@@ -3573,6 +3573,7 @@ void Navigator::RenderNewPannel(const ImVec2 &iconsize)
} }
} }
else if (new_media_mode == MEDIA_FOLDER) { else if (new_media_mode == MEDIA_FOLDER) {
ImGui::PushID("##new_media_directory_actions");
// close list // close list
ImGui::SetCursorPos( ImVec2( pannel_width_ IMGUI_RIGHT_ALIGN, pos_top.y) ); ImGui::SetCursorPos( ImVec2( pannel_width_ IMGUI_RIGHT_ALIGN, pos_top.y) );
if (ImGuiToolkit::IconButton( 4, 5, "Close directory")) { if (ImGuiToolkit::IconButton( 4, 5, "Close directory")) {
@@ -3585,7 +3586,6 @@ void Navigator::RenderNewPannel(const ImVec2 &iconsize)
} }
// ordering list // ordering list
ImGui::SetCursorPos( ImVec2( pannel_width_ IMGUI_RIGHT_ALIGN, pos_top.y + ImGui::GetFrameHeightWithSpacing()) ); ImGui::SetCursorPos( ImVec2( pannel_width_ IMGUI_RIGHT_ALIGN, pos_top.y + ImGui::GetFrameHeightWithSpacing()) );
ImGui::PushID("##new_media_mode_changed");
if ( ImGuiToolkit::IconMultistate(icons_ordering_files, &Settings::application.recentImportFolders.ordering, tooltips_ordering_files) ) if ( ImGuiToolkit::IconMultistate(icons_ordering_files, &Settings::application.recentImportFolders.ordering, tooltips_ordering_files) )
new_media_mode_changed = true; new_media_mode_changed = true;
ImGui::PopID(); ImGui::PopID();
@@ -4219,7 +4219,7 @@ void Navigator::RenderMainPannelSession()
if ( ImGuiToolkit::IconButton(ICON_FA_FILE_DOWNLOAD, "Save as")) if ( ImGuiToolkit::IconButton(ICON_FA_FILE_DOWNLOAD, "Save as"))
UserInterface::manager().saveOrSaveAs(); UserInterface::manager().saveOrSaveAs();
} else { } else {
if (ImGuiToolkit::IconButton(ICON_FA_FOLDER_OPEN, "Show in finder")) if (ImGuiToolkit::IconButton(2, 5, "Show in finder"))
SystemToolkit::open(SystemToolkit::path_filename(Mixer::manager().session()->filename())); SystemToolkit::open(SystemToolkit::path_filename(Mixer::manager().session()->filename()));
} }
ImGui::SetCursorPos(pos); ImGui::SetCursorPos(pos);
@@ -4981,7 +4981,9 @@ void Navigator::RenderMainPannelPlaylist()
if ( !ImGui::IsItemHovered()) if ( !ImGui::IsItemHovered())
session_tooltip_ = 0; session_tooltip_ = 0;
// ordering list // Closing and ordering button
ImGui::PushID("##playlist_directory_actions");
// close list
ImGui::SetCursorPos( ImVec2( pannel_width_ IMGUI_RIGHT_ALIGN, pos_top.y) ); ImGui::SetCursorPos( ImVec2( pannel_width_ IMGUI_RIGHT_ALIGN, pos_top.y) );
if (ImGuiToolkit::IconButton( 4, 5, "Close directory")) { if (ImGuiToolkit::IconButton( 4, 5, "Close directory")) {
Settings::application.recentFolders.filenames.remove(Settings::application.recentFolders.path); Settings::application.recentFolders.filenames.remove(Settings::application.recentFolders.path);
@@ -4990,8 +4992,8 @@ void Navigator::RenderMainPannelPlaylist()
else else
Settings::application.recentFolders.assign( Settings::application.recentFolders.filenames.front() ); Settings::application.recentFolders.assign( Settings::application.recentFolders.filenames.front() );
} }
ImGui::SetCursorPos( ImVec2( pannel_width_ IMGUI_RIGHT_ALIGN, pos_top.y + ImGui::GetTextLineHeightWithSpacing())); // ordering list
ImGui::PushID("##folder_ordering_changed"); ImGui::SetCursorPos( ImVec2( pannel_width_ IMGUI_RIGHT_ALIGN, pos_top.y + ImGui::GetFrameHeightWithSpacing()));
if ( ImGuiToolkit::IconMultistate(icons_ordering_files, &Settings::application.recentFolders.ordering, tooltips_ordering_files) ) if ( ImGuiToolkit::IconMultistate(icons_ordering_files, &Settings::application.recentFolders.ordering, tooltips_ordering_files) )
Settings::application.recentFolders.changed = true; Settings::application.recentFolders.changed = true;
ImGui::PopID(); ImGui::PopID();