diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-03-13 22:40:36 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-03-13 22:40:36 +0300 |
commit | 15215493bf9d1d08e650109e6eb6189fc76e289e (patch) | |
tree | bf04a7c508fca916b22518439b02ab8901c205db /source/blender/src/drawtext.c | |
parent | ecc4ccf68f057788cbd1e117672b8531ca7f286f (diff) |
Two bugfixes:
- Clicking below the list of items in the shift+f4 databrowser could crash.
- Text window crashed when making it zero size.
Diffstat (limited to 'source/blender/src/drawtext.c')
-rw-r--r-- | source/blender/src/drawtext.c | 84 |
1 files changed, 45 insertions, 39 deletions
diff --git a/source/blender/src/drawtext.c b/source/blender/src/drawtext.c index 22351479883..8ef18ee954e 100644 --- a/source/blender/src/drawtext.c +++ b/source/blender/src/drawtext.c @@ -740,13 +740,13 @@ static void calc_text_rcts(SpaceText *st) ltexth += blank_lines; - barheight = (st->viewlines*pix_available) / ltexth; + barheight = (ltexth > 0)? (st->viewlines*pix_available)/ltexth: 0; pix_bardiff = 0; if (barheight < 20) { pix_bardiff = 20 - barheight; /* take into account the now non-linear sizing of the bar */ barheight = 20; } - barstart = ((pix_available - pix_bardiff) * st->top) / ltexth; + barstart = (ltexth > 0)? ((pix_available - pix_bardiff) * st->top)/ltexth: 0; st->txtbar.xmin = 5; st->txtbar.xmax = 17; @@ -756,7 +756,7 @@ static void calc_text_rcts(SpaceText *st) CLAMP(st->txtbar.ymin, pix_bottom_margin, curarea->winy - pix_top_margin); CLAMP(st->txtbar.ymax, pix_bottom_margin, curarea->winy - pix_top_margin); - st->pix_per_line= (float) ltexth/pix_available; + st->pix_per_line= (pix_available > 0)? (float) ltexth/pix_available: 0; if (st->pix_per_line<.1) st->pix_per_line=.1f; lhlstart = MIN2(txt_get_span(st->text->lines.first, st->text->curl), @@ -764,47 +764,53 @@ static void calc_text_rcts(SpaceText *st) lhlend = MAX2(txt_get_span(st->text->lines.first, st->text->curl), txt_get_span(st->text->lines.first, st->text->sell)); - hlstart = (lhlstart * pix_available) / ltexth; - hlend = (lhlend * pix_available) / ltexth; + if(ltexth > 0) { + hlstart = (lhlstart * pix_available)/ltexth; + hlend = (lhlend * pix_available)/ltexth; - /* the scrollbar is non-linear sized */ - if (pix_bardiff > 0) { - /* the start of the highlight is in the current viewport */ - if (lhlstart >= st->top && lhlstart <= st->top + st->viewlines) { - /* speed the progresion of the start of the highlight through the scrollbar */ - hlstart = ( ( (pix_available - pix_bardiff) * lhlstart) / ltexth) + (pix_bardiff * (lhlstart - st->top) / st->viewlines); - } - else if (lhlstart > st->top + st->viewlines && hlstart < barstart + barheight && hlstart > barstart) { - /* push hl start down */ - hlstart = barstart + barheight; - } - else if (lhlend > st->top && lhlstart < st->top && hlstart > barstart) { - /*fill out start */ - hlstart = barstart; - } + /* the scrollbar is non-linear sized */ + if (pix_bardiff > 0) { + /* the start of the highlight is in the current viewport */ + if (lhlstart >= st->top && lhlstart <= st->top + st->viewlines) { + /* speed the progresion of the start of the highlight through the scrollbar */ + hlstart = ( ( (pix_available - pix_bardiff) * lhlstart) / ltexth) + (pix_bardiff * (lhlstart - st->top) / st->viewlines); + } + else if (lhlstart > st->top + st->viewlines && hlstart < barstart + barheight && hlstart > barstart) { + /* push hl start down */ + hlstart = barstart + barheight; + } + else if (lhlend > st->top && lhlstart < st->top && hlstart > barstart) { + /*fill out start */ + hlstart = barstart; + } - if (hlend <= hlstart) { - hlend = hlstart + 2; - } + if (hlend <= hlstart) { + hlend = hlstart + 2; + } - /* the end of the highlight is in the current viewport */ - if (lhlend >= st->top && lhlend <= st->top + st->viewlines) { - /* speed the progresion of the end of the highlight through the scrollbar */ - hlend = (((pix_available - pix_bardiff )*lhlend)/ltexth) + (pix_bardiff * (lhlend - st->top)/st->viewlines); - } - else if (lhlend < st->top && hlend >= barstart - 2 && hlend < barstart + barheight) { - /* push hl end up */ - hlend = barstart; - } - else if (lhlend > st->top + st->viewlines && lhlstart < st->top + st->viewlines && hlend < barstart + barheight) { - /* fill out end */ - hlend = barstart + barheight; - } + /* the end of the highlight is in the current viewport */ + if (lhlend >= st->top && lhlend <= st->top + st->viewlines) { + /* speed the progresion of the end of the highlight through the scrollbar */ + hlend = (((pix_available - pix_bardiff )*lhlend)/ltexth) + (pix_bardiff * (lhlend - st->top)/st->viewlines); + } + else if (lhlend < st->top && hlend >= barstart - 2 && hlend < barstart + barheight) { + /* push hl end up */ + hlend = barstart; + } + else if (lhlend > st->top + st->viewlines && lhlstart < st->top + st->viewlines && hlend < barstart + barheight) { + /* fill out end */ + hlend = barstart + barheight; + } - if (hlend <= hlstart) { - hlstart = hlend - 2; + if (hlend <= hlstart) { + hlstart = hlend - 2; + } } - } + } + else { + hlstart = 0; + hlend = 0; + } if (hlend - hlstart < 2) { hlend = hlstart + 2; |