Commit fcd700a7 authored by Ivica Bukvic's avatar Ivica Bukvic
Browse files

fixed scrolling algorithm for scalars, improved scrolling logic to avoid...

fixed scrolling algorithm for scalars, improved scrolling logic to avoid unnecessary updates, made scrollbars wider (easier to click) and less transparent
parent f57ab697
......@@ -570,7 +570,7 @@ static void scalar_doredraw(t_gobj *client, t_glist *glist)
//fprintf(stderr,"yes\n");
sys_vgui("pdtk_select_all_gop_widgets .x%lx %lx %d\n", glist_getcanvas(glist), glist, 1);
}
sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", glist);
sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", glist_getcanvas(glist));
}
void scalar_redraw(t_scalar *x, t_glist *glist)
......
......@@ -1237,6 +1237,9 @@ void draw_doupdate(t_draw *x, t_canvas *c, t_symbol *s)
{
t_gobj *g;
t_template *template;
t_canvas *visible = c;
while(visible->gl_isgraph && visible->gl_owner)
visible = visible->gl_owner;
int isgroup = (x->x_drawtype == gensym("group"));
for (g = c->gl_list; g; g = g->g_next)
{
......@@ -1248,9 +1251,6 @@ void draw_doupdate(t_draw *x, t_canvas *c, t_symbol *s)
{
t_word *data = ((t_scalar *)g)->sc_vec;
char str[MAXPDSTRING];
t_canvas *visible = c;
while(visible->gl_isgraph && visible->gl_owner)
visible = visible->gl_owner;
if (s == gensym("fill"))
{
char *fill;
......@@ -1341,13 +1341,12 @@ void draw_doupdate(t_draw *x, t_canvas *c, t_symbol *s)
sys_vgui(".x%lx.c itemconfigure .draw%lx.%lx %s\n",
visible, x, data, str);
}
sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", visible);
}
if (g->g_pd == canvas_class) {
draw_doupdate(x, (t_glist *)g, s);
sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", (t_glist *)g);
}
}
sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", c);
}
extern t_canvas *canvas_list;
......@@ -1718,6 +1717,9 @@ void draw_doupdatetransform(t_draw *x, t_canvas *c)
draw_mset(mtx2, 0, 0, 0, 0, 0, 0);
t_gobj *g;
t_template *template;
t_canvas *visible = c;
while(visible->gl_isgraph && visible->gl_owner)
visible = visible->gl_owner;
/* we'll probably get a different bbox now, so we
will calculate a new one the next time we call
......@@ -1739,9 +1741,6 @@ void draw_doupdatetransform(t_draw *x, t_canvas *c)
t_float m1, m2, m3, m4, m5, m6;
draw_parsetransform(x, template, ((t_scalar *)g)->sc_vec,
&m1, &m2, &m3, &m4, &m5, &m6);
t_canvas *visible = c;
while(visible->gl_isgraph && visible->gl_owner)
visible = visible->gl_owner;
if (x->x_drawtype == gensym("group"))
sys_vgui(".x%lx.c itemconfigure .dgroup%lx -matrix "
"{ {%g %g} {%g %g} {%g %g} }\n",
......@@ -1759,13 +1758,12 @@ void draw_doupdatetransform(t_draw *x, t_canvas *c)
scalar_drawselectrect((t_scalar *)g, c, 0);
scalar_drawselectrect((t_scalar *)g, c, 1);
}
sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", visible);
}
if (g->g_pd == canvas_class) {
draw_doupdatetransform(x, (t_glist *)g);
sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", (t_glist *)g);
}
}
sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", c);
}
void draw_queueupdatetransform(t_gobj *g, t_glist *glist)
......
......@@ -3406,12 +3406,13 @@ proc pdtk_canvas_new {name width height geometry editable} {
set ::canvasheight($name) 0
}
set SCROLL_OPACITY 0.33
set HSCROLL_PAD_L 6
set HSCROLL_PAD_R 13
set VSCROLL_PAD_U 6
set VSCROLL_PAD_D 13
set SCROLL_PAD_EDGE 5
set SCROLL_THICKNESS 5
set SCROLL_THICKNESS 6
set scrollbar_color "#555"
proc pdtk_canvas_draw_scrollbars {name} {
......@@ -3423,6 +3424,7 @@ proc pdtk_canvas_draw_scrollbars {name} {
global VSCROLL_PAD_D
global SCROLL_PAD_EDGE
global SCROLL_THICKNESS
global SCROLL_OPACITY
set name [string trimright $name .c]
catch {
$name.c delete xscroll
......@@ -3440,7 +3442,7 @@ proc pdtk_canvas_draw_scrollbars {name} {
set scrolly1 [expr [$name.c canvasy 0] + [winfo height $name.c] - $SCROLL_PAD_EDGE]
set scrollx2 [expr $scrollx1 + $width]
#puts stderr "$vx1 $vx2 $npix $width $loffset $scrollx1 $scrollx2"
set hscroll [$name.c create polyline $scrollx1 $scrolly1 $scrollx2 $scrolly1 -stroke $scrollbar_color -strokewidth $SCROLL_THICKNESS -strokeopacity 0.25 -tags xscroll -strokelinecap round]
set hscroll [$name.c create polyline $scrollx1 $scrolly1 $scrollx2 $scrolly1 -stroke $scrollbar_color -strokewidth $SCROLL_THICKNESS -strokeopacity $SCROLL_OPACITY -tags xscroll -strokelinecap round]
$name.c addtag noscroll withtag xscroll
#$name.c bind $hscroll <Button-1> {pdtk_canvas_scroll_horizontal_click %W %x %y %b 0}
$name.c bind $hscroll <Enter> {pdtk_canvas_enter_scrollbar %W %x %y}
......@@ -3460,7 +3462,7 @@ proc pdtk_canvas_draw_scrollbars {name} {
set scrolly1 [expr [$name.c canvasy 0] + $VSCROLL_PAD_U +$toffset]
set scrolly2 [expr $scrolly1 + $height]
#puts stderr "$vy1 $vy2 $npix $height $toffset $scrolly1 $scrolly2"
set vscroll [$name.c create polyline $scrollx1 $scrolly1 $scrollx1 $scrolly2 -stroke $scrollbar_color -strokewidth $SCROLL_THICKNESS -strokeopacity 0.25 -tags yscroll -strokelinecap round]
set vscroll [$name.c create polyline $scrollx1 $scrolly1 $scrollx1 $scrolly2 -stroke $scrollbar_color -strokewidth $SCROLL_THICKNESS -strokeopacity $SCROLL_OPACITY -tags yscroll -strokelinecap round]
$name.c addtag noscroll withtag yscroll
#$name.c bind $vscroll <Button-1> {pdtk_canvas_scroll_vertical_click %W %x %y %b 0}
$name.c bind $vscroll <Enter> {pdtk_canvas_enter_scrollbar %W %x %y}
......@@ -4204,11 +4206,13 @@ proc pdtk_canvas_do_getscroll {name} {
global pdtk_canvas_mouseup_ymaxval
#global ::update_tick([winfo parent $name])
#puts stderr "pdtk_canvas_getscroll $name"
# kludge since this gets called sometimes after a canvas is destroyed
if {![winfo exists $name]} {return}
set parentname [winfo parent $name]
#puts stderr "pdtk_canvas_getscroll $name $::scroll($parentname)"
if {$::scroll($parentname) == 0} {return}
# for use with tick mechanism
#if {$::update_tick([winfo parent $name]) == 1} {return}
#after 100 set ::update_tick([winfo parent $name]) 0
......@@ -4303,8 +4307,6 @@ proc pdtk_canvas_do_getscroll {name} {
#puts stderr "$x1 $x2 $y1 $y2"
set parentname [winfo parent $name]
if {$x1 != 1.0e30} {
set xminval 0
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment