| 2014 | } |
| 2015 | |
| 2016 | CUi::EPopupMenuFunctionResult CUi::PopupColorPicker(void *pContext, CUIRect View, bool Active) |
| 2017 | { |
| 2018 | SColorPickerPopupContext *pColorPicker = static_cast<SColorPickerPopupContext *>(pContext); |
| 2019 | CUi *pUI = pColorPicker->m_pUI; |
| 2020 | pColorPicker->m_State = EEditState::NONE; |
| 2021 | |
| 2022 | CUIRect ColorsArea, HueArea, BottomArea, ModeButtonArea, HueRect, SatRect, ValueRect, HexRect, AlphaRect; |
| 2023 | |
| 2024 | View.HSplitTop(140.0f, &ColorsArea, &BottomArea); |
| 2025 | ColorsArea.VSplitRight(20.0f, &ColorsArea, &HueArea); |
| 2026 | |
| 2027 | BottomArea.HSplitTop(3.0f, nullptr, &BottomArea); |
| 2028 | HueArea.VSplitLeft(3.0f, nullptr, &HueArea); |
| 2029 | |
| 2030 | BottomArea.HSplitTop(20.0f, &HueRect, &BottomArea); |
| 2031 | BottomArea.HSplitTop(3.0f, nullptr, &BottomArea); |
| 2032 | |
| 2033 | constexpr float ValuePadding = 5.0f; |
| 2034 | const float HsvValueWidth = (HueRect.w - ValuePadding * 2) / 3.0f; |
| 2035 | const float HexValueWidth = HsvValueWidth * 2 + ValuePadding; |
| 2036 | |
| 2037 | HueRect.VSplitLeft(HsvValueWidth, &HueRect, &SatRect); |
| 2038 | SatRect.VSplitLeft(ValuePadding, nullptr, &SatRect); |
| 2039 | SatRect.VSplitLeft(HsvValueWidth, &SatRect, &ValueRect); |
| 2040 | ValueRect.VSplitLeft(ValuePadding, nullptr, &ValueRect); |
| 2041 | |
| 2042 | BottomArea.HSplitTop(20.0f, &HexRect, &BottomArea); |
| 2043 | BottomArea.HSplitTop(3.0f, nullptr, &BottomArea); |
| 2044 | HexRect.VSplitLeft(HexValueWidth, &HexRect, &AlphaRect); |
| 2045 | AlphaRect.VSplitLeft(ValuePadding, nullptr, &AlphaRect); |
| 2046 | BottomArea.HSplitTop(20.0f, &ModeButtonArea, &BottomArea); |
| 2047 | |
| 2048 | const ColorRGBA BlackColor = ColorRGBA(0.0f, 0.0f, 0.0f, 0.5f); |
| 2049 | |
| 2050 | HueArea.Draw(BlackColor, IGraphics::CORNER_NONE, 0.0f); |
| 2051 | HueArea.Margin(1.0f, &HueArea); |
| 2052 | |
| 2053 | ColorsArea.Draw(BlackColor, IGraphics::CORNER_NONE, 0.0f); |
| 2054 | ColorsArea.Margin(1.0f, &ColorsArea); |
| 2055 | |
| 2056 | ColorHSVA PickerColorHSV = pColorPicker->m_HsvaColor; |
| 2057 | ColorRGBA PickerColorRGB = pColorPicker->m_RgbaColor; |
| 2058 | ColorHSLA PickerColorHSL = pColorPicker->m_HslaColor; |
| 2059 | |
| 2060 | // Color Area |
| 2061 | ColorRGBA TL, TR, BL, BR; |
| 2062 | TL = BL = color_cast<ColorRGBA>(ColorHSVA(PickerColorHSV.x, 0.0f, 1.0f)); |
| 2063 | TR = BR = color_cast<ColorRGBA>(ColorHSVA(PickerColorHSV.x, 1.0f, 1.0f)); |
| 2064 | ColorsArea.Draw4(TL, TR, BL, BR, IGraphics::CORNER_NONE, 0.0f); |
| 2065 | |
| 2066 | TL = TR = ColorRGBA(0.0f, 0.0f, 0.0f, 0.0f); |
| 2067 | BL = BR = ColorRGBA(0.0f, 0.0f, 0.0f, 1.0f); |
| 2068 | ColorsArea.Draw4(TL, TR, BL, BR, IGraphics::CORNER_NONE, 0.0f); |
| 2069 | |
| 2070 | // Hue Area |
| 2071 | static const float s_aaColorIndices[7][3] = { |
| 2072 | {1.0f, 0.0f, 0.0f}, // red |
| 2073 | {1.0f, 0.0f, 1.0f}, // magenta |
nothing calls this directly
no test coverage detected