mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-11 18:34:58 +01:00
Cleanup UI - Filters menu, Save-as property
Cleanup code in ImGuiToolkit::IconButton
This commit is contained in:
@@ -208,14 +208,15 @@ bool ImGuiToolkit::ButtonIconToggle(int i, int j, int i_toggle, int j_toggle, bo
|
||||
|
||||
bool ImGuiToolkit::IconButton(int i, int j, const char *tooltip)
|
||||
{
|
||||
ImGui::PushID( i * 20 + j );
|
||||
|
||||
ImGuiWindow* window = ImGui::GetCurrentWindow();
|
||||
if (window->SkipItems)
|
||||
return false;
|
||||
|
||||
ImGui::PushID( i * 20 + j );
|
||||
|
||||
// duplicate of ImGui::InvisibleButton to handle ImGuiButtonFlags_Repeat
|
||||
const ImGuiID id = window->GetID("##iconijbutton");
|
||||
|
||||
float h = ImGui::GetFrameHeight();
|
||||
ImVec2 size = ImGui::CalcItemSize(ImVec2(h, h), 0.0f, 0.0f);
|
||||
ImVec2 draw_pos = window->DC.CursorPos;
|
||||
@@ -233,17 +234,17 @@ bool ImGuiToolkit::IconButton(int i, int j, const char *tooltip)
|
||||
bool hovered, held;
|
||||
bool pressed = ImGui::ButtonBehavior(bb, id, &hovered, &held, flags);
|
||||
|
||||
const ImVec4* colors = ImGui::GetStyle().Colors;
|
||||
if (tooltip != nullptr && hovered)
|
||||
ImGuiToolkit::ToolTip(tooltip);
|
||||
|
||||
// draw with hovered color
|
||||
ImGui::PushStyleColor( ImGuiCol_Text, hovered ? colors[ImGuiCol_NavWindowingHighlight] : colors[ImGuiCol_Text] );
|
||||
ImGui::SetCursorScreenPos(draw_pos);
|
||||
|
||||
// draw icon with hovered color
|
||||
const ImVec4* colors = ImGui::GetStyle().Colors;
|
||||
ImGui::PushStyleColor( ImGuiCol_Text, hovered ? colors[ImGuiCol_NavWindowingHighlight] : colors[ImGuiCol_Text] );
|
||||
Icon(i, j, !pressed);
|
||||
ImGui::PopStyleColor();
|
||||
|
||||
if (tooltip != nullptr && ImGui::IsItemHovered())
|
||||
ImGuiToolkit::ToolTip(tooltip);
|
||||
|
||||
ImGui::PopID();
|
||||
return pressed;
|
||||
}
|
||||
@@ -255,25 +256,23 @@ bool ImGuiToolkit::IconButton(const char* icon, const char *tooltip)
|
||||
ImGui::PushID( icon );
|
||||
|
||||
float frame_height = ImGui::GetFrameHeight();
|
||||
float frame_width = frame_height;
|
||||
|
||||
ImVec2 draw_pos = ImGui::GetCursorScreenPos();
|
||||
|
||||
// toggle action : operate on the whole area
|
||||
ImGui::InvisibleButton("##iconcharbutton", ImVec2(frame_width, frame_height));
|
||||
ImGui::InvisibleButton("##iconcharbutton", ImVec2(frame_height, frame_height));
|
||||
if (ImGui::IsItemClicked())
|
||||
ret = true;
|
||||
if (tooltip != nullptr && ImGui::IsItemHovered())
|
||||
ImGuiToolkit::ToolTip(tooltip);
|
||||
|
||||
ImGui::SetCursorScreenPos(draw_pos);
|
||||
|
||||
// draw with hovered color
|
||||
const ImVec4* colors = ImGui::GetStyle().Colors;
|
||||
ImGui::PushStyleColor( ImGuiCol_Text, ImGui::IsItemHovered() ? colors[ImGuiCol_NavWindowingHighlight] : colors[ImGuiCol_Text] );
|
||||
ImGui::SetCursorScreenPos(draw_pos);
|
||||
ImGui::Text(icon);
|
||||
ImGui::PopStyleColor();
|
||||
|
||||
if (tooltip != nullptr && ImGui::IsItemHovered())
|
||||
ImGuiToolkit::ToolTip(tooltip);
|
||||
|
||||
ImGui::PopID();
|
||||
return ret;
|
||||
}
|
||||
|
||||
133
ImGuiVisitor.cpp
133
ImGuiVisitor.cpp
@@ -260,10 +260,6 @@ void ImGuiVisitor::visit(ImageProcessingShader &n)
|
||||
{
|
||||
ImGui::PushID(std::to_string(n.id()).c_str());
|
||||
|
||||
// ImGuiToolkit::Icon(6, 2);
|
||||
// ImGui::SameLine(0, IMGUI_SAME_LINE);
|
||||
// ImGui::Text("Filters");
|
||||
|
||||
if (ImGuiToolkit::IconButton(6, 4)) {
|
||||
n.gamma = glm::vec4(1.f, 1.f, 1.f, 1.f);
|
||||
Action::manager().store("Gamma & Color");
|
||||
@@ -482,86 +478,89 @@ void ImGuiVisitor::visit (Source& s)
|
||||
}
|
||||
}
|
||||
|
||||
// toggle enable/disable image processing
|
||||
// Filter
|
||||
bool on = s.imageProcessingEnabled();
|
||||
ImGui::SetCursorPos( ImVec2( pos.x, pos.y + preview_height));
|
||||
if ( ImGuiToolkit::ButtonIconToggle(6, 2, 6, 2, &on) ){
|
||||
std::ostringstream oss;
|
||||
oss << s.name() << ": " << ( on ? "Enable Filter" : "Disable Filter");
|
||||
Action::manager().store(oss.str());
|
||||
if (on) {
|
||||
ImGuiToolkit::Icon(6, 2); ImGui::SameLine(0, IMGUI_SAME_LINE); ImGui::Text("Filters");
|
||||
}
|
||||
else {
|
||||
ImGuiToolkit::Indication("Filters disabled", 6, 2);
|
||||
ImGui::SameLine(0, IMGUI_SAME_LINE);ImGui::TextDisabled("Filters");
|
||||
}
|
||||
s.setImageProcessingEnabled(on);
|
||||
|
||||
ImGui::SameLine(0, IMGUI_SAME_LINE);
|
||||
ImGui::Text("Filters");
|
||||
pos = ImGui::GetCursorPos();
|
||||
|
||||
// image processing pannel
|
||||
if (s.imageProcessingEnabled()) {
|
||||
// menu icon for image processing
|
||||
ImGui::SameLine(preview_width, 2 * IMGUI_SAME_LINE);
|
||||
if (ImGuiToolkit::IconButton(5, 8))
|
||||
ImGui::OpenPopup( "MenuImageProcessing" );
|
||||
|
||||
// menu icon for image processing
|
||||
ImGui::SameLine(preview_width, 2 * IMGUI_SAME_LINE);
|
||||
if (ImGuiToolkit::IconButton(5, 8))
|
||||
ImGui::OpenPopup( "MenuImageProcessing" );
|
||||
if (ImGui::BeginPopup( "MenuImageProcessing" ))
|
||||
{
|
||||
if (s.processingshader_link_.connected()) {
|
||||
if (ImGui::MenuItem( "Unfollow" )){
|
||||
s.processingshader_link_.disconnect();
|
||||
}
|
||||
if (ImGui::BeginPopup( "MenuImageProcessing" ))
|
||||
{
|
||||
if (ImGui::MenuItem("Enable", NULL, &on)) {
|
||||
std::ostringstream oss;
|
||||
oss << s.name() << ": " << ( on ? "Enable Filter" : "Disable Filter");
|
||||
Action::manager().store(oss.str());
|
||||
s.setImageProcessingEnabled(on);
|
||||
}
|
||||
|
||||
if (s.processingshader_link_.connected()) {
|
||||
if (ImGui::MenuItem( "Unfollow", NULL, false, on)){
|
||||
s.processingshader_link_.disconnect();
|
||||
}
|
||||
else {
|
||||
if (ImGui::MenuItem("Reset" )){
|
||||
ImageProcessingShader defaultvalues;
|
||||
s.processingShader()->copy(defaultvalues);
|
||||
s.processingshader_link_.disconnect();
|
||||
std::ostringstream oss;
|
||||
oss << s.name() << ": " << "Reset Filter";
|
||||
Action::manager().store(oss.str());
|
||||
}
|
||||
if (ImGui::MenuItem("Copy" )){
|
||||
std::string clipboard = SessionVisitor::getClipboard(s.processingShader());
|
||||
if (!clipboard.empty())
|
||||
ImGui::SetClipboardText(clipboard.c_str());
|
||||
}
|
||||
const char *clipboard = ImGui::GetClipboardText();
|
||||
const bool can_paste = (clipboard != nullptr && SessionLoader::isClipboard(clipboard));
|
||||
if (ImGui::MenuItem("Paste", NULL, false, can_paste)) {
|
||||
SessionLoader::applyImageProcessing(s, clipboard);
|
||||
std::ostringstream oss;
|
||||
oss << s.name() << ": " << "Change Filter";
|
||||
Action::manager().store(oss.str());
|
||||
}
|
||||
// ImGui::Separator();
|
||||
// if (ImGui::BeginMenu("Follow"))
|
||||
}
|
||||
else {
|
||||
if (ImGui::MenuItem("Reset", NULL, false, on )){
|
||||
ImageProcessingShader defaultvalues;
|
||||
s.processingShader()->copy(defaultvalues);
|
||||
s.processingshader_link_.disconnect();
|
||||
std::ostringstream oss;
|
||||
oss << s.name() << ": " << "Reset Filter";
|
||||
Action::manager().store(oss.str());
|
||||
}
|
||||
if (ImGui::MenuItem("Copy", NULL, false, on )){
|
||||
std::string clipboard = SessionVisitor::getClipboard(s.processingShader());
|
||||
if (!clipboard.empty())
|
||||
ImGui::SetClipboardText(clipboard.c_str());
|
||||
}
|
||||
const char *clipboard = ImGui::GetClipboardText();
|
||||
const bool can_paste = (clipboard != nullptr && SessionLoader::isClipboard(clipboard));
|
||||
if (ImGui::MenuItem("Paste", NULL, false, can_paste)) {
|
||||
SessionLoader::applyImageProcessing(s, clipboard);
|
||||
std::ostringstream oss;
|
||||
oss << s.name() << ": " << "Change Filter";
|
||||
Action::manager().store(oss.str());
|
||||
}
|
||||
// // NON-stable style follow mechanism
|
||||
// ImGui::Separator();
|
||||
// if (ImGui::BeginMenu("Follow", on))
|
||||
// {
|
||||
// for (auto mpit = Mixer::manager().session()->begin();
|
||||
// mpit != Mixer::manager().session()->end(); mpit++ )
|
||||
// {
|
||||
// for (auto mpit = Mixer::manager().session()->begin();
|
||||
// mpit != Mixer::manager().session()->end(); mpit++ )
|
||||
// {
|
||||
// std::string label = (*mpit)->name();
|
||||
// if ( (*mpit)->id() != s.id() &&
|
||||
// (*mpit)->imageProcessingEnabled() &&
|
||||
// !(*mpit)->processingshader_link_.connected()) {
|
||||
// if (ImGui::MenuItem( label.c_str() )){
|
||||
// s.processingshader_link_.connect(*mpit);
|
||||
// s.touch();
|
||||
// }
|
||||
// std::string label = (*mpit)->name();
|
||||
// if ( (*mpit)->id() != s.id() &&
|
||||
// (*mpit)->imageProcessingEnabled() &&
|
||||
// !(*mpit)->processingshader_link_.connected()) {
|
||||
// if (ImGui::MenuItem( label.c_str() )){
|
||||
// s.processingshader_link_.connect(*mpit);
|
||||
// s.touch();
|
||||
// }
|
||||
// }
|
||||
// ImGui::EndMenu();
|
||||
// }
|
||||
}
|
||||
|
||||
ImGui::EndPopup();
|
||||
// ImGui::EndMenu();
|
||||
// }
|
||||
}
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
if (s.imageProcessingEnabled()) {
|
||||
|
||||
// full panel for image processing
|
||||
ImGui::SetCursorPos( pos );
|
||||
|
||||
if (s.processingshader_link_.connected()) {
|
||||
ImGuiToolkit::Icon(6, 2);
|
||||
ImGui::SameLine(0, IMGUI_SAME_LINE);
|
||||
ImGui::Text("Filters");
|
||||
Source *target = s.processingshader_link_.source();
|
||||
ImGui::Text("Following");
|
||||
if ( target != nullptr && ImGui::Button(target->name().c_str(), ImVec2(IMGUI_RIGHT_ALIGN, 0)) )
|
||||
|
||||
@@ -5355,8 +5355,14 @@ void Navigator::RenderMainPannelVimix()
|
||||
ImGui::InputText("Height", dummy_str, IM_ARRAYSIZE(dummy_str), ImGuiInputTextFlags_ReadOnly);
|
||||
ImGui::PopStyleColor(1);
|
||||
}
|
||||
// offer to change ratio and resolution
|
||||
// offer to change filename, ratio and resolution
|
||||
else {
|
||||
ImVec2 draw_pos = ImGui::GetCursorScreenPos();
|
||||
ImGui::SameLine();
|
||||
if ( ImGuiToolkit::IconButton(ICON_FA_FILE_DOWNLOAD, "Save as" )) {
|
||||
UserInterface::manager().selectSaveFilename();
|
||||
}
|
||||
ImGui::SetCursorScreenPos(draw_pos);
|
||||
// combo boxes to select Rario and Height
|
||||
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
||||
if (ImGui::Combo("Ratio", &p.x, FrameBuffer::aspect_ratio_name, IM_ARRAYSIZE(FrameBuffer::aspect_ratio_name) ) )
|
||||
|
||||
Reference in New Issue
Block a user