Setup icon (i,j coordinates in ImGui Toolkit) for each Source class, and

use this icon in GUI to indicate the type of class.
This commit is contained in:
brunoherbelin
2020-10-01 22:57:49 +02:00
parent 467ed23b37
commit 83a2da6b2b
9 changed files with 38 additions and 12 deletions

View File

@@ -512,6 +512,13 @@ DeviceConfigSet Device::getDeviceConfigs(const std::string &src_description)
}
glm::ivec2 DeviceSource::icon() const
{
if ( device_.find("Screen") != std::string::npos )
return glm::ivec2(19, 1);
else
return glm::ivec2(2, 14);
}

View File

@@ -114,6 +114,8 @@ public:
void setDevice(const std::string &devicename);
inline std::string device() const { return device_; }
glm::ivec2 icon() const override;
private:
std::string device_;

View File

@@ -317,7 +317,7 @@ void ImGuiVisitor::visit (MediaSource& s)
void ImGuiVisitor::visit (SessionSource& s)
{
ImGuiToolkit::Icon(3,16);
ImGuiToolkit::Icon(s.icon().x, s.icon().y);
ImGui::SameLine(0, 10);
ImGui::Text("Session File");
@@ -338,7 +338,7 @@ void ImGuiVisitor::visit (SessionSource& s)
void ImGuiVisitor::visit (RenderSource& s)
{
ImGuiToolkit::Icon(19,1);
ImGuiToolkit::Icon(s.icon().x, s.icon().y);
ImGui::SameLine(0, 10);
ImGui::Text("Rendering Output");
if ( ImGui::Button(IMGUI_TITLE_PREVIEW, ImVec2(IMGUI_RIGHT_ALIGN, 0)) )
@@ -347,7 +347,7 @@ void ImGuiVisitor::visit (RenderSource& s)
void ImGuiVisitor::visit (CloneSource& s)
{
ImGuiToolkit::Icon(9,2);
ImGuiToolkit::Icon(s.icon().x, s.icon().y);
ImGui::SameLine(0, 10);
ImGui::Text("Clone");
if ( ImGui::Button(s.origin()->name().c_str(), ImVec2(IMGUI_RIGHT_ALIGN, 0)) )
@@ -356,7 +356,7 @@ void ImGuiVisitor::visit (CloneSource& s)
void ImGuiVisitor::visit (PatternSource& s)
{
ImGuiToolkit::Icon(12,5);
ImGuiToolkit::Icon(s.icon().x, s.icon().y);
ImGui::SameLine(0, 10);
ImGui::Text("Pattern");
@@ -374,7 +374,7 @@ void ImGuiVisitor::visit (PatternSource& s)
void ImGuiVisitor::visit (DeviceSource& s)
{
ImGuiToolkit::Icon(2,14);
ImGuiToolkit::Icon(s.icon().x, s.icon().y);
ImGui::SameLine(0, 10);
ImGui::Text("Device");

View File

@@ -50,6 +50,14 @@ MediaPlayer *MediaSource::mediaplayer() const
return mediaplayer_;
}
glm::ivec2 MediaSource::icon() const
{
if (mediaplayer_->isImage())
return glm::ivec2(2, 9);
else
return glm::ivec2(18, 13);
}
bool MediaSource::failed() const
{
return mediaplayer_->failed();

View File

@@ -24,6 +24,8 @@ public:
std::string path() const;
MediaPlayer *mediaplayer() const;
glm::ivec2 icon() const override;
protected:
void init() override;

View File

@@ -35,6 +35,8 @@ public:
Pattern *pattern() const;
void setPattern(int type, glm::ivec2 resolution);
glm::ivec2 icon() const override { return glm::ivec2(12, 5); }
};
#endif // PATTERNSOURCE_H

View File

@@ -26,6 +26,8 @@ public:
inline std::string path() const { return path_; }
inline Session *session() const { return session_; }
glm::ivec2 icon() const override { return glm::ivec2(3, 16); }
protected:
void init() override;
@@ -54,6 +56,8 @@ public:
uint texture() const override;
void accept (Visitor& v) override;
glm::ivec2 icon() const override { return glm::ivec2(0, 2); }
protected:
void init() override;

View File

@@ -119,6 +119,7 @@ public:
std::string _n;
};
virtual glm::ivec2 icon() const { return glm::ivec2(12, 11); }
protected:
// name
@@ -190,6 +191,8 @@ public:
inline void detach() { origin_ = nullptr; }
inline Source *origin() const { return origin_; }
glm::ivec2 icon() const override { return glm::ivec2(9, 2); }
protected:
// only Source class can create new CloneSource via clone();
CloneSource(Source *origin);

View File

@@ -1891,6 +1891,8 @@ void SourcePreview::Render(float width, bool controlbutton)
source_->setActive(active);
ImGui::SetCursorPos(pos);
}
ImGuiToolkit::Icon(source_->icon().x, source_->icon().y);
ImGui::SameLine(0, 10);
ImGui::Text("%s ", label_.c_str());
ImGui::Text("%d x %d %s", frame->width(), frame->height(), frame->use_alpha() ? "RGBA" : "RGB");
}
@@ -2047,13 +2049,9 @@ void Navigator::RenderNewPannel()
// create preview
if (update_new_source)
{
std::ostringstream oss;
oss << Pattern::pattern_types[pattern_type];
glm::ivec2 res = GlmToolkit::resolutionFromDescription(Settings::application.source.ratio, Settings::application.source.res);
oss << " (" << res.x << " x " << res.y << " px)";
new_source_preview_.setSource( Mixer::manager().createSourcePattern(pattern_type, res), oss.str());
glm::ivec2 res = GlmToolkit::resolutionFromDescription(Settings::application.source.ratio, Settings::application.source.res);
new_source_preview_.setSource( Mixer::manager().createSourcePattern(pattern_type, res),
Pattern::pattern_types[pattern_type]);
}
}
// Hardware