Page MenuHome

Userpreferences Panel (for the 3DView)
ClosedPublic

Authored by Campbell Barton (campbellbarton) on Feb 2 2016, 2:39 PM.

Details

Summary

This is an attempt to improve the User preferences panel for the 3DView. I made 2 changes:

  • I reordered the sequence of properties by grouping them into more logical groups as it made sense to me. Please indicate where to rearrange the order if necessary.
  • Then i added some changes in the code to get the groups better arranged visually. I am pretty sure that this can be done much better, more clever, more generic, whatever. This is just what i could figure out on my own so far.

Diff Detail

Repository
rB Blender

Event Timeline

Gaia Clary (gaiaclary) retitled this revision from to Userpreferences Panel (for the 3DView).
Gaia Clary (gaiaclary) updated this object.

Outcome is nice but not really keen on using fake properties as sections.

This will have to be explicitly ignored in themes too.

Agreed with Campbell.

While this does result in a nicer layout (which is arguably needed and justified), polluting RNA with hack entries used only for layout purposes is a stretch too far. Remember that RNA is not just used for the UI - it's also used for various purposes such as to be displayed/browsable in the Datablocks view, and also by scripts (e.g. theme saving - as pointed out by Campbell).

You have any ideas for a better approach?

Sergey Sharybin (sergey) requested changes to this revision.Feb 10 2016, 12:05 PM

Don't find the current implementation acceptable, it's just too much hackish.

This revision now requires changes to proceed.Feb 10 2016, 12:05 PM

So now stop keeping telling how bad this is and start sharing ideas how it could be made better, ok ? thanks :)

@Gaia Clary (gaiaclary), sure, we just shouldn't have patches piling up in the "need to be reviewed" queue for until code is really ready for that.

Briefly talked to @Campbell Barton (campbellbarton) about that. Lest crappy idea (at least more localized one) would be to have a set which contains properties after which separator is to be added. Seems easier to maintain than full groups of properties. And from all the ideas i have in mind now it's indeed lest crap one.

Use "nested/fake" RNA structs.

So, do something like:

static void rna_def_userdef_theme_space_view3d(BlenderRNA *brna)
{
    StructRNA *srna;
    PropertyRNA *prop;

    /* main struct */
    srna = RNA_def_struct(brna, "ThemeView3D", NULL);
    RNA_def_struct_sdna(srna, "ThemeSpace");
    RNA_def_struct_clear_flag(srna, STRUCT_UNDO);

    /* references to nested structs */
    prop = RNA_def_property(srna, "background", PROP_POINTER, PROP_NOT_NULL);
    ... other property setting stuff ...
    prop = RNA_def_property(srna, "outlines", PROP_POINTER, PROP_NOT_NULL);
    ... blah blah ...
 

   /* one of the nested structs - Background */
   srna = RNA_def_struct(brna, "ThemeView3DBackground", ...);
   RNA_def_struct_sdna(srna, "ThemeSpace");
   RNA_def_struct_nested(brna, srna, "ThemeView3D);  // check on how the "AnimVizOnionSkinning" stuff does it :)

   prop = // gradient stuff...
  
    /* another of the nested structs - Outlines */
   srna = RNA_def_struct(brna, "ThemeView3DOutlines", ...);
   RNA_def_struct_sdna(srna, "ThemeSpace");
   RNA_def_struct_nested(brna, srna, "ThemeView3D); 

   prop = RNA_def_property(srna ,"wire", ...);
   ...

   prop = RNA_def_property(srna, "object_selected", ...);
  
   prop  = RNA_def_property(srna, "object_active", ...);    
}

@Joshua Leung (aligorith), wouldn't that change RNA paths and hence break all existing themes?

Gaia Clary (gaiaclary) edited edge metadata.

Changes as proposed by Campbel and Sergey

Gaia Clary (gaiaclary) edited edge metadata.

Added entries for more editors.
cleaned up the source a bit (to see more clearly how the line break works)

removed unnecessary parameter theme_area

Campbell Barton (campbellbarton) added inline comments.
release/scripts/startup/bl_ui/space_userpref.py
621–639

Rather keep separate logic here, so common case can be kept understandable.

if th_delimiters is None:
    old logic
else:
    new complicated logic

This will help make it more clear whats going on if we ever want to re-work the code later.

Split delimiter logic into own block, minor re-formatting

This revision was automatically updated to reflect the committed changes.