Page MenuHome

Label alignment in top bar
Open, NormalPublic


The labels in the top bar are visually disconnected from the items they belong to, making it difficult to see which element each label is connected to.


To Do

Event Timeline

William Reynish (billreynish) lowered the priority of this task from Needs Triage by Developer to Normal.Feb 15 2019, 12:20 AM

This looks like a great first task to get my feet wet in Blender coding again.

Can I get this assigned to me? I will start looking into it very soon.

I was recommended in IRC to just assign it to myself. "Be bold!"

And i stand by that statement! However if you feel like this isn't gonna work out, and bail on it, be sure to un-assign your self so someone else can have a go at this one

Be bold. But don't be discouraged if you get bogged down in weeds. If so, there are lots of fun and easy things to do to get your feet wet. Don't want you running away in frustration.

It is possible that particular problem might look simple (just move some bits over) but could involve more that it seems. It's been a while since I looked around there, but I think those things are defined in Python and then are drawn with our layout engine that primarily puts things like that in vertical columns, not horizontal rows (hence the funny alignment). So this might be about communicating this intention to put things in a single horizontal row to Layout so that it can align things differently there.

Thanks @LazyDodo (LazyDodo) and @Harley Acheson (harley). I will read around this code and see how much work it entails to fix this.

If I get stuck or overwhelmed I will let you guys know so we can decide what to do.

No worries. And feel free to ask questions. Here or here or here.

But again, if it seems impossibly complex don't assume it is you being dumb or that the source is somehow bad. It just might not be something good while learning the codebase. We have plenty of things that could look trivial but require some experience and other things that might seem tough but would just need a single word changed. But anything you do is appreciated and should be fun.


Sounds good. I have time tomorrow to start exploring the code around this and then I will report back.

In the meantime, if you find something that is the opposite: looks tough but would just need a simple change. Throw it my way. I want to learn and contribute.

It's been a week so I wanted to give an update.

I have spent around 4 hours diving into the Blender code base with the purpose of finding how the alignment in the top bar works. I got sidetracked looking at what DNA and RNA are, and a bit of how they work, since the UI elements are generated in pre-processing (source/blender/makesrna/intern/rna_scene.c). I will continue learning.

I prefer figuring things out to learn than being spoon-fed the answers. But is there anybody who can help me with some particular doubts/questions I have? Maybe somebody who is already mentoring a GSOC student?

Ray answered a few of my questions about the relationship between DNA, RNA and Python. Now things are much clearer to me. Including that I should look at Python files in release/scripts/startup/bl_ui.

I will continue my research there and report soon.

I think I have found the problem: when we calculate the width of the UI Item (as part of setting RNA callbacks to calculate the x, y, width, height in wm_draw_window_offscreen()) we are giving it too much margin.
ui_text_icon_width() has a margin of 1.5, if I bring it down manually to 0.5 the label becomes flush with what it belongs to. For example "Orientation:" and the drop down enum.

This margin makes sense for disjointed items but not for labels.

I'm not sure what is the best approach to fix this though. Any ideas/hints? I don't see anything in Python code that describes VIEW3D_GGT_xform_gizmo that I could set. Or any flag in the PropertyNRA I could try to set either. Maybe I'm looking in the wrong place.

It has been fun reading how a the layout code for WM_main() works. 😄

@Luis de Bethencourt Guimera (luisbg) - reducing the amount at that location would tighten that margin, but it is probably not where you would want to do so.

If you examine what other functions are calling ui_text_icon_width() you'll see that it is the starting point for the width of UI elements and then that value is added to, or subtracted from, depending on what kind of thing it is. So right there would probably be more of a blunt hammer to it than you want. It could be part of an approach though, depending on how much else you discover. But the trick is to not just watch what your changes do in that top bar, but also how your changes affect everything else, like in the Properties panels. The fundamental root of this issue is the assumption that these things are show in vertical columns, not a horizontal strip. But I think we do have enough information, in that Layout has concept of direction with flags such as UI_LAYOUT_HORIZONTAL.

@Harley Acheson (harley) Thanks for the quick and informative response. I will read the other functions that call ui_text_icon_width() and see if I can come up with a better approach.

I arrived to this place because I saw when ui_item_layout() iterates over all elements of the top panel UI block, these already come with the item->w set and it just sets the x coordinates by iterating like for (i = item.first; i; i->next) { x += i->w }. So at that point each item follows the next without a gap and it is too late to change widths.

I will let you know how it goes. I will keep investigating this one and get it closer to delivery, but I'm starting to feel tempted to also get an easier get-your-feet-wet bug to feel like I'm progressing and contributing. Any suggestions?