mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 06:05:58 -06:00
dark
This commit is contained in:
parent
c119e90c6c
commit
024da56097
6 changed files with 56 additions and 10 deletions
|
|
@ -361,7 +361,7 @@ Color DarkTheme(Color color)
|
|||
|
||||
double target = 255 - Saturate255(int(Val() + saturation));
|
||||
if(target < 30)
|
||||
target *= (1 + (30 - target) / 30) * 1.5;
|
||||
target *= (1 / 1.5 + (29 - target) / 29) * 1.5;
|
||||
double ratio = target / 128;
|
||||
|
||||
double m = max(r, g, b);
|
||||
|
|
|
|||
|
|
@ -48,6 +48,14 @@ s_colors[] = {
|
|||
|
||||
Color ColorPopUp::hint[18];
|
||||
|
||||
ColorPopUp& ColorPopUp::DarkContent(bool b)
|
||||
{
|
||||
dark = b;
|
||||
wheel.DarkContent(b);
|
||||
ramp.DarkContent(b);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void ColorPopUp_InitHint()
|
||||
{
|
||||
for(int i = 0; i < 18; i++)
|
||||
|
|
@ -198,7 +206,7 @@ void ColorPopUp::Paint(Draw& w)
|
|||
if(i >= GetColorCount()) {
|
||||
if(!norampwheel) {
|
||||
Rect r(DPI(8 * 16 + 1), cy + DPI(4), DPI(10 * 16 - 1), sz.cy - DPI(4) - DPI(24));
|
||||
DrawFilledFrame(w, r, SColorText, color);
|
||||
DrawFilledFrame(w, r, SColorText, dark ? DarkThemeCached(color) : color);
|
||||
|
||||
r.Inflate(1);
|
||||
if(colori == 999) {
|
||||
|
|
@ -212,9 +220,9 @@ void ColorPopUp::Paint(Draw& w)
|
|||
}
|
||||
|
||||
Color c = RealizeColor(GetColor(i));
|
||||
DrawFilledFrame(w, x + DPI(1), y, DPI(14), DPI(14), SColorText, c);
|
||||
DrawFilledFrame(w, x + DPI(1), y, DPI(14), DPI(14), SColorText, dark ? DarkThemeCached(c) : c);
|
||||
if(i < 18 && scolors)
|
||||
w.DrawRect(x + DPI(2) + DPI(6), y + DPI(1), DPI(6), DPI(12), DarkThemeCached(c));
|
||||
w.DrawRect(x + DPI(2) + DPI(6), y + DPI(1), DPI(6), DPI(12), dark ? c : DarkThemeCached(c));
|
||||
|
||||
if(i == colori) {
|
||||
if(GetMouseLeft())
|
||||
|
|
|
|||
|
|
@ -467,6 +467,7 @@ enum { PREC = 64 };
|
|||
|
||||
Image WheelRampCtrl::PaintRamp(Size size)
|
||||
{
|
||||
DTIMING("Ramp");
|
||||
ImageDraw iw(size);
|
||||
ImageBuffer ib(PREC, PREC);
|
||||
for(int y = 0; y < PREC; y++) {
|
||||
|
|
@ -475,6 +476,8 @@ Image WheelRampCtrl::PaintRamp(Size size)
|
|||
for(int x = 0; x < PREC; x++) {
|
||||
int s16 = iscale(x, 65535, PREC - 1);
|
||||
Color c = HSV16toRGB(h16, s16, v16);
|
||||
if(dark)
|
||||
c = DarkTheme(c);
|
||||
scan->r = GetRRaw(c);
|
||||
scan->g = GetGRaw(c);
|
||||
scan->b = GetBRaw(c);
|
||||
|
|
@ -489,6 +492,7 @@ Image WheelRampCtrl::PaintRamp(Size size)
|
|||
|
||||
Image WheelRampCtrl::PaintWheel(Size size)
|
||||
{
|
||||
DTIMING("Wheel");
|
||||
ImageBuffer ib(PREC, PREC);
|
||||
static WheelBuff wb[PREC * PREC];
|
||||
ONCELOCK {
|
||||
|
|
@ -510,16 +514,22 @@ Image WheelRampCtrl::PaintWheel(Size size)
|
|||
for(int y = 0; y < PREC; y++) {
|
||||
RGBA *scan = ib[y];
|
||||
for(int x = 0; x < PREC; x++) {
|
||||
*scan++ = HSV16toRGB(cwb->arg, cwb->l, v16);
|
||||
Color c = HSV16toRGB(cwb->arg, cwb->l, v16);
|
||||
if(dark)
|
||||
c = DarkTheme(c);
|
||||
*scan++ = c;
|
||||
cwb++;
|
||||
}
|
||||
}
|
||||
|
||||
ImageDraw iw(size);
|
||||
ImagePainter iw(size);
|
||||
iw.Clear();
|
||||
Sizef s2 = (Sizef)(size) / 2;
|
||||
iw.Begin();
|
||||
iw.Ellipse(s2.cx, s2.cy, s2.cx, s2.cy).Clip();
|
||||
iw.DrawImage(size, Rescale(ib, size));
|
||||
iw.DrawEllipse(size, Null, 0, Black);
|
||||
iw.Alpha().DrawRect(size, GrayColor(0));
|
||||
iw.Alpha().DrawEllipse(size, GrayColor(255), 0, GrayColor(255));
|
||||
iw.End();
|
||||
iw.Ellipse(s2.cx, s2.cy, s2.cx - 1, s2.cy - 1).Stroke(1, SBlack());
|
||||
return iw;
|
||||
}
|
||||
|
||||
|
|
@ -539,7 +549,7 @@ void WheelRampCtrl::PaintColumn(Draw& draw)
|
|||
int factor = ClientToLevel(i);
|
||||
Color c = ramp ? HSV16toRGB(factor, 65535, 65535) : HSV16toRGB(h16, s16, factor);
|
||||
// : Color(iscale(nr, factor, 65536), iscale(ng, factor, 65536), iscale(nb, factor, 65536));
|
||||
draw.DrawRect(column_rect.left, i, size.cx, 1, c);
|
||||
draw.DrawRect(column_rect.left, i, size.cx, 1, dark ? DarkThemeCached(c) : c);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ public:
|
|||
virtual void MouseMove(Point pt, dword keyflags);
|
||||
|
||||
Event<> WhenLeftDouble;
|
||||
|
||||
void DarkContent(bool b = true) { dark = b; }
|
||||
|
||||
private:
|
||||
void SetColor(Color color, bool set_norm, bool set_hsv);
|
||||
|
|
@ -31,6 +33,7 @@ private:
|
|||
|
||||
private:
|
||||
bool ramp;
|
||||
bool dark = false;
|
||||
Color color;
|
||||
Color normalized_color;
|
||||
int h16, s16, v16;
|
||||
|
|
@ -170,6 +173,7 @@ private:
|
|||
bool hints;
|
||||
bool open;
|
||||
bool withvoid;
|
||||
bool dark;
|
||||
String nulltext;
|
||||
String voidtext;
|
||||
Color color;
|
||||
|
|
@ -201,6 +205,7 @@ public:
|
|||
ColorPopUp& VoidText(const char *s) { voidtext = s; Refresh(); return *this; }
|
||||
ColorPopUp& NoRampWheel(bool b = true) { norampwheel = b; return *this; }
|
||||
ColorPopUp& Hints(bool b = true) { hints = b; return *this; }
|
||||
ColorPopUp& DarkContent(bool b = true);
|
||||
|
||||
ColorPopUp();
|
||||
virtual ~ColorPopUp();
|
||||
|
|
@ -244,6 +249,7 @@ public:
|
|||
ColorPusher& Track(bool b = true) { track = b; return *this; }
|
||||
ColorPusher& NoTrack() { return Track(false); }
|
||||
ColorPusher& NoRampWheel(bool b = true) { colors.NoRampWheel(b); return *this; }
|
||||
ColorPusher& DarkContent(bool b = true) { colors.DarkContent(b); return *this; }
|
||||
|
||||
ColorPusher();
|
||||
virtual ~ColorPusher();
|
||||
|
|
|
|||
9
upptst/DarkModeContent/DarkModeContent.upp
Normal file
9
upptst/DarkModeContent/DarkModeContent.upp
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
uses
|
||||
CtrlLib;
|
||||
|
||||
file
|
||||
main.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "GUI";
|
||||
|
||||
13
upptst/DarkModeContent/main.cpp
Normal file
13
upptst/DarkModeContent/main.cpp
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#include <CtrlLib/CtrlLib.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
GUI_APP_MAIN
|
||||
{
|
||||
TopWindow win;
|
||||
ColorPusher p, p1;
|
||||
p.DarkContent();
|
||||
win.Add(p.LeftPos(100, 100).TopPos(100, 50));
|
||||
win.Add(p1.LeftPos(200, 100).TopPos(100, 50));
|
||||
win.Run();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue