Revision: 18304
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18304
Author:   broken
Date:     2009-01-04 03:09:41 +0100 (Sun, 04 Jan 2009)

Log Message:
-----------
* Added support for displaying disabled RNA buttons

The functionality already existed via the RNA system, this
commit makes disabled buttons draw greyed out, and not respond to clicks
(previously, they would drag/edit/etc but then reset to the previous value)

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/include/UI_interface.h
    branches/blender2.5/blender/source/blender/editors/interface/interface.c
    
branches/blender2.5/blender/source/blender/editors/interface/interface_draw.c

Modified: 
branches/blender2.5/blender/source/blender/editors/include/UI_interface.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/UI_interface.h   
2009-01-04 01:08:01 UTC (rev 18303)
+++ branches/blender2.5/blender/source/blender/editors/include/UI_interface.h   
2009-01-04 02:09:41 UTC (rev 18304)
@@ -115,8 +115,8 @@
 #define UI_BUT_ALIGN_LEFT      (1<<13)
 #define UI_BUT_ALIGN_RIGHT     (1<<14)
 #define UI_BUT_ALIGN_DOWN      (1<<15)
+#define UI_BUT_DISABLED                (1<<16)
 
-
 /* Button types, bits stored in 1 value... and a short even!
 - bits 0-4:  bitnr (0-31)
 - bits 5-7:  pointer type

Modified: 
branches/blender2.5/blender/source/blender/editors/interface/interface.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface.c    
2009-01-04 01:08:01 UTC (rev 18303)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface.c    
2009-01-04 02:09:41 UTC (rev 18304)
@@ -2118,6 +2118,12 @@
        but->rnapoin= *ptr;
        but->rnaprop= prop;
        but->rnaindex= index;
+       
+       if (!RNA_property_editable(&but->rnapoin, prop)) {
+               but->flag |= UI_BUT_DISABLED;
+               but->lock = 1;
+               but->lockstr = "";
+       }
 
        if(freestr)
                MEM_freeN(str);

Modified: 
branches/blender2.5/blender/source/blender/editors/interface/interface_draw.c
===================================================================
--- 
branches/blender2.5/blender/source/blender/editors/interface/interface_draw.c   
    2009-01-04 01:08:01 UTC (rev 18303)
+++ 
branches/blender2.5/blender/source/blender/editors/interface/interface_draw.c   
    2009-01-04 02:09:41 UTC (rev 18304)
@@ -58,6 +58,8 @@
 #include "interface_intern.h"
 
 #define UI_RB_ALPHA 16
+#define UI_DISABLED_ALPHA_OFFS -160
+
 static int roundboxtype= 15;
 
 void uiSetRoundBox(int type)
@@ -485,13 +487,14 @@
 
 void uiTriangleFakeAA(float x1, float y1, float x2, float y2, float x3, float 
y3, float asp)
 {
-       float color[4];
+       float color[4], alpha;
        float jitter;
        int i, passes=4;
        
        /* get the colour and divide up the alpha */
        glGetFloatv(GL_CURRENT_COLOR, color);
-       color[3]= 1.0/(float)passes;
+       alpha = color[3];
+       color[3]= alpha/(float)passes;
        glColor4fv(color);
        
        /* set the 'jitter amount' */
@@ -511,6 +514,9 @@
        }
        
        glDisable( GL_BLEND );
+       
+       color[3] = alpha;
+       glColor4fv(color);
 }
 
 /* for headers and floating panels */
@@ -1116,6 +1122,7 @@
 {
        float rad, maxrad;
        int align= (flag & UI_BUT_ALIGN);
+       int alpha_offs= (flag & UI_BUT_DISABLED)?UI_DISABLED_ALPHA_OFFS:0;
        
        /* rounded corners */
        if (ELEM4(type, MENU, ROW, ICONROW, ICONTEXTROW)) maxrad = 5.0;
@@ -1176,9 +1183,9 @@
                case ICONTEXTROW:                       
                        /* iconrow double arrow  */
                        if(flag & UI_SELECT) {
-                               UI_ThemeColorShade(colorid, -80);
+                               UI_ThemeColorShadeAlpha(colorid, -80, 
alpha_offs);
                        } else {
-                               UI_ThemeColorShade(colorid, -45);
+                               UI_ThemeColorShadeAlpha(colorid, -45, 
alpha_offs);
                        }
                                ui_iconrow_arrows(x1, y1, x2, y2);
                        /* end iconrow double arrow */
@@ -1186,9 +1193,9 @@
                case MENU:
                        /* menu double arrow  */
                        if(flag & UI_SELECT) {
-                               UI_ThemeColorShade(colorid, -110);
+                               UI_ThemeColorShadeAlpha(colorid, -110, 
alpha_offs);
                        } else {
-                               UI_ThemeColorShade(colorid, -80);
+                               UI_ThemeColorShadeAlpha(colorid, -80, 
alpha_offs);
                        }
                        ui_menu_arrows(x1, y1, x2, y2, asp);
                        /* end menu double arrow */
@@ -1200,6 +1207,7 @@
 {
        float rad, maxrad=10.0;
        int align= (flag & UI_BUT_ALIGN);
+       int alpha_offs= (flag & UI_BUT_DISABLED)?UI_DISABLED_ALPHA_OFFS:0;
        
        /* rounded corners */
        rad= (y2-y1)/2.0;
@@ -1261,11 +1269,11 @@
                case NUM:
                        /* side arrows */
                        if(flag & UI_SELECT) {
-                               if(flag & UI_ACTIVE) 
UI_ThemeColorShade(colorid, -70);
-                               else UI_ThemeColorShade(colorid, -70);
+                               if(flag & UI_ACTIVE) 
UI_ThemeColorShadeAlpha(colorid, -70, alpha_offs);
+                               else UI_ThemeColorShadeAlpha(colorid, -70, 
alpha_offs);
                        } else {
-                               if(flag & UI_ACTIVE) 
UI_ThemeColorShade(colorid, -40);
-                               else UI_ThemeColorShade(colorid, -20);
+                               if(flag & UI_ACTIVE) 
UI_ThemeColorShadeAlpha(colorid, -40, alpha_offs);
+                               else UI_ThemeColorShadeAlpha(colorid, -20, 
alpha_offs);
                        }
                        
                        ui_num_arrows(x1, y1, x2, y2, asp);
@@ -1303,6 +1311,7 @@
 static void ui_default_button(int type, int colorid, float asp, float x1, 
float y1, float x2, float y2, int flag)
 {
        int align= (flag & UI_BUT_ALIGN);
+       int alpha_offs= (flag & UI_BUT_DISABLED)?UI_DISABLED_ALPHA_OFFS:0;
 
        if(align) {
        
@@ -1455,7 +1464,7 @@
                /* END DARKENED AREA */
        
                /* ICONROW DOUBLE-ARROW  */
-               M_DARK;
+               UI_ThemeColorShadeAlpha(colorid, -80, alpha_offs);
                ui_iconrow_arrows(x1, y1, x2, y2);
                /* END ICONROW DOUBLE-ARROW */
                break;
@@ -1470,7 +1479,7 @@
                /* END DARKENED AREA */
        
                /* MENU DOUBLE-ARROW  */
-               M_DARK;
+               UI_ThemeColorShadeAlpha(colorid, -80, alpha_offs);
                ui_menu_arrows(x1, y1, x2, y2, asp);
                /* MENU DOUBLE-ARROW */
                break;
@@ -1481,6 +1490,7 @@
 static void ui_default_flat(int type, int colorid, float asp, float x1, float 
y1, float x2, float y2, int flag)
 {
        int align= (flag & UI_BUT_ALIGN);
+       int alpha_offs= (flag & UI_BUT_DISABLED)?UI_DISABLED_ALPHA_OFFS:0;
 
        if(align) {
        
@@ -1627,11 +1637,11 @@
                /* SIDE ARROWS */
                /* left */
                if(flag & UI_SELECT) {
-                       if(flag & UI_ACTIVE) M_DARK;
-                       else M_DARK;
+                       if(flag & UI_ACTIVE) UI_ThemeColorShadeAlpha(colorid, 
-80, alpha_offs);
+                       else UI_ThemeColorShadeAlpha(colorid, -80, alpha_offs);
                } else {
-                       if(flag & UI_ACTIVE) M_GREY;
-                       else M_LGREY;
+                       if(flag & UI_ACTIVE) UI_ThemeColorShadeAlpha(colorid, 
-45, alpha_offs);
+                       else UI_ThemeColorShadeAlpha(colorid, -20, alpha_offs);
                }
                
                ui_num_arrows(x1, y1, x2, y2, asp);
@@ -1767,6 +1777,7 @@
 
 static void ui_draw_oldskool(int type, int colorid, float asp, float x1, float 
y1, float x2, float y2, int flag)
 {
+       int alpha_offs= (flag & UI_BUT_DISABLED)?UI_DISABLED_ALPHA_OFFS:0;
        /* paper */
        if(flag & UI_SELECT) {
                if(flag & UI_ACTIVE) UI_ThemeColorShade(colorid, -40);
@@ -1809,27 +1820,27 @@
        switch(type) {
        case NUM:
        case NUMABS:
-               if(flag & UI_SELECT) UI_ThemeColorShade(colorid, -60);
-               else UI_ThemeColorShade(colorid, -30);
+               if(flag & UI_SELECT) UI_ThemeColorShadeAlpha(colorid, -60, 
alpha_offs);
+               else UI_ThemeColorShadeAlpha(colorid, -30, alpha_offs);
                ui_num_arrows(x1, y1, x2, y2, asp);
                break;
 
        case ICONROW: 
        case ICONTEXTROW: 
-               if(flag & UI_ACTIVE) UI_ThemeColorShade(colorid, 0);
-               else UI_ThemeColorShade(colorid, -10);
+               if(flag & UI_ACTIVE) UI_ThemeColorShadeAlpha(colorid, 0, 
alpha_offs);
+               else UI_ThemeColorShadeAlpha(colorid, -10, alpha_offs);
                glRectf(x2-9, y1+asp, x2-asp, y2-asp);
 
-               UI_ThemeColorShade(colorid, -50);
+               UI_ThemeColorShadeAlpha(colorid, -50, alpha_offs);
                ui_iconrow_arrows(x1, y1, x2, y2);
                break;
                
        case MENU: 
-               if(flag & UI_ACTIVE) UI_ThemeColorShade(colorid, 0);
-               else UI_ThemeColorShade(colorid, -10);
+               if(flag & UI_ACTIVE) UI_ThemeColorShadeAlpha(colorid, 0, 
alpha_offs);
+               else UI_ThemeColorShadeAlpha(colorid, -10, alpha_offs);
                glRectf(x2-17, y1+asp, x2-asp, y2-asp);
 
-               UI_ThemeColorShade(colorid, -50);
+               UI_ThemeColorShadeAlpha(colorid, -50, alpha_offs);
                ui_menu_arrows(x1, y1, x2, y2, asp);
                break;
        }
@@ -1840,6 +1851,7 @@
 {
        float rad, maxrad=7.0;
        int align= (flag & UI_BUT_ALIGN), curshade;
+       int alpha_offs= (flag & UI_BUT_DISABLED)?UI_DISABLED_ALPHA_OFFS:0;
        
        /* rounded corners */
        rad= (y2-y1)/2.0;
@@ -1912,19 +1924,19 @@
                break;
        case NUM:
        case NUMABS:
-               UI_ThemeColorShade(colorid, curshade-60);
+               UI_ThemeColorShadeAlpha(colorid, curshade-60, alpha_offs);
                ui_num_arrows(x1, y1, x2, y2, asp);
                break;
 
        case ICONROW: 
        case ICONTEXTROW: 
-               UI_ThemeColorShade(colorid, curshade-60);
+               UI_ThemeColorShadeAlpha(colorid, curshade-60, alpha_offs);
                ui_iconrow_arrows(x1, y1, x2, y2);
                break;
                
        case MENU: 
        case BLOCK: 
-               UI_ThemeColorShade(colorid, curshade-60);
+               UI_ThemeColorShadeAlpha(colorid, curshade-60, alpha_offs);
                ui_menu_arrows(x1, y1, x2, y2, asp);
                break;
        }
@@ -1939,6 +1951,8 @@
 /* super minimal button as used in logic menu */
 static void ui_draw_minimal(int type, int colorid, float asp, float x1, float 
y1, float x2, float y2, int flag)
 {
+       int alpha_offs= (flag & UI_BUT_DISABLED)?UI_DISABLED_ALPHA_OFFS:0;
+       
        /* too much space between buttons */
        
        if (type==TEX || type==IDPOIN) {
@@ -2022,28 +2036,28 @@
        switch(type) {
        case NUM:
        case NUMABS:
-               if(flag & UI_SELECT) UI_ThemeColorShade(colorid, -60);
-               else UI_ThemeColorShade(colorid, -30);
+               if(flag & UI_SELECT) UI_ThemeColorShadeAlpha(colorid, -60, 
alpha_offs);
+               else UI_ThemeColorShadeAlpha(colorid, -30, alpha_offs);
                ui_num_arrows(x1, y1, x2, y2, asp);
                break;
 
        case ICONROW: 
        case ICONTEXTROW: 
-               if(flag & UI_ACTIVE) UI_ThemeColorShade(colorid, 0);
-               else UI_ThemeColorShade(colorid, -10);
+               if(flag & UI_ACTIVE) UI_ThemeColorShadeAlpha(colorid, 0, 
alpha_offs);
+               else UI_ThemeColorShadeAlpha(colorid, -10, alpha_offs);
                glRectf(x2-9, y1+asp, x2-asp, y2-asp);
 
-               UI_ThemeColorShade(colorid, -50);
+               UI_ThemeColorShadeAlpha(colorid, -50, alpha_offs);
                ui_iconrow_arrows(x1, y1, x2, y2);
                break;
                
        case MENU: 
        case BLOCK: 
-               if(flag & UI_ACTIVE) UI_ThemeColorShade(colorid, 0);
-               else UI_ThemeColorShade(colorid, -10);
+               if(flag & UI_ACTIVE) UI_ThemeColorShadeAlpha(colorid, 0, 
alpha_offs);
+               else UI_ThemeColorShadeAlpha(colorid, -10, alpha_offs);
                glRectf(x2-17, y1+asp, x2-asp, y2-asp);
 
-               UI_ThemeColorShade(colorid, -50);
+               UI_ThemeColorShadeAlpha(colorid, -50, alpha_offs);
                ui_menu_arrows(x1, y1, x2, y2, asp);
                break;
        }
@@ -2228,6 +2242,7 @@
        char *cpoin;
        short t, pos, ch;
        short selsta_tmp, selend_tmp, selsta_draw, selwidth_draw;
+       int alpha_offs= (but->flag & UI_BUT_DISABLED)?UI_DISABLED_ALPHA_OFFS:0;
        
        /* check for button text label */
        if (but->type == ICONTEXTROW) {
@@ -2339,16 +2354,16 @@
                        if(tog3);       // color already set
                        else if(but->dt==UI_EMBOSSP) {
                                if((but->flag & (UI_SELECT|UI_ACTIVE)) && 
but->type!=LABEL) {   // LABEL = title in pulldowns
-                                       UI_ThemeColor(TH_MENU_TEXT_HI);
+                                       
UI_ThemeColorShadeAlpha(TH_MENU_TEXT_HI, 0, alpha_offs);
                                } else {
-                                       UI_ThemeColor(TH_MENU_TEXT);
+                                       UI_ThemeColorShadeAlpha(TH_MENU_TEXT, 
0, alpha_offs);
                                }
                        }
                        else {
                                if(but->flag & UI_SELECT) {             
-                                       UI_ThemeColor(TH_BUT_TEXT_HI);
+                                       UI_ThemeColorShadeAlpha(TH_BUT_TEXT_HI, 
0, alpha_offs);

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to