Murga-Projects Forums

Full Version: feedback please
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
On a possibly related note...
I tried to set the default selection color and ran into this problem then as well.

Non of these worked...resulted either in black or 128-0-0
Fl:set_color(fltk.FL_SELECTION_COLOR,120)
Fl:set_color(fltk.FL_SELECTION_COLOR,Fl:get_color(120))
Fl:set_color(fltk.FL_SELECTION_COLOR,Fl:get_color(some_widget:color()))

This one, however, worked:
Fl:set_color(fltk.FL_SELECTION_COLOR,Fl:get_color(120,r,g,b))
I don't know how the r,g,b comes into play, but I noticed earlier that the same thing is needed for fl_color_cube. I'm guessing the function must be applying values to those variables itself, but it seems odd that we would have to even be aware of this...wouldn't it be simpler (and less confusing) for fltk to have those variables be declared within the function, where we don't have to care about them?
The FLTK documentation says:

Quote:
void set_color(Fl_Color, uchar, uchar, uchar);
void set_color(Fl_Color, unsigned);

Sets an entry in the fl_color index table. You can set it to any 8-bit RGB color. The color is not allocated until fl_color(i) is used.


That might explain that you don't see a change directly

For the getcolor thing: the FLTK docs give 2 possible uses of getcolor: one with 1 argument, one with 4.
The one argument version simply returns 1 value (the Fl_Color, which in fact is 0xRRGGBBII where RR,GG,BB are the RGB values, and II is the index of the color in the palette).
The 3 last arguments of the 4 argument version are references to variables where the function will leave the RGB values, at least that's in C++. If I'm interpreting the fltk binding code correctly, in Lua it just returns the RGB components, and the 4 argument thing is just for signalling we want the seperate components too. As such, it's just an artifact of a limitation in C++ that doesn't exist in Lua, so I think it wouldn't be bad to simply always return everything (so Fl_Color, R,G,B). More generally it wouldn't be a bad idea to look for other functions which have references (or whatever the &var is), I think lots of times they are used for emulating a multi-value return.

So putting it shortly: merge these functions to one, returning the Fl_color and 3 components, without requiring the 4 arguments.

Greetings,

Jan-Pieter

That makes some amount of sense to me, though it will take some time and experimentation for it to sink in.

I incorrectly assumed Fl_Color constants were used simply to store a Fltk color index, which would explain why trying to use a single integer results in failure.
Pages: 1 2
Reference URL's