UI
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 19 Jun 2009 23:11:41 +0000 (23:11 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 19 Jun 2009 23:11:41 +0000 (23:11 +0000)
* Fix issue with panel header line not always being hidden
  for the first panel.
* Fix graying out of aligned buttons being off by one pixel,
  did not find a nice solution for it though, so just added
  -1/+1 in the code.

source/blender/editors/interface/interface_panel.c
source/blender/editors/interface/interface_widgets.c

index 06582762fdb65a5414ed69c82d8d71b31acc4cdb..72076175ad5707a5833d4e4cc2744ab8f19036f4 100644 (file)
@@ -70,6 +70,7 @@
 #define PNL_WAS_ACTIVE         4
 #define PNL_ANIM_ALIGN         8
 #define PNL_NEW_ADDED          16
+#define PNL_FIRST                      32
 
 typedef enum uiHandlePanelState {
        PANEL_STATE_DRAG,
@@ -528,7 +529,7 @@ static void rectf_scale(rctf *rect, float scale)
 /* panel integrated in buttonswindow, tool/property lists etc */
 void ui_draw_aligned_panel(ARegion *ar, uiStyle *style, uiBlock *block, rcti *rect)
 {
-       Panel *panel= block->panel, *prev;
+       Panel *panel= block->panel;
        rcti headrect;
        rctf itemrect;
        int ofsx;
@@ -541,14 +542,7 @@ void ui_draw_aligned_panel(ARegion *ar, uiStyle *style, uiBlock *block, rcti *re
        headrect.ymin= headrect.ymax;
        headrect.ymax= headrect.ymin + floor(PNL_HEADER/block->aspect + 0.001f);
        
-       /* divider only when there's a previous panel */
-       prev= panel->prev;
-       while(prev) {
-               if(prev->runtime_flag & PNL_ACTIVE) break;
-               prev= prev->prev;
-       }
-       
-       if(panel->sortorder != 0) {
+       if(!(panel->runtime_flag & PNL_FIRST)) {
                float minx= rect->xmin+5.0f/block->aspect;
                float maxx= rect->xmax-5.0f/block->aspect;
                float y= headrect.ymax;
@@ -848,7 +842,7 @@ void uiEndPanels(const bContext *C, ARegion *ar)
 {
        ScrArea *sa= CTX_wm_area(C);
        uiBlock *block;
-       Panel *panot, *panew, *patest, *pa;
+       Panel *panot, *panew, *patest, *pa, *firstpa;
        
        /* offset contents */
        for(block= ar->uiblocks.first; block; block= block->next)
@@ -888,6 +882,16 @@ void uiEndPanels(const bContext *C, ARegion *ar)
                        uiAlignPanelStep(sa, ar, 1.0, 0);
        }
 
+       /* tag first panel */
+       firstpa= NULL;
+       for(block= ar->uiblocks.first; block; block=block->next)
+               if(block->active && block->panel)
+                       if(!firstpa || block->panel->sortorder < firstpa->sortorder)
+                               firstpa= block->panel;
+       
+       if(firstpa)
+               firstpa->runtime_flag |= PNL_FIRST;
+
        /* draw panels, selected on top */
        for(block= ar->uiblocks.first; block; block=block->next) {
                if(block->active && block->panel && !(block->panel->flag & PNL_SELECT)) {
index 119fd8a3fe59b941f00187e5d1ccf493b4b4139a..14df9026078d012ba8008449b7d767dde37dfd3f 100644 (file)
@@ -1876,7 +1876,9 @@ static void widget_disabled(rcti *rect)
        /* can't use theme TH_BACK or TH_PANEL... undefined */
        glGetFloatv(GL_COLOR_CLEAR_VALUE, col);
        glColor4f(col[0], col[1], col[2], 0.5f);
-       glRectf(rect->xmin, rect->ymin, rect->xmax, rect->ymax);
+       /* need -1 and +1 to make it work right for aligned buttons,
+        * but problem may be somewhere else? */
+       glRectf(rect->xmin-1, rect->ymin, rect->xmax, rect->ymax+1);
 
        glDisable(GL_BLEND);
 }