Unable to add new theme options

Hello. Tinkering with blender’s source code, I tried to add a new theme color option for the outliner. With little idea of how to add the option, I tracked an existing outliner theme setting, Selected Highlight, and added matching code for my option everywhere ‘selected_highlight’ and ‘TH_SELECT_HIGHLIGHT’ appeared, duplicating its code and changing only the names. It failed to compile via cmake :stuck_out_tongue: . What other code is necessary to successfully add a new color theme option? Thanks :slight_smile:

Edited source code files:

Some of the errors while compiling:
Align struct error: bTheme …(tv3d, tipo, tact, etc.)
Sizeerror 8 in struct: bTheme (add 4 bytes)
source/blender/makesdna/intern/CMakeFiles/bf_dna.dir/build.make:61: recipe for target ‘source/blender/makesdna/intern/dna.c’ failed

Makefile:162: recipe for target ‘all’ failed
cmake: *** [all] Error 2

1 Like

Only a wild-ass guess, but whenever I get a nonspecific and odd error during compilation it is because I have added a new member to a struct that needs to be 64-bit aligned. Look to see if there any “pad” fields nearby and it might make sense.

Whenever I add a new member to, at least, some structs like Object or SpaceOutliner I have to do a “Clean Solution” in VS.

I also, don’t know if this has anything to do with resolving the OP’s problem.

EDIT: Having looked again at the OP’s post, I guess alignment seems probably the problem.

1 Like

Only just noticed this part in your error message. So yes, you’ll need to add or remove padding fields as needed to keep the struct as an even multiple of eight bytes. Although the struct in question isn’t really bTheme but probably ThemeSpace. You’ll find there will be padding you can remove if adding to it.

You might have missed one file too. If everything should work but your new colour starts off as black then look at versioning_userdef.c

1 Like

Got rid of a pad and it works :smiley:

1 Like