colornames

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, LCMark

colornames

Postby mwieder » Sun Oct 02, 2016 3:37 am

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().
mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
 
Posts: 2560
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US

Re: colornames

Postby livecodeali » Tue Oct 04, 2016 5:03 pm

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.
livecodeali
Livecode Staff Member
Livecode Staff Member
 
Posts: 113
Joined: Thu Apr 18, 2013 2:48 pm

Re: colornames

Postby mwieder » Tue Oct 04, 2016 5:46 pm

<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
mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
 
Posts: 2560
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US

Re: colornames

Postby livecodeali » Thu Oct 06, 2016 8:26 am

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).
livecodeali
Livecode Staff Member
Livecode Staff Member
 
Posts: 113
Joined: Thu Apr 18, 2013 2:48 pm

Re: colornames

Postby mwieder » Tue Oct 11, 2016 6:05 pm

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?
mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
 
Posts: 2560
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US


Return to Engine Contributors

Who is online

Users browsing this forum: No registered users and 4 guests