diff --git a/src/DisplaysView.cpp b/src/DisplaysView.cpp index 16bee6f..e5abeb8 100644 --- a/src/DisplaysView.cpp +++ b/src/DisplaysView.cpp @@ -1068,3 +1068,148 @@ bool WindowPreview::hasNode::operator()(WindowPreview elem) const // 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) <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)); diff --git a/src/UserInterfaceManager.cpp b/src/UserInterfaceManager.cpp index 7e52e89..8cc03ae 100644 --- a/src/UserInterfaceManager.cpp +++ b/src/UserInterfaceManager.cpp @@ -8324,7 +8324,7 @@ void Navigator::RenderMainPannelSettings() ImGui::Text("Appearance"); int v = Settings::application.accent_color; ImGui::Spacing(); - ImGui::SetCursorPosX(-0.6f * IMGUI_RIGHT_ALIGN); + ImGui::SetCursorPosX(0.5f * width_); if (ImGui::RadioButton("##Color", &v, v)){ Settings::application.accent_color = (v+1)%3; ImGuiToolkit::SetAccentColor(static_cast(Settings::application.accent_color)); @@ -8332,7 +8332,7 @@ void Navigator::RenderMainPannelSettings() if (ImGui::IsItemHovered()) ImGuiToolkit::ToolTip("Change accent color"); ImGui::SameLine(); - ImGui::SetCursorPosX(-1.f * IMGUI_RIGHT_ALIGN); + ImGui::SetCursorPosX(width_); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); if ( ImGui::InputFloat("Scale", &Settings::application.scale, 0.1f, 0.1f, "%.1f")) { Settings::application.scale = CLAMP(Settings::application.scale, 0.5f, 2.f); @@ -8348,11 +8348,11 @@ void Navigator::RenderMainPannelSettings() ImGui::Text("Record"); // select CODEC and FPS - ImGui::SetCursorPosX(-1.f * IMGUI_RIGHT_ALIGN); + ImGui::SetCursorPosX(width_); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); 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::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::SetCursorPosX(-1.f * IMGUI_RIGHT_ALIGN); + ImGui::SetCursorPosX(width_); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); 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]); @@ -8376,7 +8376,7 @@ void Navigator::RenderMainPannelSettings() ICON_FA_CARET_RIGHT " Duration:\n Variable framerate, correct duration.\n" ICON_FA_CARET_RIGHT " Framerate:\n Correct framerate, shorter duration."); ImGui::SameLine(0); - ImGui::SetCursorPosX(-1.f * IMGUI_RIGHT_ALIGN); + ImGui::SetCursorPosX(width_); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); 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" "vimix can stream JPEG (default) or H264 (requires less bandwidth but more resources for encoding)", ICON_FA_SHARE_ALT_SQUARE); ImGui::SameLine(0); - ImGui::SetCursorPosX(-1.f * IMGUI_RIGHT_ALIGN); + ImGui::SetCursorPosX(width_); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); ImGui::Combo("Share P2P", &Settings::application.stream_protocol, "JPEG\0H264\0"); @@ -8406,7 +8406,7 @@ void Navigator::RenderMainPannelSettings() ImGuiToolkit::Indication(msg, ICON_FA_GLOBE); ImGui::SameLine(0); - ImGui::SetCursorPosX(-1.f * IMGUI_RIGHT_ALIGN); + ImGui::SetCursorPosX(width_); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); char bufport[7] = ""; sprintf(bufport, "%d", Settings::application.broadcast_port); @@ -8436,7 +8436,7 @@ void Navigator::RenderMainPannelSettings() ImGuiToolkit::Indication(msg, ICON_FA_NETWORK_WIRED); ImGui::SameLine(0); - ImGui::SetCursorPosX(-1.f * IMGUI_RIGHT_ALIGN); + ImGui::SetCursorPosX(width_); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); char bufreceive[7] = ""; 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); char bufsend[7] = ""; 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(); ImGuiToolkit::ButtonOpenUrl( "Edit", Settings::application.control.osc_filename.c_str(), ImVec2(w, 0) ); ImGui::SameLine(0, 6); diff --git a/src/defines.h b/src/defines.h index e456f6f..3d05c12 100644 --- a/src/defines.h +++ b/src/defines.h @@ -82,7 +82,7 @@ #define IMGUI_TITLE_LOGS ICON_FA_LIST_UL " Logs" #define IMGUI_LABEL_RECENT_FILES " Recent files" #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_TOP_ALIGN 10 #define IMGUI_COLOR_OVERLAY IM_COL32(5, 5, 5, 150)