Improve UI in views

Eye candy and clarified tooltips for UI and menus in Geometry, layer and texture views
This commit is contained in:
Bruno Herbelin
2024-11-03 10:38:48 +01:00
parent 563f56d2a2
commit 68c39290ec
4 changed files with 48 additions and 41 deletions

View File

@@ -312,31 +312,30 @@ void GeometryView::draw()
ImGui::PushStyleColor(ImGuiCol_PopupBg, ImVec4(0.14f, 0.14f, 0.14f, 0.9f));
// toggle sources visibility flag
std::string _label = "Show sources outside mixing circle (" + std::to_string(hidden_count_)
+ " source" + (hidden_count_>1?"s ":" ") + "not visible " + ICON_FA_MOON + ")";
std::string _label = Settings::application.views[mode_].ignore_mix ? "Show " : "Hide ";
_label += "non visible sources\n(";
_label += std::to_string(hidden_count_) + " source" + (hidden_count_>1?"s are ":" is ") + "outside mixing circle)";
ImGuiToolkit::ButtonIconToggle(12, 0, &Settings::application.views[mode_].ignore_mix, _label.c_str());
// select layers visibility
static std::vector< std::string > _tooltips = {
{"Sources in Background layer"},
{"Sources in Workspace layer"},
{"Sources in Foreground layer"},
{"Sources in all layers (total)"}
};
std::vector< std::tuple<int, int, std::string> > _workspaces = {
{ICON_WORKSPACE_BACKGROUND, std::to_string( workspaces_counts_[Source::WORKSPACE_BACKGROUND] )},
{ICON_WORKSPACE_CENTRAL, std::to_string( workspaces_counts_[Source::WORKSPACE_CENTRAL] )},
{ICON_WORKSPACE_FOREGROUND, std::to_string( workspaces_counts_[Source::WORKSPACE_FOREGROUND] )},
{ICON_WORKSPACE, std::to_string( workspaces_counts_[Source::WORKSPACE_ANY] )}
static std::vector<std::tuple<int, int, std::string> > _workspaces
= {{ICON_WORKSPACE_BACKGROUND, "Show only sources in\nBackground layer ("},
{ICON_WORKSPACE_CENTRAL, "Show only sources in\nWorkspace layer ("},
{ICON_WORKSPACE_FOREGROUND, "Show only sources in\nForeground layer ("},
{ICON_WORKSPACE, "Show sources in all layers ("}
};
ImGui::SameLine(0, IMGUI_SAME_LINE);
ImGui::SetNextItemWidth( ImGui::GetTextLineHeightWithSpacing() * 2.6);
if ( ImGuiToolkit::ComboIcon ("##WORKSPACE", &Settings::application.current_workspace, _workspaces, _tooltips) ){
// need full update
Mixer::manager().setView(mode_);
std::ostringstream oss;
oss << std::get<2>(_workspaces[Settings::application.current_workspace]);
oss << std::to_string(workspaces_counts_[Settings::application.current_workspace]);
oss << ")";
if (ImGuiToolkit::ButtonIcon(std::get<0>(
_workspaces[Settings::application.current_workspace]),
std::get<1>(
_workspaces[Settings::application.current_workspace]),
oss.str().c_str() )) {
Settings::application.current_workspace = (Settings::application.current_workspace+1)%4;
}
if ( ImGui::IsItemHovered() )
ImGuiToolkit::ToolTip("Show sources per layer");
ImGui::PopStyleColor(6);
ImGui::End();
@@ -1617,8 +1616,8 @@ View::Cursor GeometryView::over(glm::vec2 pos)
Source *current = Mixer::manager().currentSource();
if (current != nullptr) {
// reset mouse over handles
current->handles_[mode_][Handles::EDIT_CROP]->color = glm::vec4(COLOR_HIGHLIGHT_SOURCE, 1.f);
current->handles_[mode_][Handles::EDIT_SHAPE]->color = glm::vec4(COLOR_HIGHLIGHT_SOURCE, 1.f);
current->handles_[mode_][Handles::EDIT_CROP]->color = glm::vec4(COLOR_HIGHLIGHT_SOURCE, 0.6f);
current->handles_[mode_][Handles::EDIT_SHAPE]->color = glm::vec4(COLOR_HIGHLIGHT_SOURCE, 0.6f);
// picking visitor found nodes?
if (!pv.empty()) {
@@ -1635,11 +1634,10 @@ View::Cursor GeometryView::over(glm::vec2 pos)
}
}
// mouse over handles
const ImVec4 h = ImGuiToolkit::HighlightColor();
if (pick.first == current->handles_[mode_][Handles::EDIT_CROP])
current->handles_[mode_][Handles::EDIT_CROP]->color = glm::vec4(h.x, h.y, h.z, 1.f);
current->handles_[mode_][Handles::EDIT_CROP]->color = glm::vec4(COLOR_HIGHLIGHT_SOURCE, 1.f);
else if (pick.first == current->handles_[mode_][Handles::EDIT_SHAPE])
current->handles_[mode_][Handles::EDIT_SHAPE]->color = glm::vec4(h.x, h.y, h.z, 1.f);
current->handles_[mode_][Handles::EDIT_SHAPE]->color = glm::vec4(COLOR_HIGHLIGHT_SOURCE, 1.f);
}
}

View File

@@ -391,9 +391,11 @@ View::Cursor LayerView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::pair
current_action_ = s->name() + ": " + info.str();
if ( d > LAYER_FOREGROUND )
info << "\n (Foreground)";
info << "\n (Foreground layer)";
else if ( d < LAYER_BACKGROUND )
info << "\n (Background)";
info << "\n (Background layer)";
else
info << "\n (Workspace layer)";
return Cursor(Cursor_ResizeNESW, info.str() );
}

View File

@@ -228,7 +228,7 @@ Source::Source(uint64_t id) : SourceCore(), id_(id), ready_(false), symbol_(null
handles_[View::GEOMETRY][Handles::SCALE]->translation_.z = 0.1;
transform_manipulator->attach(handles_[View::GEOMETRY][Handles::SCALE]);
handles_[View::GEOMETRY][Handles::EDIT_SHAPE] = new Handles(Handles::EDIT_SHAPE);
handles_[View::GEOMETRY][Handles::EDIT_SHAPE]->color = glm::vec4(COLOR_HIGHLIGHT_SOURCE, 1.f);
handles_[View::GEOMETRY][Handles::EDIT_SHAPE]->color = glm::vec4(COLOR_HIGHLIGHT_SOURCE, 0.6f);
handles_[View::GEOMETRY][Handles::EDIT_SHAPE]->translation_.z = 0.1;
transform_manipulator->attach(handles_[View::GEOMETRY][Handles::EDIT_SHAPE]);
@@ -263,7 +263,7 @@ Source::Source(uint64_t id) : SourceCore(), id_(id), ready_(false), symbol_(null
handles_[View::GEOMETRY][Handles::ROUNDING]->translation_.z = 0.1;
node_manipulator->attach(handles_[View::GEOMETRY][Handles::ROUNDING]);
handles_[View::GEOMETRY][Handles::EDIT_CROP] = new Handles(Handles::EDIT_CROP);
handles_[View::GEOMETRY][Handles::EDIT_CROP]->color = glm::vec4(COLOR_HIGHLIGHT_SOURCE, 1.f);
handles_[View::GEOMETRY][Handles::EDIT_CROP]->color = glm::vec4(COLOR_HIGHLIGHT_SOURCE, 0.6f);
handles_[View::GEOMETRY][Handles::EDIT_CROP]->translation_.z = 0.1;
node_manipulator->attach(handles_[View::GEOMETRY][Handles::EDIT_CROP]);

View File

@@ -668,11 +668,16 @@ void TextureView::draw()
int maskmode = edit_source_->maskShader()->mode;
ImGui::SetNextItemWidth( ImGui::GetTextLineHeightWithSpacing() * 2.6);
if (ImGui::BeginCombo("##Mask", MaskShader::mask_icons[maskmode])) {
if (ImGui::Button( std::string(std::string(MaskShader::mask_icons[maskmode])+" "+ICON_FA_SORT_DOWN ).c_str()))
ImGui::OpenPopup( "Mask_menu_popup" );
if (ImGui::IsItemHovered())
ImGuiToolkit::ToolTip(MaskShader::mask_names[maskmode]);
if (ImGui::BeginPopup( "Mask_menu_popup" ))
{
ImGuiToolkit::PushFont(ImGuiToolkit::FONT_DEFAULT);
for (int m = MaskShader::NONE; m <= MaskShader::SOURCE; ++m){
if (ImGui::Selectable( MaskShader::mask_icons[m] )) {
if (ImGui::Selectable( std::string(std::string(MaskShader::mask_icons[m])
+ " " + MaskShader::mask_names[m]).c_str()) ) {
// on change of mode
if (maskmode != m) {
// cancel previous source mask
@@ -696,25 +701,26 @@ void TextureView::draw()
std::ostringstream oss;
oss << edit_source_->name() << ": " << MaskShader::mask_names[maskmode];
Action::manager().store(oss.str());
// force take control of source for NONE and SOURCE modes
if (maskmode == MaskShader::NONE || maskmode == MaskShader::SOURCE)
// select source depending on mode and tool
if ((maskmode == MaskShader::SHAPE && mask_cursor_shape_) ||
(maskmode == MaskShader::PAINT && mask_cursor_paint_))
Mixer::manager().unsetCurrentSource();
else
Mixer::manager().setCurrentSource(edit_source_);
}
}
if (ImGui::IsItemHovered())
ImGuiToolkit::ToolTip(MaskShader::mask_names[m]);
}
ImGui::EndCombo();
ImGui::PopFont();
ImGui::EndPopup();
}
if (ImGui::IsItemHovered())
ImGuiToolkit::ToolTip(MaskShader::mask_names[maskmode]);
// GUI for selecting source mask
if (maskmode == MaskShader::SOURCE) {
ImGui::SameLine(0, 60);
bool on = true;
ImGuiToolkit::ButtonToggle(ICON_FA_MOUSE_POINTER, &on, "Edit texture");
if (ImGuiToolkit::ButtonToggle(ICON_FA_MOUSE_POINTER, &on, "Edit texture"))
Mixer::manager().setCurrentSource(edit_source_);
// List of sources
ImGui::SameLine(0, 60);
@@ -1012,7 +1018,8 @@ void TextureView::draw()
// always active mouse pointer
ImGui::SameLine(0, 60);
bool on = true;
ImGuiToolkit::ButtonToggle(ICON_FA_MOUSE_POINTER, &on, "Edit texture");
if (ImGuiToolkit::ButtonToggle(ICON_FA_MOUSE_POINTER, &on, "Edit texture"))
Mixer::manager().setCurrentSource(edit_source_);
ImGui::SameLine(0, 60);
ImGui::TextDisabled( "No mask" );
}