text edit: selecting zoomed in text with the mouse had an incorrect offset.
authorCampbell Barton <ideasman42@gmail.com>
Sun, 9 Oct 2011 01:11:07 +0000 (01:11 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 9 Oct 2011 01:11:07 +0000 (01:11 +0000)
source/blender/editors/interface/interface_handlers.c

index 8855bbd8e644d403989e1d003edbac88f9e9a31a..9ad828f91c16c13fa04247c968fc45ddabacb8ac 100644 (file)
@@ -1307,12 +1307,12 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho
        }
        /* mouse inside the widget */
        else if (x >= startx) {
-               float aspect= (but->block->aspect);
+               const float aspect_sqrt= sqrtf(but->block->aspect);
                
                but->pos= strlen(origstr)-but->ofs;
                
                /* XXX does not take zoom level into account */
-               while (startx + aspect*BLF_width(fstyle->uifont_id, origstr+but->ofs) > x) {
+               while (startx + aspect_sqrt * BLF_width(fstyle->uifont_id, origstr+but->ofs) > x) {
                        if (but->pos <= 0) break;
                        but->pos--;
                        origstr[but->pos+but->ofs] = 0;