Improve UX List of New source type to insert

New icons for inserted source panel. Merged loopback into connected list. Removed 'internal' new source.
This commit is contained in:
Bruno Herbelin
2023-08-12 20:47:26 +02:00
parent 2a4be39c9a
commit 09dbc5c84e
7 changed files with 31 additions and 62 deletions

Binary file not shown.

View File

@@ -541,9 +541,9 @@ bool ImGuiToolkit::ComboIcon (const char* label, int* current_item, std::vector<
if ( ImGui::BeginCombo( label, text_buf, ImGuiComboFlags_None) ) { if ( ImGui::BeginCombo( label, text_buf, ImGuiComboFlags_None) ) {
for (int p = 0; p < (int) items.size(); ++p){ for (int p = 0; p < (int) items.size(); ++p){
ImGui::PushID((void*)(intptr_t)p); ImGui::PushID((void*)(intptr_t)p);
if (ImGuiToolkit::SelectableIcon( "", if (ImGuiToolkit::SelectableIcon( std::get<0>( items.at(p) ),
std::get<0>( items.at(p) ),
std::get<1>( items.at(p) ), std::get<1>( items.at(p) ),
"",
p == *current_item) ) { p == *current_item) ) {
*current_item = p; *current_item = p;
ret = true; ret = true;
@@ -560,9 +560,9 @@ bool ImGuiToolkit::ComboIcon (const char* label, int* current_item, std::vector<
if ( ImGui::BeginCombo( label, text_buf, ImGuiComboFlags_None) ) { if ( ImGui::BeginCombo( label, text_buf, ImGuiComboFlags_None) ) {
for (int p = 0; p < (int) items.size(); ++p){ for (int p = 0; p < (int) items.size(); ++p){
ImGui::PushID((void*)(intptr_t)p); ImGui::PushID((void*)(intptr_t)p);
if (ImGuiToolkit::SelectableIcon( std::get<2>( items.at(p) ).c_str(), if (ImGuiToolkit::SelectableIcon( std::get<0>( items.at(p) ),
std::get<0>( items.at(p) ),
std::get<1>( items.at(p) ), std::get<1>( items.at(p) ),
std::get<2>( items.at(p) ).c_str(),
p == *current_item) ) { p == *current_item) ) {
*current_item = p; *current_item = p;
ret = true; ret = true;
@@ -579,7 +579,7 @@ bool ImGuiToolkit::ComboIcon (const char* label, int* current_item, std::vector<
return ret; return ret;
} }
bool ImGuiToolkit::SelectableIcon(const char* label, int i, int j, bool selected) bool ImGuiToolkit::SelectableIcon(int i, int j, const char* label, bool selected, const ImVec2 &size_arg)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
ImVec2 draw_pos = ImGui::GetCursorScreenPos() - g.Style.FramePadding * 0.5; ImVec2 draw_pos = ImGui::GetCursorScreenPos() - g.Style.FramePadding * 0.5;
@@ -588,15 +588,19 @@ bool ImGuiToolkit::SelectableIcon(const char* label, int i, int j, bool selected
char space_buf[] = " "; char space_buf[] = " ";
const ImVec2 space_size = ImGui::CalcTextSize(" ", NULL); const ImVec2 space_size = ImGui::CalcTextSize(" ", NULL);
const int space_num = static_cast<int>( ceil(g.FontSize / space_size.x) ); const int space_num = static_cast<int>( ceil(g.FontSize / space_size.x) );
space_buf[space_num]='\0'; space_buf[space_num+1]='\0';
char text_buf[256]; char text_buf[256];
ImFormatString(text_buf, IM_ARRAYSIZE(text_buf), "%s %s", space_buf, label); ImFormatString(text_buf, IM_ARRAYSIZE(text_buf), "%s%s", space_buf, label);
// draw menu item // draw menu item
bool ret = ImGui::Selectable(text_buf, selected); bool ret = ImGui::Selectable(text_buf, selected, ImGuiSelectableFlags_None, size_arg);
// overlay of icon on top of first item // center icon vertically
draw_pos.y += size_arg.y > 0 ? (size_arg.y - space_size.y) * 0.5 : 0.0;
draw_pos.x += size_arg.x > 0 ? (size_arg.x - g.FontSize) * 0.5 : 0.0;
// overlay of icon on top of first item
_drawIcon(draw_pos, i, j); _drawIcon(draw_pos, i, j);
return ret; return ret;

View File

@@ -28,7 +28,7 @@ namespace ImGuiToolkit
bool ButtonIconToggle (int i, int j, int i_toggle, int j_toggle, bool* toggle, const char *tooltip = nullptr); bool ButtonIconToggle (int i, int j, int i_toggle, int j_toggle, bool* toggle, const char *tooltip = nullptr);
bool ButtonIconMultistate (std::vector<std::pair<int, int> > icons, int* state, std::vector<std::string> tooltips); bool ButtonIconMultistate (std::vector<std::pair<int, int> > icons, int* state, std::vector<std::string> tooltips);
bool MenuItemIcon (int i, int j, const char* label, const char* shortcut = nullptr, bool selected = false, bool enabled = true); bool MenuItemIcon (int i, int j, const char* label, const char* shortcut = nullptr, bool selected = false, bool enabled = true);
bool SelectableIcon(const char* label, int i, int j, bool selected = false); bool SelectableIcon(int i, int j, const char* label, bool selected, const ImVec2& size_arg = ImVec2(0,0));
bool ComboIcon (const char* label, int* current_item, std::vector<std::tuple<int, int, std::string> > items, bool tooltiptext = false); bool ComboIcon (const char* label, int* current_item, std::vector<std::tuple<int, int, std::string> > items, bool tooltiptext = false);
// buttons // buttons

View File

@@ -923,7 +923,7 @@ void ImGuiVisitor::visit (RenderSource& s)
} }
// icon to open output view // icon to open output view
ImGui::SetCursorPos(top); ImGui::SetCursorPos(top);
if (ImGuiToolkit::IconButton(ICON_FA_LAPTOP, "Show Output")) if (ImGuiToolkit::IconButton(ICON_FA_LAPTOP, "Open Display"))
Settings::application.widget.preview = true; Settings::application.widget.preview = true;
} }
else else

View File

@@ -175,5 +175,5 @@ glm::ivec2 RenderSource::icon() const
std::string RenderSource::info() const std::string RenderSource::info() const
{ {
return "Rendering Output"; return "Display loopback";
} }

View File

@@ -68,7 +68,6 @@
#include "Mixer.h" #include "Mixer.h"
#include "Recorder.h" #include "Recorder.h"
#include "SourceCallback.h" #include "SourceCallback.h"
#include "CloneSource.h"
#include "MediaSource.h" #include "MediaSource.h"
#include "PatternSource.h" #include "PatternSource.h"
#include "DeviceSource.h" #include "DeviceSource.h"
@@ -3103,14 +3102,11 @@ void Navigator::RenderSourcePannel(Source *s)
// prepare panel for new source of same type // prepare panel for new source of same type
MediaSource *file = dynamic_cast<MediaSource *>(s); MediaSource *file = dynamic_cast<MediaSource *>(s);
MultiFileSource *sequence = dynamic_cast<MultiFileSource *>(s); MultiFileSource *sequence = dynamic_cast<MultiFileSource *>(s);
CloneSource *internal = dynamic_cast<CloneSource *>(s);
PatternSource *generated = dynamic_cast<PatternSource *>(s); PatternSource *generated = dynamic_cast<PatternSource *>(s);
if (file != nullptr) if (file != nullptr)
Settings::application.source.new_type = SOURCE_FILE; Settings::application.source.new_type = SOURCE_FILE;
else if (sequence != nullptr) else if (sequence != nullptr)
Settings::application.source.new_type = SOURCE_SEQUENCE; Settings::application.source.new_type = SOURCE_SEQUENCE;
else if (internal != nullptr)
Settings::application.source.new_type = SOURCE_INTERNAL;
else if (generated != nullptr) else if (generated != nullptr)
Settings::application.source.new_type = SOURCE_GENERATED; Settings::application.source.new_type = SOURCE_GENERATED;
else else
@@ -3199,30 +3195,27 @@ void Navigator::RenderNewPannel()
ImGui::Columns(5, NULL, false); ImGui::Columns(5, NULL, false);
bool selected_type[5] = {0}; bool selected_type[5] = {0};
selected_type[Settings::application.source.new_type] = true; selected_type[Settings::application.source.new_type] = true;
if (ImGui::Selectable( ICON_FA_PHOTO_VIDEO, &selected_type[SOURCE_FILE], 0, iconsize)) { if (ImGuiToolkit::SelectableIcon( 2, 5, "##SOURCE_FILE", selected_type[SOURCE_FILE], iconsize)) {
Settings::application.source.new_type = SOURCE_FILE; Settings::application.source.new_type = SOURCE_FILE;
clearNewPannel(); clearNewPannel();
} }
ImGui::NextColumn(); ImGui::NextColumn();
if (ImGui::Selectable( ICON_FA_IMAGES, &selected_type[SOURCE_SEQUENCE], 0, iconsize)) { if (ImGuiToolkit::SelectableIcon( 3, 9, "##SOURCE_SEQUENCE", selected_type[SOURCE_SEQUENCE], iconsize)) {
Settings::application.source.new_type = SOURCE_SEQUENCE; Settings::application.source.new_type = SOURCE_SEQUENCE;
clearNewPannel(); clearNewPannel();
} }
ImGui::NextColumn(); ImGui::NextColumn();
if (ImGui::Selectable( ICON_FA_PLUG, &selected_type[SOURCE_CONNECTED], 0, iconsize)) { if (ImGuiToolkit::SelectableIcon( 10, 9, "##SOURCE_CONNECTED", selected_type[SOURCE_CONNECTED], iconsize)) {
Settings::application.source.new_type = SOURCE_CONNECTED; Settings::application.source.new_type = SOURCE_CONNECTED;
clearNewPannel(); clearNewPannel();
} }
ImGui::NextColumn(); ImGui::NextColumn();
if (ImGui::Selectable( ICON_FA_COGS, &selected_type[SOURCE_GENERATED], 0, iconsize)) { if (ImGuiToolkit::SelectableIcon( 11, 5, "##SOURCE_GENERATED", selected_type[SOURCE_GENERATED], iconsize)) {
Settings::application.source.new_type = SOURCE_GENERATED; Settings::application.source.new_type = SOURCE_GENERATED;
clearNewPannel(); clearNewPannel();
} }
ImGui::NextColumn(); ImGui::NextColumn();
if (ImGui::Selectable( ICON_FA_RETWEET, &selected_type[SOURCE_INTERNAL], 0, iconsize)) {
Settings::application.source.new_type = SOURCE_INTERNAL;
clearNewPannel();
}
ImGui::Columns(1); ImGui::Columns(1);
ImGui::PopStyleVar(); ImGui::PopStyleVar();
@@ -3437,7 +3430,7 @@ void Navigator::RenderNewPannel()
static MultiFileRecorder _video_recorder; static MultiFileRecorder _video_recorder;
static int _fps = 25; static int _fps = 25;
ImGui::Text("Create image sequence:"); ImGui::Text("Load image sequence:");
// clic button to load file // clic button to load file
if ( ImGui::Button( ICON_FA_FOLDER_OPEN " Open multiple", ImVec2(ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN, 0)) ) { if ( ImGui::Button( ICON_FA_FOLDER_OPEN " Open multiple", ImVec2(ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN, 0)) ) {
@@ -3570,55 +3563,23 @@ void Navigator::RenderNewPannel()
} }
// Internal Source creator
else if (Settings::application.source.new_type == SOURCE_INTERNAL){
ImGui::Text("Loopback object:");
// fill new_source_preview with a new source
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
if (ImGui::BeginCombo("##Source", "Select"))
{
std::string label = "Rendering Loopback";
if (ImGui::Selectable( label.c_str() )) {
new_source_preview_.setSource( Mixer::manager().createSourceRender(), label);
}
SourceList::iterator iter;
for (iter = Mixer::manager().session()->begin(); iter != Mixer::manager().session()->end(); ++iter)
{
label = std::string("Source ") + (*iter)->initials() + " - " + (*iter)->name();
if (ImGui::Selectable( label.c_str() )) {
label = std::string("Clone of ") + label;
new_source_preview_.setSource( Mixer::manager().createSourceClone((*iter)->name(), false),label);
}
}
ImGui::EndCombo();
}
// Indication
ImGui::SameLine();
ImGuiToolkit::HelpToolTip("Create a source replicating internal vimix objects.\n"
ICON_FA_CARET_RIGHT " Loopback from output\n"
ICON_FA_CARET_RIGHT " Clone other sources");
}
// Generated Source creator
else if (Settings::application.source.new_type == SOURCE_GENERATED){ else if (Settings::application.source.new_type == SOURCE_GENERATED){
bool update_new_source = false; bool update_new_source = false;
ImGui::Text("Generate graphics:"); ImGui::Text("Generate graphic patterns:");
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
if (ImGui::BeginCombo("##Pattern", "Select", ImGuiComboFlags_HeightLarge)) if (ImGui::BeginCombo("##Pattern", "Select", ImGuiComboFlags_HeightLarge))
{ {
if ( ImGui::Selectable("Custom " ICON_FA_CARET_RIGHT) ) { if ( ImGui::Selectable("Custom " ICON_FA_PLAY_CIRCLE) ) {
update_new_source = true; update_new_source = true;
custom_pipeline = true; custom_pipeline = true;
pattern_type = -1; pattern_type = -1;
} }
for (int p = 0; p < (int) Pattern::count(); ++p){ for (int p = 0; p < (int) Pattern::count(); ++p){
pattern_descriptor pattern = Pattern::get(p); pattern_descriptor pattern = Pattern::get(p);
std::string label = pattern.label + (pattern.animated ? " " ICON_FA_CARET_RIGHT : " "); std::string label = pattern.label + (pattern.animated ? " " ICON_FA_PLAY_CIRCLE : " ");
if (pattern.available && ImGui::Selectable( label.c_str(), p == pattern_type )) { if (pattern.available && ImGui::Selectable( label.c_str(), p == pattern_type )) {
update_new_source = true; update_new_source = true;
custom_pipeline = false; custom_pipeline = false;
@@ -3715,6 +3676,10 @@ void Navigator::RenderNewPannel()
} }
} }
if ( ImGui::Selectable("Display Loopback") ) {
new_source_preview_.setSource( Mixer::manager().createSourceRender(), "Display Loopback");
}
if ( ImGui::Selectable("SRT Broadcaster") ) { if ( ImGui::Selectable("SRT Broadcaster") ) {
new_source_preview_.setSource(); new_source_preview_.setSource();
custom_connected = true; custom_connected = true;
@@ -3732,7 +3697,8 @@ void Navigator::RenderNewPannel()
ImGuiToolkit::HelpToolTip("Create a source capturing video streams from connected devices or machines;\n" ImGuiToolkit::HelpToolTip("Create a source capturing video streams from connected devices or machines;\n"
ICON_FA_CARET_RIGHT " webcams or frame grabbers\n" ICON_FA_CARET_RIGHT " webcams or frame grabbers\n"
ICON_FA_CARET_RIGHT " screen capture\n" ICON_FA_CARET_RIGHT " screen capture\n"
ICON_FA_CARET_RIGHT " shared by vimix on local network\n" ICON_FA_CARET_RIGHT " vimix display loopback\n"
ICON_FA_CARET_RIGHT " vimix Peer-to-peer in local network\n"
ICON_FA_CARET_RIGHT " broadcasted with SRT over network."); ICON_FA_CARET_RIGHT " broadcasted with SRT over network.");
if (custom_connected) { if (custom_connected) {

View File

@@ -77,7 +77,6 @@ public:
SOURCE_SEQUENCE, SOURCE_SEQUENCE,
SOURCE_CONNECTED, SOURCE_CONNECTED,
SOURCE_GENERATED, SOURCE_GENERATED,
SOURCE_INTERNAL,
SOURCE_TYPES SOURCE_TYPES
} NewSourceType; } NewSourceType;