diff --git a/code/Ui/ColorPicker/ColorControl.cpp b/code/Ui/ColorPicker/ColorControl.cpp index 027dd1b75b..e295bc3c92 100644 --- a/code/Ui/ColorPicker/ColorControl.cpp +++ b/code/Ui/ColorPicker/ColorControl.cpp @@ -1,6 +1,6 @@ /* * TRAKTOR - * Copyright (c) 2022 Anders Pistol. + * Copyright (c) 2022-2024 Anders Pistol. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -12,17 +12,15 @@ #include "Ui/Bitmap.h" #include "Ui/ColorPicker/ColorControl.h" -namespace traktor +namespace traktor::ui { - namespace ui + namespace { - namespace - { const Unit c_width = 32_ut; const Unit c_height = 24_ut; - } + } T_IMPLEMENT_RTTI_CLASS(L"traktor.ui.ColorControl", ColorControl, Widget) @@ -31,6 +29,7 @@ bool ColorControl::create(Widget* parent, int style) if (!Widget::create(parent, style)) return false; + addEventHandler< SizeEvent >(this, &ColorControl::eventSize); addEventHandler< PaintEvent >(this, &ColorControl::eventPaint); const int32_t width = pixel(c_width); @@ -44,17 +43,49 @@ bool ColorControl::create(Widget* parent, int style) } void ColorControl::setColor(const Color4ub& color) +{ + m_color = color; + updatePreview(); + update(); +} + +Color4ub ColorControl::getColor() const +{ + return m_color; +} + +Size ColorControl::getPreferredSize(const Size& hint) const { const int32_t width = pixel(c_width); const int32_t height = pixel(c_height); + return Size(width, height); +} - m_color = color; - for (int32_t y = 0; y < height; ++y) +void ColorControl::updatePreview() +{ + const Size sz = getInnerRect().getSize(); + + if (m_previewImage) { - for (int32_t x = 0; x < width; ++x) + if (m_previewImage->getWidth() != sz.cx || m_previewImage->getHeight() != sz.cy) { - Color4ub checkerColor = (((x >> 2) & 1) ^ ((y >> 2) & 1)) ? Color4ub(180, 180, 180) : Color4ub(80, 80, 80); - Color4ub previewColor = lerp(checkerColor, color, color.a / 255.0f); + m_previewImage = nullptr; + m_previewBitmap = nullptr; + } + } + + if (!m_previewImage) + { + m_previewImage = new drawing::Image(drawing::PixelFormat::getR8G8B8(), sz.cx, sz.cy); + m_previewBitmap = new ui::Bitmap(sz.cx, sz.cy); + } + + for (int32_t y = 0; y < sz.cy; ++y) + { + for (int32_t x = 0; x < sz.cx; ++x) + { + const Color4ub checkerColor = (((x >> 2) & 1) ^ ((y >> 2) & 1)) ? Color4ub(180, 180, 180) : Color4ub(80, 80, 80); + const Color4ub previewColor = lerp(checkerColor, m_color, m_color.a / 255.0f); float rgba[4]; previewColor.getRGBA32F(rgba); @@ -64,19 +95,12 @@ void ColorControl::setColor(const Color4ub& color) } m_previewBitmap->copyImage(m_previewImage); - update(); } -Color4ub ColorControl::getColor() const +void ColorControl::eventSize(SizeEvent* event) { - return m_color; -} - -Size ColorControl::getPreferredSize(const Size& hint) const -{ - const int32_t width = pixel(c_width); - const int32_t height = pixel(c_height); - return Size(width, height); + updatePreview(); + update(); } void ColorControl::eventPaint(PaintEvent* event) @@ -93,5 +117,4 @@ void ColorControl::eventPaint(PaintEvent* event) event->consume(); } - } } diff --git a/code/Ui/ColorPicker/ColorControl.h b/code/Ui/ColorPicker/ColorControl.h index 41e833ae05..d56505daba 100644 --- a/code/Ui/ColorPicker/ColorControl.h +++ b/code/Ui/ColorPicker/ColorControl.h @@ -1,6 +1,6 @@ /* * TRAKTOR - * Copyright (c) 2022 Anders Pistol. + * Copyright (c) 2022-2024 Anders Pistol. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -18,17 +18,15 @@ # define T_DLLCLASS T_DLLIMPORT #endif -namespace traktor +namespace traktor::drawing { - namespace drawing - { class Image; - } +} - namespace ui - { +namespace traktor::ui +{ class Bitmap; @@ -53,9 +51,11 @@ class T_DLLCLASS ColorControl : public Widget Ref< drawing::Image > m_previewImage; Ref< Bitmap > m_previewBitmap; + void updatePreview(); + + void eventSize(SizeEvent* event); + void eventPaint(PaintEvent* event); }; - } } - diff --git a/resources/runtime/themes/Dark/New/Theater/Theater.svg b/resources/runtime/themes/Dark/New/Theater/Theater.svg index facb9d0b00..da1cee60b7 100644 --- a/resources/runtime/themes/Dark/New/Theater/Theater.svg +++ b/resources/runtime/themes/Dark/New/Theater/Theater.svg @@ -26,11 +26,11 @@ borderopacity="1" inkscape:pageopacity="0" inkscape:pageshadow="2" - inkscape:zoom="1.9999999" - inkscape:cx="23.250001" - inkscape:cy="-20.750001" + inkscape:zoom="15.999999" + inkscape:cx="-0.96875005" + inkscape:cy="5.6875003" inkscape:document-units="px" - inkscape:current-layer="Dark" + inkscape:current-layer="g1" showgrid="true" inkscape:snap-global="true" inkscape:snap-grids="true" @@ -51,12 +51,12 @@ @@ -527,26 +527,6 @@ inkscape:label="Dark" id="Dark" inkscape:groupmode="layer"> - - - - - + + + + + + + diff --git a/resources/runtime/themes/Dark/New/UI/Directory.svg b/resources/runtime/themes/Dark/New/UI/Directory.svg index 78c85181ee..726def649f 100644 --- a/resources/runtime/themes/Dark/New/UI/Directory.svg +++ b/resources/runtime/themes/Dark/New/UI/Directory.svg @@ -2,9 +2,9 @@ - - + + traktor.ui.Sequence + + + background-color + 55, 55, 55, 255 + + + background-color-selected + 90, 90, 90, 255 + + + line-color + 160, 160, 160, 255 + + + tick-color + 128, 128, 128, 255 + + + + + traktor.ui.SequenceGroup + + + background-color + 120, 120, 120, 255 + + + background-color-selected + 153, 153, 153, 255 + + + + + traktor.ui.SequencerControl + + + background-color + 37, 37, 38, 0 + + + control-background-color + 55, 55, 55, 255 + + + cursor-color + 0, 122, 204, 255 + + + info-background-color + 0, 122, 204, 255 + + + + + traktor.ui.Tick + + + background-color + 51, 153, 255, 255 + + + background-color-selected + 96, 139, 78, 255 + + + color + 63, 63, 70, 255 + + + + + traktor.ui.Track + + + background-color + 51, 153, 255, 255 + + + background-color-selected + 96, 139, 78, 255 + + + color + 63, 63, 70, 255 + + +