Recent

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

polpero

  • Full Member
  • ***
  • Posts: 116
Re: TColorPalette...
« Reply #30 on: August 24, 2015, 11:43:35 pm »
hmmm...

Did something happen to the selection rect?
The line looks thicker than it was before...
And couldn't we have a fixed color?

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: TColorPalette...
« Reply #31 on: August 24, 2015, 11:54:46 pm »
Yes, I changed the selection rect. It is 3 pixels wide now and has the opposite color of the color button. The 1-pixel wide border was not always seen very well. Using a fixed selection color is not very safe because it may have a color too close to the button.
« Last Edit: August 25, 2015, 12:14:28 am by wp »

polpero

  • Full Member
  • ***
  • Posts: 116
Re: TColorPalette...
« Reply #32 on: August 25, 2015, 12:13:42 am »
well...

i prefered it before
i find it a bit ... aggressive
has too much importance on a 1px distance
with a clForm buttonColor

but this is personal taste i admit

everything seems to work good






wp

  • Hero Member
  • *****
  • Posts: 11858
Re: TColorPalette...
« Reply #33 on: August 25, 2015, 12:36:21 am »
There was a 1-pixel calculation error which became quite evident for the 1-pixel button distance. Fixed. Maybe better now?

polpero

  • Full Member
  • ***
  • Posts: 116
Re: TColorPalette...
« Reply #34 on: August 25, 2015, 12:19:28 pm »
hmm... not really...

maybe we could have a fSelectionType of [fSNone, fSLight, fSMedium and fSHeavy]
where fSNone with a 0px width would replace fShowSelection := false?

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: TColorPalette...
« Reply #35 on: August 25, 2015, 02:16:58 pm »
Done in r4293 (with modifications). Added also SelectionColor (which is ignored if SelectionKind is pskThinInverted or pskThickInverted - ok not quite: SelectionColor is used also for SelectionKind=pskThinInverted if the inverted color matches the bordercolor).

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: TColorPalette...
« Reply #36 on: August 25, 2015, 07:18:01 pm »
Now with optional vertical orientation of the palette. New demo showing the ColorPalette in a toolbar.

polpero

  • Full Member
  • ***
  • Posts: 116
Re: TColorPalette...
« Reply #37 on: August 26, 2015, 08:26:39 pm »
Hey... that last demo is pretty cool!

but
shouldn't the palette, on Flip,
be extended to all it's length?

(i only get a 3x3 grid)

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: TColorPalette...
« Reply #38 on: August 26, 2015, 10:52:38 pm »
Going back and forth...

When writing the Toolbar demo I realized that it would be quite useful to know which mouse button had clicked on a color button. This is exactly what the old OnMousePick was designed for - and I had deprecated this event!

Therefore, the recent commits were rather destructive: I removed the OnSelectColor event to fully bring back the OnMousePick, replaced the SelectedColor and SelectedIndex by the PickedColor and PickedIndex. Also, the "PickShift" property is no longer needed.

And I saw that the form is not notified when the mouse leaves the entire colorpalette - now the OnColorMouseMoveEvent fires at this moment. And I saw that I had introduced an incompatible change into the emitting ColorMouseMove procedure because I had fired the event had only when the mouse had entered a different tile of the palette. Now, as in the original version, the OnColorMouseMove fires with every mouse movement. Although the standard OnMouseMove event can be used for tracking the mouse color as well I'd prefer to use the OnColorMouseMove because then the MouseLeave is handled correctly.

Quote
but
shouldn't the palette, on Flip,
be extended to all it's length?

(i only get a 3x3 grid)
Yes, it is fixed now. Working with Coolbars is still a pain (but 1000x better than in Delphi)...

polpero

  • Full Member
  • ***
  • Posts: 116
Re: TColorPalette...
« Reply #39 on: August 27, 2015, 01:54:11 am »
Quote
Therefore, the recent commits were rather destructive
hmm... that's bad :(
but it explains a few annoying messages on compiling
...


Since we're still in the process of going back and forth :) what would you think of changing the TPaletteSelectionKind to: "none, thin, normal, thick" and of modifying the selection color to fixed or auto ? Auto being the inverted colors... I'm still looking for the right calibration here... what do you think?

On the subject of questioning, why is it that we need a mouseColorMove and a MouseMove? Since we are here in a colorPalette, isn't it self-descriptive that the mouseMoves will be mouseColorMoves?  ... just trying to simplify...

Finally

i'm working on a merge of my former colorpalette to this one and am preparing a new demo. I'm not ready to send it right away, i need a few hours more... but in the process i've got an issue on loading and saving that you might be simplify. If i show you the code you'll probably understand immediatly so here are the saving and loading procedures:

Code: [Select]
procedure TmainForm.doSavePalFile;
var pStr, fName, tmp: string;
   i: word;
   outFile: tStringList;
begin
  try
    outFile := tStringList.create;
    with colPalet do
    begin
      fName := mainPath+'tmp.pal';
      savePalette(fName); //TColorPalette save
      outFile.LoadFromFile(fName);
      tmp := outFile.text;
      // prepare properties
      pStr := '# ' + PalName + #10
            + '#<PROPS>' + #10
            + '##########################################' + #10
            + '# PALETTE PROPERTIES ( Should/Could be unHashed? ) ' + #10
            + '#$BTNSIZE ' + intToStr(ButtonWidth) + #10
            + '#$BTNCOLOR ' + colorToString(ButtonBorderColor) + #10
            + '#$BTNDIST ' + intToStr(ButtonDistance) + #10
            + '#$SELKIND ' + intToStr(ord(SelectionKind)) + #10
            + '#$SELCOLOR ' + colorToString(SelectionColor) + #10
            + '#' + #10
            + '#</PROPS>'
            + #10
            ;
    end;
  finally
     outFile.text := pStr + tmp ;
     fName := filePath + palName;
     outFile.SaveToFile(fName);
     outFile.free;
     FListBox.UpdateFileList;
     lastFileName := fName;
  end;
end; {doSavePalFile}



procedure TmainForm.doLoadPalFile(fName: string);
var pBuff: string;
   inStr: TStringList;
   function getValue(aKey: string):string;
   var ...
   begin
     sKey := '#$'+aKey;
     ...
     result := //the corresponding value
     end;
   end;

begin
  if not fileExists(fName) then exit;

  inStr := TStringList.create;
  inStr.LoadFromFile(fName);
  pBuff := copy(inStr.text,1,pos('#</PROPS>',inStr.text));
  with ColPalet do
  begin
    if pBuff <> '' then
    begin
       ButtonWidth := strToInt(getValue('BTNSIZE'));
       ... etc
    end;
    loadPalette(fName);
    EdColCount.Value := columnCount ;
  end;

  inStr.free;
end;  {doLoadPalFile}

Could we extend the TColorPalette syntax to include a few properties? Although those procedures work well, - hidden behind the hashes could be inserted a second level of instructions that don't trouble the colorPalette - but it would be much simpler if it was integrated...

I don't think all the properties have to get there but some might be quite convenient: a palette with numerous entries might be better served with small buttons and inversely few entries better served with large buttons...





wp

  • Hero Member
  • *****
  • Posts: 11858
Re: TColorPalette...
« Reply #40 on: August 29, 2015, 01:52:30 pm »
Sorry I missed the time while your post was "Recent"...

Quote
changing the TPaletteSelectionKind to: "none, thin, normal, thick"
"thin" is 1px, "thick" is 3px, therefore "normal" must be be 2px. Unlike the odd pixel counts, 2px is not symmetrical to the reference points, and it is not clear whether the second line will be inside or outside the shape. This, furthermore, may depend on widgetset. I do not want to go through the additional complexity of implementing the component in various widgetsets for an almost invisible additional feature.

Quote
modifying the selection color to fixed or auto ? Auto being the inverted colors...
No, this would add another property which is not needed if the selectionkinds contain this information...

Quote
Could we extend the TColorPalette syntax to include a few properties?
OK, i'll add properties to the file format. But there'll be an optional parameter "ColorsOnly" for the "LoadPalette" method because I could imagine cases where the properties embedded in the file could be disruptive to an existing layout.

polpero

  • Full Member
  • ***
  • Posts: 116
Re: TColorPalette...
« Reply #41 on: August 29, 2015, 02:35:51 pm »
I've been carried away by other business too...

Hey
why is it that the PaletteSelectionKind order is different in the declaration
than in the properties palette (in the explorer)?

Quote
... this would add another property which is not needed
Yeah ok...
(although it would give more unity to the enumeration
  if the color aspect wasn't mixed throuth it...
  but the list is short...  one or the other,
  it doesn't really matter)

Quote
... because I could imagine cases where the properties embedded in the file could be disruptive to an existing layout.

Example?



wp

  • Hero Member
  • *****
  • Posts: 11858
Re: TColorPalette...
« Reply #42 on: August 29, 2015, 04:44:05 pm »
Uploaded a version in which some new keywords can be used in the palette file:
  • $BTNDIST value
  • $BTNWIDTH value
  • $BTNHEIGHT value
  • $BTNBORDER r,g,b
  • $FLIPPED TRUE (or FALSE)
  • $SELKIND NONE (or THIN or THICK or THIN-INV or THICK-INV)
  • $SELCOLOR r,g,b
LoadPalette has a new (optional) parameter "AItems" which is a set of TPaletteItem = (piColors, piColumnCount, piFlipped, piButtonBorder, piButtonSize, piButtonDistance,  piSelKind, piSelColor) to identify which parameters will be loaded. The default is [piColors, piColumnCount] as it was before; use piAll to load everything.

SavePalette writes a palette with all the properties.

Quote
Example?
Suppose I send you a palette file, I like SelectionKind piThickInverted, no button distance, you like piThin with some particular SelectionColor, and 4 pixels button distance. You would not be happy I you load my palette...

Quote
why is it that the PaletteSelectionKind order is different in the declaration
than in the properties palette (in the explorer)?
This is done by Lazarus' property editor for enumerations which sorts the enumerated elements alphabetically.

Quote
why is it that we need a mouseColorMove and a MouseMove?
Probably we don't. I got carried away because I wanted to call an existing method in the MouseExit procedure and did not want to call MouseMove - ColorMouseMove looked right. Probably I'll make them equivalent and deprecate OnMouseColorMove.

polpero

  • Full Member
  • ***
  • Posts: 116
Re: TColorPalette...
« Reply #43 on: August 29, 2015, 05:01:11 pm »
Quote
Uploaded a version in which some new keywords

Thanks!
I'll update my stuff here
( still working on that demo...
   that was supposed to be a few hours away...)


Quote
Suppose I send you a palette file, ... You would not be happy I you load my palette...

Hmmm clever!
hadn't thought about that
(But i wouldn't be that unhappy
  since i already knew about your prefs... : ) )

///////////////////////

THOUGHTS...
... on clearing...

clearColors needs a refresh should it be included?
clearColors clears the colors but leaves the buttons...
why would we want the colors gone but not the buttons?
Should we have a 'clear' procedure that clears the colors
and resets columnCount to 0?

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: TColorPalette...
« Reply #44 on: August 29, 2015, 05:54:20 pm »
Quote
clearColors needs a refresh should it be included?
In principle, yes, but who prevents you from setting ColumnCount=0 explicitly? Anyway, ClearColors by itself is rather useless - who wants to work with an empty palette? It is only an intermediate step to create a palette from code, and the layout can be created when everything is set.
« Last Edit: August 29, 2015, 06:31:10 pm by wp »

 

TinyPortal © 2005-2018