Recent

Author Topic: TColorPalette...  (Read 19149 times)

polpero

  • Jr. Member
  • **
  • Posts: 72
Re: TColorPalette...
« Reply #15 on: August 22, 2015, 01:45:06 pm »
Very nice!

I see that i really didn't need the showGrid variable.

PickMode is a little annoying in default mode in regard to the response on the colorSample shape. It won't pick the color when mouse moves between mouse Down and Up

Your selection frame is great.

Do you think that adding a color sniffer implies many lines of code?
it could show it's color in the colorSample and an addSniffedColor btn would add it to the palette... What do you think?


I've got also a webPalette, made of webSafeColors (named colors) ...
Do you think adding it as another default palette would be a good idea?

wp

  • Hero Member
  • *****
  • Posts: 6499
Re: TColorPalette...
« Reply #16 on: August 22, 2015, 02:16:53 pm »
I'm currently working at providing built-in palettes: the 16 Delphi standard colors, plus (optionally) the 4 extra Delphi colors, plus (optionally) the system colors, plus (optionally) the color gradient in "Default.pal". A "websafe" palette would fit in very nicely. Adding color names would require some restructuring because the color names have to be combined with the rgb color values.

I think it is not a good idea to pack a color picker into the component because it would be useful for other color pickers as well, or it could do a fine job as a standalone component. It would require just a few lines of code to transfer the picked color to the ComponentPalette.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

polpero

  • Jr. Member
  • **
  • Posts: 72
Re: TColorPalette...
« Reply #17 on: August 22, 2015, 02:42:59 pm »
Good... built-in palettes was exactly what i was thinking of.

I don't know if this could help you (if it's not too messy...), i assembled it a decade or more ago (see attachment)

Would you have a hint (or an example) on the color sniffer?

wp

  • Hero Member
  • *****
  • Posts: 6499
Re: TColorPalette...
« Reply #18 on: August 22, 2015, 03:36:14 pm »
Where is this unit from? What is its license?
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

polpero

  • Jr. Member
  • **
  • Posts: 72
Re: TColorPalette...
« Reply #19 on: August 22, 2015, 04:08:14 pm »
no unit

just a library... i couldn't remember where i found the source...
I was working with Delphi3 and mwSynEdit, at that time...
I found the colorNames (aren't they public?) and rearranged it all to fit my needs...
It is actually part of my HTMEdit editor: polpero.ca/tools/HTMed5.zip which i am slowly porting to Laz.

wp

  • Hero Member
  • *****
  • Posts: 6499
Re: TColorPalette...
« Reply #20 on: August 22, 2015, 09:43:06 pm »
Got the palettes in now. See property "PaletteKind". The gradient palette is furthermore controlled by "GradientSteps" - a bit confusing, but I did not find a better name: Each gradient row has a "root" color in the middle and begins at clWhite and ends before clBlack; there are "GradientSteps" boxes between the root color and the begin/end of the bar, plus the root color box itself, i.e. in total, there are GradientSteps*2+1 boxes in a row.

I added two "websafe" palettes. The first one is from the wikipedia article (https://en.wikipedia.org/wiki/Web_colors#Color_table) because there is a simple algorithm to construct it. The second one is the series of colors defined in your previously posted unit. In the latter case the colors are in the order corresponding to the color names that you have in that unit as well. The palette looks a bit scattered, it would be better to have the colors sorted per hue. I see in your unit that you added an "Index" to the TWebColor objects, but I get the impression that this is just the index in the color name array.

How important are the color names? They require some restructuring of the color list to store the strings along with the colors. But the main reason why I am a bit hesistant is that the color names are very close to the user interface, and this would mean that they should be translatable strings, and this opens another box of things to do...

Quote
PickMode is a little annoying in default mode in regard to the response on the colorSample shape. It won't pick the color when mouse moves between mouse Down and Up
Yes, I think it is annoying too, and this is the reason why I implemented the other modes. But that's the way the component had been working before I touched it. I don't know how many people have used it. If I change this default behavior I will break their code. But let me think about it a bit: There is a wiki page where I could document the changed behavior.
« Last Edit: August 22, 2015, 10:52:40 pm by wp »
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

wp

  • Hero Member
  • *****
  • Posts: 6499
Re: TColorPalette...
« Reply #21 on: August 22, 2015, 11:58:22 pm »
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

polpero

  • Jr. Member
  • **
  • Posts: 72
Re: TColorPalette...
« Reply #22 on: August 23, 2015, 05:25:12 pm »
I love the gradient palettes...
it looks real good with 8 steps and over...


I've been doing some thinking...

NAMED COLORS

The color names are more useful than the colors themselves... I mean that they offer a better memorization system. Those names get remembered more easily, that's why i keep them... and probably out of habit... Later on, on the process of refining a web page design, those named colors may be replaced by subtler shades and non-named colors but the names prove handy for quick reference... So on that plane, the palette is used rather as a memorization device to help remember and learn the names, making it possible to gradually type the names without consulting the palette...

 I do not think that those colors are meant to be sorted in their alphabetical names order. (too scattered as you said). On that level they are just names with no valuable link to the color's hue progression. I've attached two sorted colors palettes, one from the wikipedia page ( thanks, this was a useful ref.) and the other is my own sorting (from uWebCol unit) as i've been using in the HTMLEditor. If  you open the palette file you will see that i've apposed to each rgb color line the color's name, which could give an idea of how to retrieve it later for providing the selected colors information...

SAFE COLORS

I should not confuse safe colors with named colors. I understand that they are two different systems. So the palette should probably be named accordingly?

THTMLColorPalette?

Maybe the TColorPalette should remain simple and serve as a base component for a HTMLColorPalette? Since NamedColors are not new colors, only a semantic layer added to the assigned color... This way, access to colors' names and/or HexValues would be separated and (eventually, for named colors) easily accessible for localization although i haven't heard that they were translated yet...

TColorPalette as a base component could also be accompanied by a PaletteMaker to produce custom palettes. It could offer a RGB editor, drag and drop fonctionalities between 2 palettes (the referenced one and one on the making), aPalette manager where could be moved ranges from one palette to the other... Custom palettes could be used as Themes...


wp

  • Hero Member
  • *****
  • Posts: 6499
Re: TColorPalette...
« Reply #23 on: August 23, 2015, 11:18:13 pm »
Colors are named now. In the palette file, just add the color name to the line with the three rgb values, separated by a space. No hash character like in your files - this is reserved for comments (which do not need to start at the first character now) - see attachment. The method "AddColor" supports an optional second parameter to specify the color name. If the color name is empty then the color names of the graphics uinit are used as a replacement.

In the long term, we should try to extend the graphics unit with "web colors"; this would also solve localization.

I also replaced the built-in "pkWebSafePalette2" by a "pkHTMLPalette" which corresponds to the "WikipediaSort.pas" of your recent attachment.

The default of the PickMode is pmImmediate now, which is much more comfortable. The change is documented in the wiki page which was greatly extended to describe the recent changes (not finished yet). An offline version of the wiki page is included in the distribution.

Once activities have settled here I will upload a "release" zip file to sourceforge, version will be increased to 0.2
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

polpero

  • Jr. Member
  • **
  • Posts: 72
Re: TColorPalette...
« Reply #24 on: August 24, 2015, 02:52:06 pm »
much thanks
very fine and inspiring work


I had this question...

Wouldn't a more condensed form (using only 2 lines)  be appropriate in the hints message?
something like:
aColor
rgb(0,0,0) (all on one line)

but i think that your custom hintText is exactly for this purpose right? (I like it)

/////

i've got an issue with colorName on mouseMove...

Let's say i've got a previewShape that shows the mouseMove color changes
and a previewLabel that should show the associate namedColor...
(The previewShape is larger than the colorBox and acts as a ZoomIn field)

Could there be an access to the the named color on mouse move
or a curIndex that would be different from the selectedIndex to get access to colorNames[curIndex];
This index is already defined in the mouseMove procedure but is not public...

An other method would be to capture the colorPalette's hint
(previewLabel.caption := colorPalette.hint
but what if we do not want to showColorHints?



Once again
Thanks for everything
a very nice evolution


wp

  • Hero Member
  • *****
  • Posts: 6499
Re: TColorPalette...
« Reply #25 on: August 24, 2015, 07:30:48 pm »
There's now a "MouseIndex" and a "MouseColor", good for OnMouseMove event handler and some kind of "MouseOver" color panel (see second color display box in the demo).

I re-thought the names of the "BorderColor" and "BorderWidth" properties and found them a bit confusing. "BorderWidth" is now called "ButtonDistance". "BorderColor" was renamed to "ButtonBorderColor" and acts as a thin border line around the color buttons; use "clNone" to hide it. The gap between the buttons, instead, is colorized by the components standard "Color"; again, use "clNone" to skip the background color.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

polpero

  • Jr. Member
  • **
  • Posts: 72
Re: TColorPalette...
« Reply #26 on: August 24, 2015, 08:54:25 pm »
I'm still wondering if it's right to include the NamedColorsPalette in the built-in palettes.
If we take an overall look at all of them it really stands out as an exception. Demanding modification to the general structure design by it's unique names property. Should an exception rule over the design of such a structure? Wouldn't it be more sensible to have a HTMLPalette class inherit prom the TColorPalette? The funtionalities would all be there without overcharging the base component?

Tell me what you think.

I'll have a look at the latest update.


wp

  • Hero Member
  • *****
  • Posts: 6499
Re: TColorPalette...
« Reply #27 on: August 24, 2015, 09:41:31 pm »
The named palette got into TColorPalette rather naturally because the internal list which stores the colors was changed from a TList to a TStringList. Therefore, there is automatic storage for the color names along with the color values, and this is the reason why that change could be done so easily. However, except for the pkHTMLPalette, no strings are passed as color names because the corresponding colors are either known by the graphics unit which allows to extract their names by calling ColorToString(), or I don't know any good color names as in the case of the pkGradientPalette. But the user of the component has the possibility to add the color names (ColorPalette.ColorNames:= 'something').

Going through an inherited component, however, would make things more complicated (because a TStringList cannot inherit from a TList), and nobody would understand why there are two such similar components on the component palette.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

polpero

  • Jr. Member
  • **
  • Posts: 72
Re: TColorPalette...
« Reply #28 on: August 24, 2015, 09:54:43 pm »
Yes, i get your point... and since everything seems like flowing quite naturally i'll get used to it (although i still see that list as a stranger)

There's something wrong in the demo.
The mouse colors are ok, That Panel does exactly the job i had in mind but.. .the names don't folllow... can you confirm?


wp

  • Hero Member
  • *****
  • Posts: 6499
Re: TColorPalette...
« Reply #29 on: August 24, 2015, 10:08:32 pm »
Fixed in r4290
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10