Fix T37705: texture panel order wrong when switching from cycles to blender render.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Wed, 18 Dec 2013 12:15:13 +0000 (13:15 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Wed, 18 Dec 2013 12:15:13 +0000 (13:15 +0100)
source/blender/editors/interface/interface_panel.c

index be6cbaf7b72643db3429c62c84e1c81d01d347fd..76d222f4bba77bdb1ef722f6556e029bb6749aa9 100644 (file)
@@ -267,6 +267,11 @@ Panel *uiBeginPanel(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, Pan
                }
        }
 
+       /* ensure panels without header are at the top */
+       if (pt->flag & PNL_NO_HEADER) {
+               pa->sortorder = 0;
+       }
+
        /* Do not allow closed panels without headers! Else user could get "disappeared" UI! */
        if ((pt->flag & PNL_NO_HEADER) && (pa->flag & PNL_CLOSED)) {
                pa->flag &= ~PNL_CLOSED;
@@ -285,7 +290,16 @@ Panel *uiBeginPanel(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, Pan
                        break;
        
        if (newpanel) {
-               pa->sortorder = (palast) ? palast->sortorder + 1 : 0;
+               if (palast) {
+                       pa->sortorder = palast->sortorder + 1;
+               }
+               else {
+                       pa->sortorder = 0;
+
+                       for (palast = ar->panels.first; palast; palast = palast->next)
+                               if (pa->sortorder <= palast->sortorder)
+                                       pa->sortorder = palast->sortorder + 1;
+               }
 
                for (panext = ar->panels.first; panext; panext = panext->next)
                        if (panext != pa && panext->sortorder >= pa->sortorder)
@@ -1002,7 +1016,6 @@ void uiScalePanels(ARegion *ar, float new_width)
        for (block = ar->uiblocks.first; block; block = block->next) {
                if (block->panel) {
                        float fac = new_width / (float)block->panel->sizex;
-                       printf("scaled %f\n", fac);
                        block->panel->sizex = new_width;
                        
                        for (but = block->buttons.first; but; but = but->next) {