Page Menu
Home
Search
Configure Global Search
Log In
Files
F5341
Bug7140_scrollbar_3.patch
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
Jetze van Beijma (beardape)
Nov 13 2013, 1:22 PM
Size
4 KB
Subscribers
None
Bug7140_scrollbar_3.patch
View Options
Index: drawtext.c
===================================================================
--- drawtext.c (revision 12813)
+++ drawtext.c (working copy)
@@ -725,45 +725,85 @@
static void calc_text_rcts(SpaceText *st)
{
- short barheight, barstart;
- int lbarstart, lbarh, ltexth;
+ short barheight, barstart, hlstart, hlend, blank_lines;
+ int lhlstart, lhlend, ltexth;
+ short pix_available, pix_top_margin, pix_bottom_margin, pix_bardiff;
- lbarstart= st->top;
- lbarh= st->viewlines;
- ltexth= txt_get_span(st->text->lines.first, st->text->lines.last) + st->viewlines / 2 + 2;
-
- barheight= (lbarh*(curarea->winy-4))/ltexth;
- if (barheight<20) barheight=20;
+ pix_top_margin = 8;
+ pix_bottom_margin = 4;
+ pix_available = curarea->winy - pix_top_margin - pix_bottom_margin;
+ ltexth= txt_get_span(st->text->lines.first, st->text->lines.last);
+ blank_lines = st->viewlines / 2;
- barstart= (lbarstart*(curarea->winy-4))/ltexth + 8;
+ //when resizing a vieport with the bar at the bottom to a greater height more blank lines will be added
+ if(ltexth + blank_lines < st->top + st->viewlines)
+ blank_lines = st->top + st->viewlines - ltexth;
+
+ ltexth += blank_lines;
+ barheight = (st->viewlines*pix_available)/ltexth;
+ 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;
+
st->txtbar.xmin= 5;
st->txtbar.xmax= 17;
- st->txtbar.ymax= curarea->winy - barstart;
+ st->txtbar.ymax= curarea->winy - pix_top_margin - barstart;
st->txtbar.ymin= st->txtbar.ymax - barheight;
- CLAMP(st->txtbar.ymin, 2, curarea->winy-2);
- CLAMP(st->txtbar.ymax, 2, curarea->winy-2);
+ 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/curarea->winy;
+ st->pix_per_line= (float) ltexth/pix_available;
if (st->pix_per_line<.1) st->pix_per_line=.1f;
- lbarstart= MIN2(txt_get_span(st->text->lines.first, st->text->curl),
+ lhlstart = MIN2(txt_get_span(st->text->lines.first, st->text->curl),
txt_get_span(st->text->lines.first, st->text->sell));
- lbarh= abs(txt_get_span(st->text->lines.first, st->text->curl)-txt_get_span(st->text->lines.first, st->text->sell));
+ 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(pix_bardiff > 0){ //the scrollbar is non-linear sized
+ if(lhlstart >= st->top && lhlstart <= st->top + st->viewlines){ //the start of the highlight is in the current viewport
+ //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(lhlend >= st->top && lhlend <= st->top + st->viewlines){ //the end of the highlight is in the current viewport
+ //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 < 2)
+ hlend = hlstart + 2;
- barheight= (lbarh*(curarea->winy-4))/ltexth;
- if (barheight<2) barheight=2;
-
- barstart= (lbarstart*(curarea->winy-4))/ltexth + 8;
-
st->txtscroll.xmin= 5;
st->txtscroll.xmax= 17;
- st->txtscroll.ymax= curarea->winy-barstart;
- st->txtscroll.ymin= st->txtscroll.ymax - barheight;
+ st->txtscroll.ymax= curarea->winy - pix_top_margin - hlstart;
+ st->txtscroll.ymin= curarea->winy - pix_top_margin - hlend;
- CLAMP(st->txtscroll.ymin, 2, curarea->winy-2);
- CLAMP(st->txtscroll.ymax, 2, curarea->winy-2);
+ CLAMP(st->txtscroll.ymin, pix_bottom_margin, curarea->winy - pix_top_margin);
+ CLAMP(st->txtscroll.ymax, pix_bottom_margin, curarea->winy - pix_top_margin);
}
static void draw_textscroll(SpaceText *st)
File Metadata
Details
Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
1e/d7/0348c3ba1f406196eeb639563e00
Event Timeline
Log In to Comment