Logic brick connection highlighting on mouseover. Merged from candy branch. I hope...
authorMatthew Smith <mjdietel@gmail.com>
Tue, 1 May 2012 21:02:04 +0000 (21:02 +0000)
committerMatthew Smith <mjdietel@gmail.com>
Tue, 1 May 2012 21:02:04 +0000 (21:02 +0000)
source/blender/editors/interface/interface.c

index 9e12c8f94b779ece9091ecdc841e01f1571f49a1..c8806aa01663d6bcfe990aaca3a0c76051d98bd7 100644 (file)
@@ -498,7 +498,7 @@ static int ui_but_float_precision(uiBut *but, double value)
        return prec;
 }
 
-static void ui_draw_linkline(uiLinkLine *line)
+static void ui_draw_linkline(uiLinkLine *line, int hilightActiveLines)
 {
        rcti rect;
 
@@ -509,8 +509,10 @@ static void ui_draw_linkline(uiLinkLine *line)
        rect.xmax = (line->to->x1 + line->to->x2) / 2.0f;
        rect.ymax = (line->to->y1 + line->to->y2) / 2.0f;
        
-       if (line->flag & UI_SELECT) 
-               glColor3ub(100, 100, 100);
+       if(line->flag & UI_SELECT)
+               glColor3ub(100,100,100);
+       else if(hilightActiveLines && ((line->from->flag & UI_ACTIVE) || (line->to->flag & UI_ACTIVE))) 
+               UI_ThemeColor(TH_TEXT_HI);
        else 
                glColor3ub(0, 0, 0);
 
@@ -521,18 +523,38 @@ static void ui_draw_links(uiBlock *block)
 {
        uiBut *but;
        uiLinkLine *line;
-       
-       but = block->buttons.first;
-       while (but) {
-               if (but->type == LINK && but->link) {
-                       line = but->link->lines.first;
-                       while (line) {
-                               ui_draw_linkline(line);
-                               line = line->next;
+
+       // Draw the inactive lines (lines with neither button being hovered over).
+       // As we go, remember if we see any active or selected lines.
+       int foundselectline = 0;
+       int foundactiveline = 0;
+       for (but=block->buttons.first; but; but=but->next) {
+               if(but->type==LINK && but->link) {
+                       for (line=but->link->lines.first; line; line=line->next) {
+                               if (!(line->from->flag & UI_ACTIVE) && !(line->to->flag & UI_ACTIVE))
+                                       ui_draw_linkline(line, 0);
+                               else
+                                       foundactiveline = 1;
+
+                               if ((line->from->flag & UI_SELECT) || (line->to->flag & UI_SELECT))
+                                       foundselectline = 1;
                        }
                }
                but = but->next;
        }       
+
+       // Draw any active lines (lines with either button being hovered over).
+       // Do this last so they appear on top of inactive lines.
+       if (foundactiveline) {
+               for (but=block->buttons.first; but; but=but->next) {
+                       if(but->type==LINK && but->link) {
+                               for (line=but->link->lines.first; line; line=line->next) {
+                                       if ((line->from->flag & UI_ACTIVE) || (line->to->flag & UI_ACTIVE))
+                                               ui_draw_linkline(line, !foundselectline);
+                               }
+                       }
+               }       
+       }
 }
 
 /* ************** BLOCK ENDING FUNCTION ************* */