aardappel / treesheets

TreeSheets : Free Form Data Organizer (see strlen.com/treesheets)
zlib License
2.49k stars 184 forks source link

How are the colors in xml coded? #647

Closed noyannus closed 1 month ago

noyannus commented 1 month ago

How are the colors in xml coded?

I am trying to set a huge number of cells via xml-export > assign colors > xml-import and don't understand the numerical color values such as "12632256".

In main.xpp you assign

static uint celltextcolors[] = {
    0xFFFFFF,  // CUSTOM COLOR!
    0xFFFFFF, 0x000000, 0x202020, 0x404040, 0x606060, 0x808080, 0xA0A0A0, 0xC0C0C0, 0xD0D0D0,
    0xE0E0E0, 0xE8E8E8, 0x000080, 0x0000FF, 0x8080FF, 0xC0C0FF, 0xC0C0E0, 0x008000, 0x00FF00,
    0x80FF80, 0xC0FFC0, 0xC0E0C0, 0x800000, 0xFF0000, 0xFF8080, 0xFFC0C0, 0xE0C0C0, 0x800080,
    0xFF00FF, 0xFF80FF, 0xFFC0FF, 0xE0C0E0, 0x008080, 0x00FFFF, 0x80FFFF, 0xC0FFFF, 0xC0E0E0,
    0x808000, 0xFFFF00, 0xFFFF80, 0xFFFFC0, 0xE0E0C0,
};

but the exported xml has a different format, and the xml import understands neither 0x808080, nor #808080. And for an rgb exported gray I'd expect three adjacent identical digit pairs in the value.

So, what's your magic?

aardappel commented 1 month ago

That is simply the decimal version. If in e.g. Windows Calculator you select "Programmer" mode, then paste 12632256 and change from DEC to HEX mode, you'll get C0C0C0.

We should probably support hex import/export? @tobiolo

noyannus commented 1 month ago

Thanks.

We should probably support hex import/export?

As one who's not doing the work, I'd say, absolutely. Or, as a first step to ease use, have a documentation page that puts all such info into a single place (or simply includ it in the readme), so we users don't have to bother you with questions or try to figure it out from the source code.

tobiolo commented 1 month ago

I guess it can be done with a formatted print, see https://cplusplus.com/reference/cstdio/printf/ and some wxFormat overhead to convert back and forth (maybe not needed if directly recognized) But then we have to be backwards compatible...

aardappel commented 1 month ago

Probably, export should always be hex (more familiar), and import should support both.