Commit: d914d101ecc7f2e70398182978b491c9710ef64b
Author: Campbell Barton
Date:   Fri May 30 10:20:58 2014 +1000
https://developer.blender.org/rBd914d101ecc7f2e70398182978b491c9710ef64b

UI: fix for drawing textselect outside of button

also draw cursor even when there is a selection.

===================================================================

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

===================================================================

diff --git a/source/blender/editors/interface/interface_widgets.c 
b/source/blender/editors/interface/interface_widgets.c
index b25aac7..b0be614 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -1248,40 +1248,39 @@ static void widget_draw_text(uiFontStyle *fstyle, 
uiWidgetColors *wcol, uiBut *b
 
        /* text button selection and cursor */
        if (but->editstr && but->pos != -1) {
-               short t = 0, pos = 0;
-               short selsta_tmp, selend_tmp, selsta_draw, selwidth_draw;
 
+               /* text button selection */
                if ((but->selend - but->selsta) > 0) {
-                       /* text button selection */
-                       selsta_tmp = but->selsta;
-                       selend_tmp = but->selend;
+                       int selsta_draw, selwidth_draw;
                        
                        if (drawstr[0] != 0) {
 
                                if (but->selsta >= but->ofs) {
-                                       selsta_draw = 
BLF_width(fstyle->uifont_id, drawstr + but->ofs, selsta_tmp - but->ofs);
+                                       selsta_draw = 
BLF_width(fstyle->uifont_id, drawstr + but->ofs, but->selsta - but->ofs);
                                }
                                else {
                                        selsta_draw = 0;
                                }
 
-                               selwidth_draw = BLF_width(fstyle->uifont_id, 
drawstr + but->ofs, selend_tmp - but->ofs);
+                               selwidth_draw = BLF_width(fstyle->uifont_id, 
drawstr + but->ofs, but->selend - but->ofs);
 
                                glColor4ubv((unsigned char *)wcol->item);
-                               glRects(rect->xmin + selsta_draw, rect->ymin + 
2, rect->xmin + selwidth_draw, rect->ymax - 2);
+                               glRecti(rect->xmin + selsta_draw,
+                                       rect->ymin + 2,
+                                       min_ii(rect->xmin + selwidth_draw, 
rect->xmax - 2),
+                                       rect->ymax - 2);
                        }
                }
-               else {
-                       /* text cursor */
-                       pos = but->pos;
-                       if (pos >= but->ofs) {
-                               if (drawstr[0] != 0) {
-                                       t = BLF_width(fstyle->uifont_id, 
drawstr + but->ofs, pos - but->ofs);
-                               }
 
-                               glColor3f(0.20, 0.6, 0.9);
-                               glRects(rect->xmin + t, rect->ymin + 2, 
rect->xmin + t + 2, rect->ymax - 2);
+               /* text cursor */
+               if (but->pos >= but->ofs) {
+                       int t;
+                       if (drawstr[0] != 0) {
+                               t = BLF_width(fstyle->uifont_id, drawstr + 
but->ofs, but->pos - but->ofs);
                        }
+
+                       glColor3f(0.20, 0.6, 0.9);
+                       glRecti(rect->xmin + t, rect->ymin + 2, rect->xmin + t 
+ 2, rect->ymax - 2);
                }
        }

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

Reply via email to