Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » U++ community news and announcements » DarkTheme function parameters changed
Re: DarkTheme function parameters changed [message #60901 is a reply to message #60898] Sun, 06 October 2024 22:52 Go to previous messageGo to next message
Lance is currently offline  Lance
Messages: 656
Registered: March 2007
Contributor
mirek wrote on Sun, 06 October 2024 15:37
That is not enough, look at this:

CtrlLib/ArrayCtrl.h:686

ArrayCtrl& EvenRowColor(Color paper = Blend(SColorMark, SColorPaper, 220), Color ink = SColorText);

Please educate me if I am wrong.

What are SColorMark, SColorPaper, SColorText? Are they some Color variable in ArrayCtrl's Chameleon Style?

When a user code called
    EvenRowColor();

Something like this happen (conceptually)
   push ink = SColorText;
   push paper = Blend(SColorMark, SColorPaper, 220)
   push this
   call ArrayCtrl::EvenRowColor

If SColorText, SColorMark, SColorPaper are all refreshed after the theme change, EvenColor should receive correct color parameters.

So if instead of store a copy of SColorxxx(), let it store a reference/pointer of SColorxxx() instead. And all SColorXXX() should return Color& instead of Color.

Will this be adequate?
Re: DarkTheme function parameters changed [message #60902 is a reply to message #60901] Mon, 07 October 2024 00:26 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14255
Registered: November 2005
Ultimate Member
Lance wrote on Sun, 06 October 2024 22:52
mirek wrote on Sun, 06 October 2024 15:37
That is not enough, look at this:

CtrlLib/ArrayCtrl.h:686

ArrayCtrl& EvenRowColor(Color paper = Blend(SColorMark, SColorPaper, 220), Color ink = SColorText);

Please educate me if I am wrong.

What are SColorMark, SColorPaper, SColorText? Are they some Color variable in ArrayCtrl's Chameleon Style?

When a user code called
    EvenRowColor();

Something like this happen (conceptually)
   push ink = SColorText;
   push paper = Blend(SColorMark, SColorPaper, 220)
   push this
   call ArrayCtrl::EvenRowColor

If SColorText, SColorMark, SColorPaper are all refreshed after the theme change, EvenColor should receive correct color parameters.

So if instead of store a copy of SColorxxx(), let it store a reference/pointer of SColorxxx() instead. And all SColorXXX() should return Color& instead of Color.

Will this be adequate?


It could easily be a reference, but it does not solve the problem, unless you add somewhat complicate mechanism where the "Blend" part is somehow encoded. I mean, you can make SColorMark work, SColorPaper work, but what is actually stored is some other color, a mix of those two.

It is too clumsy and 'undefined' IMO for the rapid development.

Mirek
Re: DarkTheme function parameters changed [message #60904 is a reply to message #60902] Mon, 07 October 2024 01:59 Go to previous messageGo to next message
Lance is currently offline  Lance
Messages: 656
Registered: March 2007
Contributor
Do you mean that we can have SColorPaper,SColorMark theme-sensitive, but there is no guarantee Blend(SColorPaper, SColorMark, 220) will make any sense in all possible themes we may throw at it?

Re: DarkTheme function parameters changed [message #60907 is a reply to message #60904] Mon, 07 October 2024 08:51 Go to previous messageGo to next message
Tom1
Messages: 1301
Registered: March 2007
Ultimate Contributor
Hi,

Sorry to interfere here, but I would not mind having both theme dependent SColors and "SkinChanged" virtual method called on Ctrls when system theme changes. When the theme changes, everything obviously needs to be Refresh()ed, which could be the default behavior of "SkinChanged". But that is not sufficient, as in some cases content is cached in pre-rendered images which are not aware of the changed theme. Therefore, "SkinChanged" is needed to re-render everything followed by Refresh().

Is there a way to run a test on this? Maybe a branch for testing the idea?

Best regards,

Tom
Re: DarkTheme function parameters changed [message #60908 is a reply to message #60907] Mon, 07 October 2024 09:40 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14255
Registered: November 2005
Ultimate Member
Tom1 wrote on Mon, 07 October 2024 08:51
Hi,

Sorry to interfere here, but I would not mind having both theme dependent SColors and "SkinChanged" virtual method called on Ctrls when system theme changes. When the theme changes, everything obviously needs to be Refresh()ed, which could be the default behavior of "SkinChanged". But that is not sufficient, as in some cases content is cached in pre-rendered images which are not aware of the changed theme. Therefore, "SkinChanged" is needed to re-render everything followed by Refresh().

Is there a way to run a test on this? Maybe a branch for testing the idea?

Best regards,

Tom


Not yet. After 2024 release, I can add the changes to the master - however for forseeable future, we will need "allow theme changes" flag/function call.
Re: DarkTheme function parameters changed [message #60909 is a reply to message #60904] Mon, 07 October 2024 09:43 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14255
Registered: November 2005
Ultimate Member
Lance wrote on Mon, 07 October 2024 01:59
Do you mean that we can have SColorPaper,SColorMark theme-sensitive, but there is no guarantee Blend(SColorPaper, SColorMark, 220) will make any sense in all possible themes we may throw at it?



I mean that Blend(SColorPaper, SColorMark, 220) has to be evaluated at some point. From developer perspective, the most logical point is when he calls Blend. It this was supposed to work without SkinChanged, we would need to do something like changing all colors stored in widgets to functions. I do not think that is a good idea...

Mirek

[Updated on: Mon, 07 October 2024 09:44]

Report message to a moderator

Re: DarkTheme function parameters changed [message #60910 is a reply to message #60908] Mon, 07 October 2024 10:36 Go to previous messageGo to next message
Tom1
Messages: 1301
Registered: March 2007
Ultimate Contributor
mirek wrote on Mon, 07 October 2024 10:40
Not yet. After 2024 release, I can add the changes to the master - however for forseeable future, we will need "allow theme changes" flag/function call.

Thanks! Looking forward to both of these events!

Best regards,

Tom
Re: DarkTheme function parameters changed [message #60913 is a reply to message #60909] Mon, 07 October 2024 13:57 Go to previous messageGo to next message
Lance is currently offline  Lance
Messages: 656
Registered: March 2007
Contributor
mirek wrote on Mon, 07 October 2024 03:43


I mean that Blend(SColorPaper, SColorMark, 220) has to be evaluated at some point. From developer perspective, the most logical point is when he calls Blend. It this was supposed to work without SkinChanged, we would need to do something like changing all colors stored in widgets to functions. I do not think that is a good idea...

Mirek

//header
struct SysColors
{
   Color paper;
   Color ink;
   Color mark;
   Color highlight;
   ...
   void RefreshColors();

   ...

   static SysColors scs;

private:
   SysColors(){ RefreshColors(); }
};
Color& SColorPaper = SysColors::scs.paper;
Color& SColorMark  = SysColors::scs.mark;
//cpp
SysColors SysColors::scs;



Then
Blend(SColorPaper, SColorMark, 220)

will be evaluated everytime with refreshed System Colors.

It will involve a lot of tedious work of changing copied color values to references to variables of program life time. Other than that, it should not present unnecessary work on upp users.

[Updated on: Mon, 07 October 2024 14:12]

Report message to a moderator

Re: DarkTheme function parameters changed [message #60914 is a reply to message #60910] Mon, 07 October 2024 14:03 Go to previous messageGo to next message
Lance is currently offline  Lance
Messages: 656
Registered: March 2007
Contributor
Tom1 wrote on Mon, 07 October 2024 04:36
mirek wrote on Mon, 07 October 2024 10:40
Not yet. After 2024 release, I can add the changes to the master - however for forseeable future, we will need "allow theme changes" flag/function call.

Thanks! Looking forward to both of these events!

Best regards,

Tom

I am mostly on DarkStyle, means I don't need to switch back and forth. It's a matter of u++ user experience.

Thanks for your great work BTW.
Re: DarkTheme function parameters changed [message #60915 is a reply to message #60914] Mon, 07 October 2024 14:22 Go to previous messageGo to next message
Tom1
Messages: 1301
Registered: March 2007
Ultimate Contributor
Lance wrote on Mon, 07 October 2024 15:03
I am mostly on DarkStyle, means I don't need to switch back and forth. It's a matter of u++ user experience.

Well, so am I. Smile

Yes, it's all about user experience: Many of my clients sometimes run 24/7 on vehicles and there it is very useful to be able to switch between dark and light modes (I mean the entire Windows theme) when the Sun rises and sets without need to shut down and restart our software.

Best regards,

Tom
Re: DarkTheme function parameters changed [message #60916 is a reply to message #60913] Mon, 07 October 2024 14:48 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14255
Registered: November 2005
Ultimate Member
Lance wrote on Mon, 07 October 2024 13:57
mirek wrote on Mon, 07 October 2024 03:43


I mean that Blend(SColorPaper, SColorMark, 220) has to be evaluated at some point. From developer perspective, the most logical point is when he calls Blend. It this was supposed to work without SkinChanged, we would need to do something like changing all colors stored in widgets to functions. I do not think that is a good idea...

Mirek

//header
struct SysColors
{
   Color paper;
   Color ink;
   Color mark;
   Color highlight;
   ...
   void RefreshColors();

   ...

   static SysColors scs;

private:
   SysColors(){ RefreshColors(); }
};
Color& SColorPaper = SysColors::scs.paper;
Color& SColorMark  = SysColors::scs.mark;
//cpp
SysColors SysColors::scs;



Then
Blend(SColorPaper, SColorMark, 220)

will be evaluated everytime with refreshed System Colors.


No.

ArrayCtrl ctrl;
ctrl.EvenRowColor();

it gets evaulate once, at this point. If SystemColors change, it is still evaluated for the old values. Changing values to references does not really help, you would at least need to call EvenRowColor again.

And pls note that this is just one example. What about e.g.

ctrl.Add(AttrText("Hello there!").Ink(IsDarkTheme() ? Blend(White(), LtBlue()) : Blue());

[Updated on: Mon, 07 October 2024 14:50]

Report message to a moderator

Re: DarkTheme function parameters changed [message #60917 is a reply to message #60916] Mon, 07 October 2024 16:49 Go to previous messageGo to next message
Lance is currently offline  Lance
Messages: 656
Registered: March 2007
Contributor
I see the challenge now.

We need something like theme-dependent color.

With regard to Blend(), would it ever need more than 2 colors?

I have a hackish solution.

class DynColor{
   struct _combo{
       Color c;
       char  f[4];
   };

   operator Color()const{
      switch(f[3] & 3){
      case 0: // the 64 bits are a Color*
          return * reinterpret_cast<const Color*>(this);
      case 1: // a normal color hold at data.c
          return c;
      case 2: // Blend, with f[0], f[1] the index
              // of System colors, hopefully
              // we don't have more than 256 of them
              // , and f[2] hold the third paramenter of Blend
         return Blend(GetSysColorFromIndex(f[0],
                  GetSysColorFromIndex(f[1]),
                  f[2]);
       case 3: // let's handle the
//ctrl.Add(AttrText("Hello there!").Ink(IsDarkTheme() ? Blend(White(), LtBlue()) : Blue());  
               // case here
            // theme dependant blend
           return IsDarkTheme() ?
                Blend( treat_c as byte[4], and store blend information there) :
                Blend(GetSysColorFromIndex(f[0],
                  GetSysColorFromIndex(f[1]),
                  f[2]);
          
      }
   }

private:
   combo data;
};


Just a prototype for conception. We need to consider endianness at least.

Now, we can
ctrl.Add(AttrText("Hello there!").Ink(ConstructDynColor(DarkBlender{...}, NormalBlender{...}));

Yes I am aware this requires changes to AttrText code. I can imagine it's quite involving.

Also this will require everywhere that requires dynamic color to use 64-bit color, a double in storage space.

[Updated on: Mon, 07 October 2024 17:31]

Report message to a moderator

Re: DarkTheme function parameters changed [message #60918 is a reply to message #60917] Mon, 07 October 2024 17:24 Go to previous messageGo to next message
Lance is currently offline  Lance
Messages: 656
Registered: March 2007
Contributor
ctrl.Add(AttrText("Hello there!").Ink(IsDarkTheme() ? Blend(White(), LtBlue()) : Blue());

theme-dependant color should really start from theme defined base colors. If user code ever calls IsDarkTheme(), it's really his/her responsibility to override ThemeChanged virtual function to handle these.
Re: DarkTheme function parameters changed [message #60919 is a reply to message #60918] Mon, 07 October 2024 17:34 Go to previous messageGo to next message
Lance is currently offline  Lance
Messages: 656
Registered: March 2007
Contributor
On a second thought, ThemeChanged virtual function might be the easier and less expensive way to go.
Re: DarkTheme function parameters changed [message #60930 is a reply to message #60919] Wed, 09 October 2024 23:39 Go to previous messageGo to next message
Lance is currently offline  Lance
Messages: 656
Registered: March 2007
Contributor
Maybe we can do dynamic color within the current Color. I don't know the full picture, but here are some thoughts:

1. upto 254 System colors are store in a c array that is indexable with a integer i (0<=i<=254); These are, of course, SColorPaper, SColorInk, SBlack, SWhite, etc.

2. End user(programmer) are deprived of alpha value of 255. With alpha=255
a. if r=g=b=255, that's the Null Color;
b. If g=b=255, r<255, r is the color index of a system color;
c. if b<=254, the Final Color = Blend(ColorFromIndex(r), ColorFromIndex(g), b);

3. If a programmer's Color choice conflicts with dynamic color ones, a warning will be logged but a color close enough will be silently supplied instead.

4. Color are finalized on the site. So AttrTxt, etc, only calculate the final Color before it actually renders text.

5. UPP supports light theme(normal theme), dark theme out of box, free of charge. If a programmer wants his/her program sticks to light theme, sticks to dark theme, stick to host theme (between dark and non-dark, any non-dark host theme will be interpreted to light theme by upp, before further themes are developed, if ever). Remove the chamalion Style * style;(a further 8 byte reduction on x64 platforms) from Ctrl definition, but add a GetChStyle()const virtual function, which will return light theme, dark theme, or host-dependant theme according to programmers' choice. If anyone want to Style a Ctrl, he/she should override GetChStyel() to return pointers to his/her own full set of theme values. Don't use, don't pay.

5. Icon will remain to be an issue.

Re: DarkTheme function parameters changed [message #61088 is a reply to message #60930] Wed, 13 November 2024 23:54 Go to previous message
mirek is currently offline  mirek
Messages: 14255
Registered: November 2005
Ultimate Member
https://www.ultimatepp.org/forums/index.php?t=msg&goto=6 1087&#msg_61087
Previous Topic: SetRect "MegaRect" support...
Next Topic: 2024rc
Goto Forum:
  


Current Time: Tue Apr 29 09:24:04 CEST 2025

Total time taken to generate the page: 0.03107 seconds