* Added checkmarks to 'table buttons' as used in RNA viewer. Helps to distinguish...
[blender.git] / source / blender / editors / interface / interface_draw.c
index de29421ef475884f038d7a31c57a99ac712a70da..405143cc4af6a051e074b665caafec46e92a4c00 100644 (file)
@@ -47,6 +47,7 @@
 #include "BIF_glutil.h"
 
 #include "UI_interface.h"
+#include "UI_interface_icons.h"
 #include "UI_text.h"
 
 #include "BMF_Api.h"
@@ -369,8 +370,6 @@ void uiEmboss(float x1, float y1, float x2, float y2, int sel)
 
 static void ui_draw_icon(uiBut *but, BIFIconID icon, int blend)
 {
-       /* XXX 2.50 need interface_icons.c */
-#if 0
        float xs=0, ys=0, aspect, height;
 
        /* this icon doesn't need draw... */
@@ -430,7 +429,6 @@ static void ui_draw_icon(uiBut *but, BIFIconID icon, int blend)
        UI_icon_draw_aspect_blended(xs, ys, icon, aspect, blend);
        
        glDisable(GL_BLEND);
-#endif
 }
 
 
@@ -680,8 +678,36 @@ static void round_button_flat(int colorid, float asp, float x1, float y1, float
        /* end outline */
 }
 
+static void ui_checkmark_box(int colorid, float x1, float y1, float x2, float y2)
+{
+       uiSetRoundBox(15);
+       UI_ThemeColorShade(colorid, -5);
+       gl_round_box_shade(GL_POLYGON, x1+4, (y1+(y2-y1)/2)-5, x1+14, (y1+(y2-y1)/2)+4, 2, -0.04, 0.03);
+       
+       UI_ThemeColorShade(colorid, -30);
+       gl_round_box(GL_LINE_LOOP, x1+4, (y1+(y2-y1)/2)-5, x1+14, (y1+(y2-y1)/2)+4, 2);
+
+}
+static void ui_checkmark(float x1, float y1, float x2, float y2)
+{
+       glEnable( GL_LINE_SMOOTH );
+       glEnable( GL_BLEND );
+       glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
+       glLineWidth(1.5);
+       
+       glBegin( GL_LINE_STRIP );
+       glVertex2f(x1+5, (y1+(y2-y1)/2)-1);
+       glVertex2f(x1+8, (y1+(y2-y1)/2)-4);
+       glVertex2f(x1+13, (y1+(y2-y1)/2)+5);
+       glEnd();
+       
+       glLineWidth(1.0);
+       glDisable( GL_BLEND );
+       glDisable( GL_LINE_SMOOTH );    
+}
+
 /* small side double arrow for iconrow */
-static void ui_default_iconrow_arrows(float x1, float y1, float x2, float y2)
+static void ui_iconrow_arrows(float x1, float y1, float x2, float y2)
 {
        glEnable( GL_POLYGON_SMOOTH );
        glEnable( GL_BLEND );
@@ -704,7 +730,7 @@ static void ui_default_iconrow_arrows(float x1, float y1, float x2, float y2)
 }
 
 /* side double arrow for menu */
-static void ui_default_menu_arrows(float x1, float y1, float x2, float y2)
+static void ui_menu_arrows(float x1, float y1, float x2, float y2)
 {
        /* 'point' first, then two base vertices */
        uiTriangleFakeAA(x2-9, (y2-(y2-y1)/2)+6,
@@ -717,7 +743,7 @@ static void ui_default_menu_arrows(float x1, float y1, float x2, float y2)
 }
 
 /* left/right arrows for number fields */
-static void ui_default_num_arrows(float x1, float y1, float x2, float y2)
+static void ui_num_arrows(float x1, float y1, float x2, float y2)
 {
        if( x2-x1 > 25) {       // 25 is a bit arbitrary, but small buttons cant have arrows
 
@@ -853,7 +879,7 @@ static void ui_roundshaded_button(int type, int colorid, float asp, float x1, fl
                        } else {
                                UI_ThemeColorShade(colorid, -45);
                        }
-                               ui_default_iconrow_arrows(x1, y1, x2, y2);
+                               ui_iconrow_arrows(x1, y1, x2, y2);
                        /* end iconrow double arrow */
                        break;
                case MENU:
@@ -863,7 +889,7 @@ static void ui_roundshaded_button(int type, int colorid, float asp, float x1, fl
                        } else {
                                UI_ThemeColorShade(colorid, -80);
                        }
-                       ui_default_menu_arrows(x1, y1, x2, y2);
+                       ui_menu_arrows(x1, y1, x2, y2);
                        /* end menu double arrow */
                        break;
        }       
@@ -933,33 +959,14 @@ static void ui_roundshaded_flat(int type, int colorid, float asp, float x1, floa
                                /* check to see that there's room for the check mark
                                * draw a check mark, or if it's a TOG3, draw a + or - */
                                if (x2 - x1 > 20) {
-                                       uiSetRoundBox(15);
-                                       UI_ThemeColorShade(colorid, -5);
-                                       gl_round_box_shade(GL_POLYGON, x1+4, (y1+(y2-y1)/2)-5, x1+14, (y1+(y2-y1)/2)+4, 2, -0.04, 0.03);
-                                       
-                                       UI_ThemeColorShade(colorid, -20);
-                                       gl_round_box(GL_LINE_LOOP, x1+4, (y1+(y2-y1)/2)-5, x1+14, (y1+(y2-y1)/2)+4, 2);
+                                       ui_checkmark_box(colorid, x1, y1, x2, y2);
                                        
                                        /* TOG3 is handled with ui_tog3_invert() 
                                                *  remember to update checkmark drawing there too*/
                                        if((flag & UI_SELECT) && (type != TOG3)) {
                                                UI_ThemeColorShade(colorid, -140);
-                                               
-                                               glEnable( GL_LINE_SMOOTH );
-                                               glEnable( GL_BLEND );
-                                               glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
-                                               glLineWidth(1.5);
-                                               
-                                               /* checkmark */
-                                               glBegin( GL_LINE_STRIP );
-                                               glVertex2f(x1+5, (y1+(y2-y1)/2)-1);
-                                               glVertex2f(x1+8, (y1+(y2-y1)/2)-4);
-                                               glVertex2f(x1+13, (y1+(y2-y1)/2)+5);
-                                               glEnd();
-                                               
-                                               glLineWidth(1.0);
-                                               glDisable( GL_BLEND );
-                                               glDisable( GL_LINE_SMOOTH );            
+       
+                                               ui_checkmark(x1, y1, x2, y2);
                                        }
                                        /* draw a dot: alternate, for layers etc. */
                                } else if(flag & UI_SELECT) {
@@ -996,7 +1003,7 @@ static void ui_roundshaded_flat(int type, int colorid, float asp, float x1, floa
                                else UI_ThemeColorShade(colorid, -20);
                        }
                        
-                       ui_default_num_arrows(x1, y1, x2, y2);
+                       ui_num_arrows(x1, y1, x2, y2);
                        /* end side arrows */
                        break;
        }       
@@ -1184,7 +1191,7 @@ static void ui_default_button(int type, int colorid, float asp, float x1, float
        
                /* ICONROW DOUBLE-ARROW  */
                M_DARK;
-               ui_default_iconrow_arrows(x1, y1, x2, y2);
+               ui_iconrow_arrows(x1, y1, x2, y2);
                /* END ICONROW DOUBLE-ARROW */
                break;
        case MENU:
@@ -1199,7 +1206,7 @@ static void ui_default_button(int type, int colorid, float asp, float x1, float
        
                /* MENU DOUBLE-ARROW  */
                M_DARK;
-               ui_default_menu_arrows(x1, y1, x2, y2);
+               ui_menu_arrows(x1, y1, x2, y2);
                /* MENU DOUBLE-ARROW */
                break;
        }       
@@ -1362,7 +1369,7 @@ static void ui_default_flat(int type, int colorid, float asp, float x1, float y1
                        else M_LGREY;
                }
                
-               ui_default_num_arrows(x1, y1, x2, y2);
+               ui_num_arrows(x1, y1, x2, y2);
                /* END SIDE ARROWS */
        }
 }
@@ -1537,7 +1544,7 @@ static void ui_draw_oldskool(int type, int colorid, float asp, float x1, float y
        case NUMABS:
                if(flag & UI_SELECT) UI_ThemeColorShade(colorid, -60);
                else UI_ThemeColorShade(colorid, -30);
-               ui_default_num_arrows(x1, y1, x2, y2);
+               ui_num_arrows(x1, y1, x2, y2);
                break;
 
        case ICONROW: 
@@ -1547,7 +1554,7 @@ static void ui_draw_oldskool(int type, int colorid, float asp, float x1, float y
                glRectf(x2-9, y1+asp, x2-asp, y2-asp);
 
                UI_ThemeColorShade(colorid, -50);
-               ui_default_iconrow_arrows(x1, y1, x2, y2);
+               ui_iconrow_arrows(x1, y1, x2, y2);
                break;
                
        case MENU: 
@@ -1556,7 +1563,7 @@ static void ui_draw_oldskool(int type, int colorid, float asp, float x1, float y
                glRectf(x2-17, y1+asp, x2-asp, y2-asp);
 
                UI_ThemeColorShade(colorid, -50);
-               ui_default_menu_arrows(x1, y1, x2, y2);
+               ui_menu_arrows(x1, y1, x2, y2);
                break;
        }
        
@@ -1687,19 +1694,19 @@ static void ui_draw_round(int type, int colorid, float asp, float x1, float y1,
        case NUM:
        case NUMABS:
                UI_ThemeColorShade(colorid, curshade-60);
-               ui_default_num_arrows(x1, y1, x2, y2);
+               ui_num_arrows(x1, y1, x2, y2);
                break;
 
        case ICONROW: 
        case ICONTEXTROW: 
                UI_ThemeColorShade(colorid, curshade-60);
-               ui_default_iconrow_arrows(x1, y1, x2, y2);
+               ui_iconrow_arrows(x1, y1, x2, y2);
                break;
                
        case MENU: 
        case BLOCK: 
                UI_ThemeColorShade(colorid, curshade-60);
-               ui_default_menu_arrows(x1, y1, x2, y2);
+               ui_menu_arrows(x1, y1, x2, y2);
                break;
        }
 }
@@ -1798,7 +1805,7 @@ static void ui_draw_minimal(int type, int colorid, float asp, float x1, float y1
        case NUMABS:
                if(flag & UI_SELECT) UI_ThemeColorShade(colorid, -60);
                else UI_ThemeColorShade(colorid, -30);
-               ui_default_num_arrows(x1, y1, x2, y2);
+               ui_num_arrows(x1, y1, x2, y2);
                break;
 
        case ICONROW: 
@@ -1808,7 +1815,7 @@ static void ui_draw_minimal(int type, int colorid, float asp, float x1, float y1
                glRectf(x2-9, y1+asp, x2-asp, y2-asp);
 
                UI_ThemeColorShade(colorid, -50);
-               ui_default_iconrow_arrows(x1, y1, x2, y2);
+               ui_iconrow_arrows(x1, y1, x2, y2);
                break;
                
        case MENU: 
@@ -1818,7 +1825,7 @@ static void ui_draw_minimal(int type, int colorid, float asp, float x1, float y1
                glRectf(x2-17, y1+asp, x2-asp, y2-asp);
 
                UI_ThemeColorShade(colorid, -50);
-               ui_default_menu_arrows(x1, y1, x2, y2);
+               ui_menu_arrows(x1, y1, x2, y2);
                break;
        }
        
@@ -2910,9 +2917,18 @@ static void ui_draw_table(int type, int colorid, float asp, float x1, float y1,
        case NUMABS:
                if(flag & UI_SELECT) UI_ThemeColorShade(colorid, -120);
                else UI_ThemeColorShade(colorid, -90);
-               ui_default_num_arrows(x1, y1, x2, y2);
+               ui_num_arrows(x1, y1, x2, y2);
                break;
 
+       case TOG:
+               ui_checkmark_box(colorid, x1, y1, x2, y2);
+               
+               if(flag & UI_SELECT) {
+                       UI_ThemeColorShade(colorid, -140);
+                       ui_checkmark(x1, y1, x2, y2);
+               }
+               break;
+               
        case ICONROW: 
        case ICONTEXTROW: 
                if(flag & UI_ACTIVE) UI_ThemeColorShade(colorid, 0);
@@ -2920,7 +2936,7 @@ static void ui_draw_table(int type, int colorid, float asp, float x1, float y1,
                glRectf(x2-9, y1+asp, x2-asp, y2-asp);
 
                UI_ThemeColorShade(colorid, -50);
-               ui_default_iconrow_arrows(x1, y1, x2, y2);
+               ui_iconrow_arrows(x1, y1, x2, y2);
                break;
                
        case MENU: 
@@ -2930,7 +2946,7 @@ static void ui_draw_table(int type, int colorid, float asp, float x1, float y1,
                glRectf(x2-17, y1+asp, x2-asp, y2-asp);
 
                UI_ThemeColorShade(colorid, -50);
-               ui_default_menu_arrows(x1, y1, x2, y2);
+               ui_menu_arrows(x1, y1, x2, y2);
                break;
        }
 }