Cleanup ImguiVisitor & image shaders interface

This commit is contained in:
brunoherbelin
2020-04-28 13:55:52 +02:00
parent 203ee4bea9
commit 091eceefe5
4 changed files with 10 additions and 9 deletions

View File

@@ -115,8 +115,6 @@ void ImGuiVisitor::visit(MediaPlayer &n)
void ImGuiVisitor::visit(Shader &n) void ImGuiVisitor::visit(Shader &n)
{ {
float width = ImGui::GetContentRegionAvail().x;
ImGui::PushID(n.id()); ImGui::PushID(n.id());
if (ImGuiToolkit::ButtonIcon(10, 2)) { if (ImGuiToolkit::ButtonIcon(10, 2)) {
@@ -149,9 +147,9 @@ void ImGuiVisitor::visit(ImageShader &n)
ImGui::SameLine(0, 10); ImGui::SameLine(0, 10);
ImGui::SetNextItemWidth(RIGHT_ALIGN); ImGui::SetNextItemWidth(RIGHT_ALIGN);
// combo list of masks // combo list of masks
if ( ImGui::Combo("Mask", &item_current, ImageShader::mask_names, ImageShader::mask_presets.size()+1 ) ) if ( ImGui::Combo("Mask", &item_current, ImageShader::mask_names, IM_ARRAYSIZE(ImageShader::mask_names) ) )
{ {
if (item_current < ImageShader::mask_presets.size()) if (item_current < (int) ImageShader::mask_presets.size())
n.mask = ImageShader::mask_presets[item_current]; n.mask = ImageShader::mask_presets[item_current];
else { else {
// TODO ask for custom mask // TODO ask for custom mask
@@ -206,14 +204,11 @@ void ImGuiVisitor::visit(ImageProcessingShader &n)
if (ImGuiToolkit::ButtonIcon(1, 7)) n.filterid = 0; if (ImGuiToolkit::ButtonIcon(1, 7)) n.filterid = 0;
ImGui::SameLine(0, 10); ImGui::SameLine(0, 10);
ImGui::SetNextItemWidth(RIGHT_ALIGN); ImGui::SetNextItemWidth(RIGHT_ALIGN);
ImGui::Combo("Filter", &n.filterid, "None\0Blur\0Sharpen\0Edge\0Emboss\0Denoising\0Erode 3x3\0Erode 5x5\0Erode 7x7\0Dilate 3x3\0Dilate 5x5\0Dilate 7x7\0"); ImGui::Combo("Filter", &n.filterid, ImageProcessingShader::filter_names, IM_ARRAYSIZE(ImageProcessingShader::filter_names) );
if (ImGuiToolkit::ButtonIcon(7, 1)) n.invert = 0; if (ImGuiToolkit::ButtonIcon(7, 1)) n.invert = 0;
ImGui::SameLine(0, 10); ImGui::SameLine(0, 10);
ImGui::SetNextItemWidth(RIGHT_ALIGN); ImGui::SetNextItemWidth(RIGHT_ALIGN);
// static const char* invert_names[3] = { "None", "Color", "Luminance" };
// const char* current_invert_name = invert_names[n.invert];
// ImGui::SliderInt("Invert", &n.invert, 0, 2, current_invert_name);
ImGui::Combo("Invert", &n.invert, "None\0Invert Color\0Invert Luminance\0"); ImGui::Combo("Invert", &n.invert, "None\0Invert Color\0Invert Luminance\0");
if (ImGuiToolkit::ButtonIcon(13, 4)) { if (ImGuiToolkit::ButtonIcon(13, 4)) {

View File

@@ -5,6 +5,10 @@
ShadingProgram imageProcessingShadingProgram("shaders/image.vs", "shaders/imageprocessing.fs"); ShadingProgram imageProcessingShadingProgram("shaders/image.vs", "shaders/imageprocessing.fs");
const char* ImageProcessingShader::filter_names[12] = { "None", "Blur", "Sharpen", "Edge", "Emboss", "Denoising",
"Erosion 3x3", "Erosion 5x5", "Erosion 7x7", "Dilation 3x3", "Dilation 5x5", "Dilation 7x7" };
ImageProcessingShader::ImageProcessingShader() ImageProcessingShader::ImageProcessingShader()
{ {
program_ = &imageProcessingShadingProgram; program_ = &imageProcessingShadingProgram;

View File

@@ -5,6 +5,7 @@
#include "Shader.h" #include "Shader.h"
class ImageProcessingShader : public Shader class ImageProcessingShader : public Shader
{ {
public: public:
@@ -41,6 +42,7 @@ public:
// [5] 1 x convolution opening (denoising) // [5] 1 x convolution opening (denoising)
// [6 11] 6 x convolutions: erosion 3x3, 5x5, 7x7, dilation 3x3, 5x5, 7x7 // [6 11] 6 x convolutions: erosion 3x3, 5x5, 7x7, dilation 3x3, 5x5, 7x7
int filterid; int filterid;
static const char* filter_names[12];
}; };

View File

@@ -25,7 +25,7 @@ public:
uint mask; uint mask;
float stipple; float stipple;
static const char* mask_names[]; static const char* mask_names[10];
static std::vector< uint > mask_presets; static std::vector< uint > mask_presets;
}; };