News : The level of daily SPAM has reached insane proportions, all registrations are now manual. I ask you to send me an e-mail (john (at) murga (dot) org), to confirm that you want me to create an account for you.


Post Reply  Post Thread 
Pages (2): « First < Previous 1 [2] Last »
feedback please
Author Message
mikshaw
Senior Member
****


Posts: 522
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 5
Post: #11
RE: feedback please

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?

12-06-2010 08:08 AM
Find all posts by this user Quote this message in a reply
jpjacobs
Member
***


Posts: 113
Group: Registered
Joined: Jul 2007
Status: Offline
Reputation: 0
Post: #12
RE: feedback please

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

12-06-2010 10:05 AM
Find all posts by this user Quote this message in a reply
mikshaw
Senior Member
****


Posts: 522
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 5
Post: #13
RE: feedback please

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.

12-07-2010 01:37 AM
Find all posts by this user Quote this message in a reply
Pages (2): « First < Previous 1 [2] Last »
Post Reply  Post Thread 

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: