Introduction of classes ColorRGB and ColorRGBA to unify color data definition and manipulation

(cherry picked from commit prusa3d/PrusaSlicer@d0bff2d996 )
This commit is contained in:
enricoturri1966 2023-10-20 15:41:26 +08:00 committed by Noisyfox
parent 36ffb18059
commit 28d0147d09
60 changed files with 1290 additions and 1174 deletions

View file

@ -27,6 +27,7 @@
#include "libslic3r/libslic3r.h"
#include "libslic3r/Utils.hpp"
#include "libslic3r/Color.hpp"
#include "libslic3r/Shape/TextShape.hpp"
#include "3DScene.hpp"
#include "GUI.hpp"
@ -127,11 +128,11 @@ static const std::map<const wchar_t, std::string> font_icons_extra_large = {
const ImVec4 ImGuiWrapper::COL_GREY_DARK = { 0.333f, 0.333f, 0.333f, 1.0f };
const ImVec4 ImGuiWrapper::COL_GREY_LIGHT = { 0.4f, 0.4f, 0.4f, 1.0f };
const ImVec4 ImGuiWrapper::COL_ORANGE_DARK = { 0.757f, 0.404f, 0.216f, 1.0f };
const ImVec4 ImGuiWrapper::COL_ORANGE_LIGHT = { 1.0f, 0.49f, 0.216f, 1.0f };
const ImVec4 ImGuiWrapper::COL_ORANGE_LIGHT = to_ImVec4(ColorRGBA::ORANGE());
const ImVec4 ImGuiWrapper::COL_WINDOW_BACKGROUND = { 0.1f, 0.1f, 0.1f, 0.8f };
const ImVec4 ImGuiWrapper::COL_BUTTON_BACKGROUND = COL_ORANGE_DARK;
const ImVec4 ImGuiWrapper::COL_BUTTON_HOVERED = COL_ORANGE_LIGHT;
const ImVec4 ImGuiWrapper::COL_BUTTON_ACTIVE = ImGuiWrapper::COL_BUTTON_HOVERED;
const ImVec4 ImGuiWrapper::COL_BUTTON_ACTIVE = COL_BUTTON_HOVERED;
//BBS
@ -1776,6 +1777,26 @@ bool ImGuiWrapper::want_any_input() const
return io.WantCaptureMouse || io.WantCaptureKeyboard || io.WantTextInput;
}
ImU32 ImGuiWrapper::to_ImU32(const ColorRGBA& color)
{
return ImGui::GetColorU32({ color.r(), color.g(), color.b(), color.a() });
}
ImVec4 ImGuiWrapper::to_ImVec4(const ColorRGBA& color)
{
return { color.r(), color.g(), color.b(), color.a() };
}
ColorRGBA ImGuiWrapper::from_ImU32(const ImU32& color)
{
return from_ImVec4(ImGui::ColorConvertU32ToFloat4(color));
}
ColorRGBA ImGuiWrapper::from_ImVec4(const ImVec4& color)
{
return { color.x, color.y, color.z, color.w };
}
#ifdef __APPLE__
static const ImWchar ranges_keyboard_shortcuts[] =
{