Larger IMGUI_RIGHT_ALIGN

This commit is contained in:
Bruno Herbelin
2023-03-08 22:12:37 +01:00
parent 2b6bbce1d9
commit 8c778e8afb
4 changed files with 159 additions and 14 deletions

View File

@@ -1068,3 +1068,148 @@ bool WindowPreview::hasNode::operator()(WindowPreview elem) const
// return ret; // return ret;
//} //}
// GLM conversion of GLSL code to generate white balance matrices
//// Parameters for transfer characteristics (gamma curves)
//struct transfer {
// // Exponent used to linearize the signal
// float power;
// // Offset from 0.0 for the exponential curve
// float off;
// // Slope of linear segment near 0
// float slope;
// // Values below this are divided by slope during linearization
// float cutoffToLinear;
// // Values below this are multiplied by slope during gamma correction
// float cutoffToGamma;
// transfer(float p, float o, float s, float l, float g) :
// power(p), off(o), slope (s), cutoffToLinear(l), cutoffToGamma(g)
// {}
//};
//// Parameters for a colorspace
//struct rgb_space {
// // Chromaticity coordinates (xyz) for Red, Green, and Blue primaries
// glm::mat4 primaries;
// // Chromaticity coordinates (xyz) for white point
// glm::vec4 white;
// // Linearization and gamma correction parameters
// transfer trc;
// rgb_space(glm::mat4 p, glm::vec4 w, transfer t) :
// primaries(p), white(w), trc(t)
// {}
//};
//// Turns 6 chromaticity coordinates into a 3x3 matrix
//#define Primaries(r1, r2, g1, g2, b1, b2)\
// glm::mat4(\
// (r1), (r2), 1.0 - (r1) - (r2), 0,\
// (g1), (g2), 1.0 - (g1) - (g2), 0,\
// (b1), (b2), 1.0 - (b1) - (b2), 0,\
// 0, 0, 0, 1)
//// Creates a whitepoint's xyz chromaticity coordinates from the given xy coordinates
//#define White(x, y)\
// glm::vec4( glm::vec3((x), (y), 1.0f - (x) - (y)) /(y), 1.0f)
//// Automatically calculate the slope and cutoffs for transfer characteristics
//#define Transfer(po, of)\
//transfer(\
// (po),\
// (of),\
// (pow((po)*(of)/((po) - 1.0), 1.0 - (po))*pow(1.0 + (of), (po)))/(po),\
// (of)/((po) - 1.0),\
// (of)/((po) - 1.0)*(po)/(pow((po)*(of)/((po) - 1.0), 1.0 - (po))*pow(1.0 + (of), (po)))\
//)
//// Creates a scaling matrix using a vec4 to set the xyzw scalars
//#define diag(v)\
// glm::mat4(\
// (v).x, 0, 0, 0,\
// 0, (v).y, 0, 0,\
// 0, 0, (v).z, 0,\
// 0, 0, 0, (v).w)
//// Creates a conversion matrix that turns RGB colors into XYZ colors
//#define rgbToXyz(space)\
// (space.primaries*diag(inverse((space).primaries)*(space).white))
//// Creates a conversion matrix that turns XYZ colors into RGB colors
//#define xyzToRgb(space)\
// inverse(rgbToXyz(space))
///*
// * Chromaticities for RGB primaries
// */
//// Rec. 709 (HDTV) and sRGB primaries
//const glm::mat4 primaries709 = Primaries(
// 0.64f, 0.33f,
// 0.3f, 0.6f,
// 0.15f, 0.06f
//);
//// Same as above, but in fractional form
//const glm::mat4 primariesLms = Primaries(
// 194735469.0/263725741.0, 68990272.0/263725741.0,
// 141445123.0/106612934.0, -34832189.0/106612934.0,
// 36476327.0/229961670.0, 0.0
//);
///*
// * Chromaticities for white points
// */
//// Standard illuminant E (also known as the 'equal energy' white point)
//const glm::vec4 whiteE = White(1.f/3.f, 1.f/3.f);
//// Standard Illuminant D65 according to the Rec. 709 and sRGB standards
//const glm::vec4 whiteD65S = White(0.3127f, 0.3290f);
///*
// * Gamma curve parameters
// */
//// Linear gamma
//const transfer gam10 = transfer(1.0f, 0.0f, 1.0f, 0.0f, 0.0f);
//// Gamma for sRGB
//const transfer gamSrgb = transfer(2.4f, 0.055f, 12.92f, 0.04045f, 0.0031308f);
///*
// * RGB Colorspaces
// */
//// sRGB (mostly the same as Rec. 709, but different gamma and full range values)
//const rgb_space Srgb = rgb_space(primaries709, whiteD65S, gamSrgb);
//// Lms primaries, balanced against equal energy white point
//const rgb_space LmsRgb = rgb_space(primariesLms, whiteE, gam10);
//const glm::mat4 toXyz = rgbToXyz(Srgb);
//const glm::mat4 toRgb = xyzToRgb(Srgb);
//const glm::mat4 toLms = xyzToRgb(LmsRgb);
//const glm::mat4 frLms = rgbToXyz(LmsRgb);
//std::cerr << "toXyz" << std::endl;
//std::cerr << glm::to_string(toXyz) <<std::endl;
//std::cerr << "toRgb" << std::endl;
//std::cerr << glm::to_string(toRgb) <<std::endl;
//std::cerr << "toLms" << std::endl;
//std::cerr << glm::to_string(toLms) <<std::endl;
//std::cerr << "frLms" << std::endl;
//std::cerr << glm::to_string(frLms) <<std::endl;

View File

@@ -151,11 +151,11 @@ bool ImGuiToolkit::ButtonSwitch(const char* label, bool* toggle, const char* sho
// draw the label right aligned // draw the label right aligned
const ImVec2 label_size = ImGui::CalcTextSize(label, NULL, true); const ImVec2 label_size = ImGui::CalcTextSize(label, NULL, true);
ImVec2 text_pos = draw_pos + ImVec2(frame_width -3.5f * ImGui::GetTextLineHeightWithSpacing() -label_size.x, 0.f); ImVec2 text_pos = draw_pos + ImVec2(frame_width -3.8f * ImGui::GetTextLineHeightWithSpacing() -label_size.x, 0.f);
ImGui::RenderText(text_pos, label); ImGui::RenderText(text_pos, label);
// draw switch after the text // draw switch after the text
ImVec2 p = draw_pos + ImVec2(frame_width -3.1f * ImGui::GetTextLineHeightWithSpacing(), 0.f); ImVec2 p = draw_pos + ImVec2(frame_width -3.5f * ImGui::GetTextLineHeightWithSpacing(), 0.f);
draw_list->AddRectFilled(p, ImVec2(p.x + width, p.y + height), col_bg, height * 0.5f); draw_list->AddRectFilled(p, ImVec2(p.x + width, p.y + height), col_bg, height * 0.5f);
draw_list->AddCircleFilled(ImVec2(p.x + radius + t * (width - radius * 2.0f), p.y + radius), radius - 1.5f, IM_COL32(255, 255, 255, 250)); draw_list->AddCircleFilled(ImVec2(p.x + radius + t * (width - radius * 2.0f), p.y + radius), radius - 1.5f, IM_COL32(255, 255, 255, 250));

View File

@@ -8324,7 +8324,7 @@ void Navigator::RenderMainPannelSettings()
ImGui::Text("Appearance"); ImGui::Text("Appearance");
int v = Settings::application.accent_color; int v = Settings::application.accent_color;
ImGui::Spacing(); ImGui::Spacing();
ImGui::SetCursorPosX(-0.6f * IMGUI_RIGHT_ALIGN); ImGui::SetCursorPosX(0.5f * width_);
if (ImGui::RadioButton("##Color", &v, v)){ if (ImGui::RadioButton("##Color", &v, v)){
Settings::application.accent_color = (v+1)%3; Settings::application.accent_color = (v+1)%3;
ImGuiToolkit::SetAccentColor(static_cast<ImGuiToolkit::accent_color>(Settings::application.accent_color)); ImGuiToolkit::SetAccentColor(static_cast<ImGuiToolkit::accent_color>(Settings::application.accent_color));
@@ -8332,7 +8332,7 @@ void Navigator::RenderMainPannelSettings()
if (ImGui::IsItemHovered()) if (ImGui::IsItemHovered())
ImGuiToolkit::ToolTip("Change accent color"); ImGuiToolkit::ToolTip("Change accent color");
ImGui::SameLine(); ImGui::SameLine();
ImGui::SetCursorPosX(-1.f * IMGUI_RIGHT_ALIGN); ImGui::SetCursorPosX(width_);
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
if ( ImGui::InputFloat("Scale", &Settings::application.scale, 0.1f, 0.1f, "%.1f")) { if ( ImGui::InputFloat("Scale", &Settings::application.scale, 0.1f, 0.1f, "%.1f")) {
Settings::application.scale = CLAMP(Settings::application.scale, 0.5f, 2.f); Settings::application.scale = CLAMP(Settings::application.scale, 0.5f, 2.f);
@@ -8348,11 +8348,11 @@ void Navigator::RenderMainPannelSettings()
ImGui::Text("Record"); ImGui::Text("Record");
// select CODEC and FPS // select CODEC and FPS
ImGui::SetCursorPosX(-1.f * IMGUI_RIGHT_ALIGN); ImGui::SetCursorPosX(width_);
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
ImGui::Combo("Codec", &Settings::application.record.profile, VideoRecorder::profile_name, IM_ARRAYSIZE(VideoRecorder::profile_name) ); ImGui::Combo("Codec", &Settings::application.record.profile, VideoRecorder::profile_name, IM_ARRAYSIZE(VideoRecorder::profile_name) );
ImGui::SetCursorPosX(-1.f * IMGUI_RIGHT_ALIGN); ImGui::SetCursorPosX(width_);
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
ImGui::Combo("Framerate", &Settings::application.record.framerate_mode, VideoRecorder::framerate_preset_name, IM_ARRAYSIZE(VideoRecorder::framerate_preset_name) ); ImGui::Combo("Framerate", &Settings::application.record.framerate_mode, VideoRecorder::framerate_preset_name, IM_ARRAYSIZE(VideoRecorder::framerate_preset_name) );
@@ -8367,7 +8367,7 @@ void Navigator::RenderMainPannelSettings()
ImGui::SameLine(0); ImGui::SameLine(0);
} }
ImGui::SetCursorPosX(-1.f * IMGUI_RIGHT_ALIGN); ImGui::SetCursorPosX(width_);
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
ImGui::SliderInt("Buffer", &Settings::application.record.buffering_mode, 0, IM_ARRAYSIZE(VideoRecorder::buffering_preset_name)-1, ImGui::SliderInt("Buffer", &Settings::application.record.buffering_mode, 0, IM_ARRAYSIZE(VideoRecorder::buffering_preset_name)-1,
VideoRecorder::buffering_preset_name[Settings::application.record.buffering_mode]); VideoRecorder::buffering_preset_name[Settings::application.record.buffering_mode]);
@@ -8376,7 +8376,7 @@ void Navigator::RenderMainPannelSettings()
ICON_FA_CARET_RIGHT " Duration:\n Variable framerate, correct duration.\n" ICON_FA_CARET_RIGHT " Duration:\n Variable framerate, correct duration.\n"
ICON_FA_CARET_RIGHT " Framerate:\n Correct framerate, shorter duration."); ICON_FA_CARET_RIGHT " Framerate:\n Correct framerate, shorter duration.");
ImGui::SameLine(0); ImGui::SameLine(0);
ImGui::SetCursorPosX(-1.f * IMGUI_RIGHT_ALIGN); ImGui::SetCursorPosX(width_);
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
ImGui::Combo("Priority", &Settings::application.record.priority_mode, "Duration\0Framerate\0"); ImGui::Combo("Priority", &Settings::application.record.priority_mode, "Duration\0Framerate\0");
@@ -8389,7 +8389,7 @@ void Navigator::RenderMainPannelSettings()
ImGuiToolkit::Indication("Peer-to-peer sharing on local network\n\n" ImGuiToolkit::Indication("Peer-to-peer sharing on local network\n\n"
"vimix can stream JPEG (default) or H264 (requires less bandwidth but more resources for encoding)", ICON_FA_SHARE_ALT_SQUARE); "vimix can stream JPEG (default) or H264 (requires less bandwidth but more resources for encoding)", ICON_FA_SHARE_ALT_SQUARE);
ImGui::SameLine(0); ImGui::SameLine(0);
ImGui::SetCursorPosX(-1.f * IMGUI_RIGHT_ALIGN); ImGui::SetCursorPosX(width_);
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
ImGui::Combo("Share P2P", &Settings::application.stream_protocol, "JPEG\0H264\0"); ImGui::Combo("Share P2P", &Settings::application.stream_protocol, "JPEG\0H264\0");
@@ -8406,7 +8406,7 @@ void Navigator::RenderMainPannelSettings()
ImGuiToolkit::Indication(msg, ICON_FA_GLOBE); ImGuiToolkit::Indication(msg, ICON_FA_GLOBE);
ImGui::SameLine(0); ImGui::SameLine(0);
ImGui::SetCursorPosX(-1.f * IMGUI_RIGHT_ALIGN); ImGui::SetCursorPosX(width_);
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
char bufport[7] = ""; char bufport[7] = "";
sprintf(bufport, "%d", Settings::application.broadcast_port); sprintf(bufport, "%d", Settings::application.broadcast_port);
@@ -8436,7 +8436,7 @@ void Navigator::RenderMainPannelSettings()
ImGuiToolkit::Indication(msg, ICON_FA_NETWORK_WIRED); ImGuiToolkit::Indication(msg, ICON_FA_NETWORK_WIRED);
ImGui::SameLine(0); ImGui::SameLine(0);
ImGui::SetCursorPosX(-1.f * IMGUI_RIGHT_ALIGN); ImGui::SetCursorPosX(width_);
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
char bufreceive[7] = ""; char bufreceive[7] = "";
sprintf(bufreceive, "%d", Settings::application.control.osc_port_receive); sprintf(bufreceive, "%d", Settings::application.control.osc_port_receive);
@@ -8448,7 +8448,7 @@ void Navigator::RenderMainPannelSettings()
} }
} }
ImGui::SetCursorPosX(-1.f * IMGUI_RIGHT_ALIGN); ImGui::SetCursorPosX(width_);
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
char bufsend[7] = ""; char bufsend[7] = "";
sprintf(bufsend, "%d", Settings::application.control.osc_port_send); sprintf(bufsend, "%d", Settings::application.control.osc_port_send);
@@ -8460,7 +8460,7 @@ void Navigator::RenderMainPannelSettings()
} }
} }
ImGui::SetCursorPosX(-1.f * IMGUI_RIGHT_ALIGN); ImGui::SetCursorPosX(width_);
const float w = IMGUI_RIGHT_ALIGN - ImGui::GetFrameHeightWithSpacing(); const float w = IMGUI_RIGHT_ALIGN - ImGui::GetFrameHeightWithSpacing();
ImGuiToolkit::ButtonOpenUrl( "Edit", Settings::application.control.osc_filename.c_str(), ImVec2(w, 0) ); ImGuiToolkit::ButtonOpenUrl( "Edit", Settings::application.control.osc_filename.c_str(), ImVec2(w, 0) );
ImGui::SameLine(0, 6); ImGui::SameLine(0, 6);

View File

@@ -82,7 +82,7 @@
#define IMGUI_TITLE_LOGS ICON_FA_LIST_UL " Logs" #define IMGUI_TITLE_LOGS ICON_FA_LIST_UL " Logs"
#define IMGUI_LABEL_RECENT_FILES " Recent files" #define IMGUI_LABEL_RECENT_FILES " Recent files"
#define IMGUI_LABEL_RECENT_RECORDS " Recent recordings" #define IMGUI_LABEL_RECENT_RECORDS " Recent recordings"
#define IMGUI_RIGHT_ALIGN -3.5f * ImGui::GetTextLineHeightWithSpacing() #define IMGUI_RIGHT_ALIGN -3.8f * ImGui::GetTextLineHeightWithSpacing()
#define IMGUI_SAME_LINE 8 #define IMGUI_SAME_LINE 8
#define IMGUI_TOP_ALIGN 10 #define IMGUI_TOP_ALIGN 10
#define IMGUI_COLOR_OVERLAY IM_COL32(5, 5, 5, 150) #define IMGUI_COLOR_OVERLAY IM_COL32(5, 5, 5, 150)