[Bf-committers] Can someone please tell me what am I missing in this properties panel code
johnbartle at live.com
Wed Jul 1 07:55:00 CEST 2015
> Date: Tue, 30 Jun 2015 20:14:27 -0500
> From: akrashe at gmail.com
> To: bf-committers at blender.org
> Subject: Re: [Bf-committers] Can someone please tell me what am I missing in this properties panel code
> > Yes, actually I would like to know why it doesn't work on the default
> > outliner instance! Although, since I now know the code works, I will try to
> > figure that out. But if you or Josh want to explain this than that would be
> > extremely welcomed!!!!
> Ok this may take a bit, so bear with me. Remember that blender saves the
> user interface data inside the .blend files, so old blend files and the
> startup blend files do not have your extra region. So for both factory
> settings and old files you'll need to add your region in if you want it to
> be available.
> There are a couple of ways to approach this. First you could just add the
> area in when it's needed from the code. I don't really recommend this but
> there is precedent in the code for this, so I'll go over it and the issues
> in your code for it first.
> There is a function in your patch called outliner_has_buttons_region. This
> function is called whenever your properties region is toggled. If the
> region already exists it just returns it, but if the region does not exist
> yet it adds it to the areas region list after the RGN_TYPE_WINDOW. The
> region list for your outliner area now goes like this: Header -> Main
> Window -> Properties Buttons. The problem with this is that order matters
> on the region list. To understand this you have to know that the regions
> for the areas are setup using a function called region_rect_recursive which
> loops over the regions from first to last and assigns space to each one.
> In this case the Header takes some space along the top, then the main
> window takes all the remaining space, and finally the new properties area
> does not have any remaining space to take so it stays hidden all the time.
> So the way to fix this is to change the RGN_TYPE_WINDOW to RGN_TYPE_HEADER
> in the outliner_has_buttons_region function. Now it inserts your new
> region into the region list correctly (Header -> Properties Buttons -> Main
> Window) and when you try to toggle your properties region on a factory
> default outliner area it shows up. Note that any files you've saved with
> your patch previously and tried to toggle on your new region will always
> fail now because it was inserted and saved in the wrong place, so make sure
> to use a clean file.
> It looks like you copied this has_buttons_region function from the
> graph_has_button_regions function in the graph editor files. I think it is
> incorrect there also because I don't think you should ever insert a buttons
> region after the main window region, but in that case the code is never run
> because all blend files since 2.5 have had buttons regions already in the
> correct order, so the function never gets to the part that inserts the
> region. If you look around you can see there is a _has_buttons_region
> function for each space and most of them use RGN_TYPE_HEADER to insert the
> There are pluses and minuses to doing it this way though. The good thing
> is that you don't have to touch versioning code to test out your patch.
> The bad part is that it doesn't account for everything. If you load a file
> with your patch it still doesn't indicate that your new area is there until
> after you've fist tried to toggle it. So for instance there will be no "+"
> toggle icon on the side of the outliner area. To fully fix this you
> basically should go into the version code and there are basically two areas
> you'll have to look at.
> The first thing to consider is factory settings. This loads a .blend file
> that was compiled into the blender binary. In the source directory it is
> located at release/datafiles/startup.blend. If you want to see how it
> works look into "data_to_c" and the "datatoc" executable. You can also
> follow the WM_OT_read_factory_settings operator to see how it's loaded.
> There is probably a process for updating this compiled in startup file but
> I'm not sure of it. I think in this case you can also look at
> BLO_update_defaults_startup_blend function, it updates the factory settings
> startup file when loaded without having to save and embed the file.
> The second thing is old files. When files are loaded there is a function
> do_versions that is called to update data. You can see this is split into
> several more functions for different series. You probably want
> Somewhere in both these functions you can loop through all areas and
> spacelinks to find outliners and then add your new region in. I'm not as
> knowledgeable in the versioning code areas so I suggest looking around for
> Hope that helps.
> Bf-committers mailing list
> Bf-committers at blender.org
Thanks for the thorough reply Anthony!
Your explanation really shed some light for me on how Blender handles region areas, and also why the properties panel region was not showing up with the initial outliner instance. I don't think I would've learned that to quickly by myself.
Thanks again for your time and effort placed in your reply!
More information about the Bf-committers