Page 1 of 1

colornames

Posted: Sun Oct 02, 2016 3:37 am
by mwieder
Pull request 4290 partially fixed bug 7344 (it's marked as fixed in LC8.1, but actually not so much).

There are two files in ide/Toolset/resources/supporting_files/colors that still need updating, colorsToNames.txt and namesToColors.txt.
I went to fix them up, but there's a header at the top of the files that says
/* This mapping comes from engine/src/rgb.cpp and should not be changed */

So before I waste even more time on this,
A. It's obvious that there's no automated build procedure to generate those files from rgb.cpp.
B. Should I ignore the warning and edit the files, or should the fix be to autogenerate the files from the cpp source?

B sounds like a better strategy in the long run, but A is an easy win.

And this isn't a pedantic issue, because as pointed out in another thread, the following line still breaks because of this:

Code: Select all

set the backgroundcolor of button 1 to "Gray3"
Edit:

Hmmm...
Looking at the code in uidc.cpp, it seems that the color tables in rgb.cpp are used after all, and the supporting files are just orphans.
I'm still working on wrapping my brain around the while(low < high) section in lookupcolor().

Re: colornames

Posted: Tue Oct 04, 2016 5:03 pm
by livecodeali
The text files are there so that the IDE knows how the engine maps colour names to colours and vice versa. The reason they were moved in the first place is that they used to reside in custom properties of an IDE stack that was subsequently scriptified.

Your B is indeed the ideal solution, but it didn't seem worth the effort at the time of moving the mappings to text files since the values in rgb.cpp hardly ever change. But as long as they are changed in both locations at the same time, all is well.

Re: colornames

Posted: Tue Oct 04, 2016 5:46 pm
by mwieder
<sigh> serves me right for asking two opposing questions and expecting a single answer.

So, if I edit the text files will the IDE then pull up the correct values? I see the mapping of the text files in revidelibrary.8.livecodescript, but I edited the text files and still can't get Gray3 to be a valid color.

Error description: penColor: bad color

Re: colornames

Posted: Thu Oct 06, 2016 8:26 am
by livecodeali
The mapping from engine color names to rgb values and back again in the text files is only used for translating to and from RGB values when interfacing between LCS and LCB (see http://quality.livecode.com/show_bug.cgi?id=16011). I hadn't noticed that they are now not up to date because of https://github.com/livecode/livecode/pull/4290, hooray. Here's a bug report: http://quality.livecode.com/show_bug.cgi?id=18546

So to answer what I think is your question, the place that matter for all uses of a color name in LCS is rgb.cpp. The text files need to be kept up to date with rgb.cpp in order to keep the mapping correct when interfacing with LCB (for example in the color swatch widget used in the property inspector).

Re: colornames

Posted: Tue Oct 11, 2016 6:05 pm
by mwieder
I have the text files fixed up now and I'm close to ready to submit a pull request, but I'm not sure where to put tests for this. I haven't been able to locate a convenient pigeonhole for text file color tests - should these go under ide core?