Changeset 659 for abuse/trunk/src/imlib/scroller.cpp
- Timestamp:
- May 15, 2011, 6:22:25 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
abuse/trunk/src/imlib/scroller.cpp
r655 r659 82 82 83 83 scroller::scroller(int X, int Y, int ID, int L, int H, int Vert, int Total_items, ifield *Next) 84 { x=X; y=Y; id=ID; next=Next; l=L; h=H; sx=0; t=Total_items; drag=-1; vert=Vert;84 { m_pos = vec2i(X, Y); id=ID; next=Next; l=L; h=H; sx=0; t=Total_items; drag=-1; vert=Vert; 85 85 } 86 86 … … 89 89 { 90 90 area_config(); 91 x1= x-1; y1=y-1;91 x1=m_pos.x-1; y1=m_pos.y-1; 92 92 if (vert) 93 { x2= x+l+bw(); y2=y+h; }93 { x2=m_pos.x+l+bw(); y2=m_pos.y+h; } 94 94 else 95 { x2= x+l; y2=y+h+bh(); }95 { x2=m_pos.x+l; y2=m_pos.y+h+bh(); } 96 96 } 97 97 … … 99 99 { 100 100 if (vert) 101 { x1= x+l; y1=y+bh(); x2=x+l+bw()-1; y2=y+h-bh()-1; }102 else { x1= x+bw(); y1=y+h; x2=x+l-bw(); y2=y+h+bh()-1; }101 { x1=m_pos.x+l; y1=m_pos.y+bh(); x2=m_pos.x+l+bw()-1; y2=m_pos.y+h-bh()-1; } 102 else { x1=m_pos.x+bw(); y1=m_pos.y+h; x2=m_pos.x+l-bw(); y2=m_pos.y+h+bh()-1; } 103 103 } 104 104 … … 146 146 if (vert) 147 147 { 148 x1= x+l+1;148 x1=m_pos.x+l+1; 149 149 if (t<2) 150 y1= y+bh()+1;150 y1=m_pos.y+bh()+1; 151 151 else 152 y1= y+bh()+1+sx*(sy2-sy1+1-bh())/(t-1);152 y1=m_pos.y+bh()+1+sx*(sy2-sy1+1-bh())/(t-1); 153 153 } else 154 154 { 155 if (t<2) x1= x+bw()+1;156 else x1= x+bw()+1+sx*(sx2-sx1+1-bw())/(t-1);157 y1= y+h+1;155 if (t<2) x1=m_pos.x+bw()+1; 156 else x1=m_pos.x+bw()+1+sx*(sx2-sx1+1-bw())/(t-1); 157 y1=m_pos.y+h+1; 158 158 } 159 159 x2=x1+bw()-3; … … 259 259 int x1,y1,x2,y2; 260 260 wig_area(x1,y1,x2,y2); 261 if (mx>= x && mx<=x+l-1 && my>=y && my<=y+h-1)261 if (mx>=m_pos.x && mx<=m_pos.x+l-1 && my>=m_pos.y && my<=m_pos.y+h-1) 262 262 handle_inside_event(ev,screen,inm); 263 263 } … … 351 351 int h=(y2-y1+1-bh()); 352 352 if (h) 353 return (my- y-bh()-bh()/2)*(t-1)/h;353 return (my-m_pos.y-bh()-bh()/2)*(t-1)/h; 354 354 else return 0; 355 355 } … … 358 358 int w=(x2-x1+1-bw()); 359 359 if (w) 360 return (mx- x-bw()-bw()/2)*(t-1)/w;360 return (mx-m_pos.x-bw()-bw()/2)*(t-1)/w; 361 361 else return 0; 362 362 } … … 366 366 void scroller::scroll_event(int newx, image *screen) 367 367 { 368 screen->Bar( vec2i(x, y), vec2i(x + l - 1, y +h - 1), wm->black());368 screen->Bar(m_pos, m_pos + vec2i(l - 1, h - 1), wm->black()); 369 369 int xa,ya,xo=0,yo; 370 if (vert) { xa=0; ya=30; yo= x+5; yo=y+5; } else { xa=30; ya=0; xo=x+5; yo=y+5; }370 if (vert) { xa=0; ya=30; yo=m_pos.x+5; yo=m_pos.y+5; } else { xa=30; ya=0; xo=m_pos.x+5; yo=m_pos.y+5; } 371 371 for (int i=newx,c=0; c<30 && i<100; i++,c++) 372 372 { … … 419 419 if (ev.type==EV_MOUSE_MOVE && activate_on_mouse_move()) 420 420 { 421 int sel=last_sel+(ev.mouse_move.y- y)/(wm->font()->height()+1);421 int sel=last_sel+(ev.mouse_move.y-m_pos.y)/(wm->font()->height()+1); 422 422 if (sel!=cur_sel && sel<t && sel>=0) 423 423 { … … 428 428 else if (ev.type==EV_MOUSE_BUTTON) 429 429 { 430 int sel=last_sel+(ev.mouse_move.y- y)/(wm->font()->height()+1);430 int sel=last_sel+(ev.mouse_move.y-m_pos.y)/(wm->font()->height()+1); 431 431 if (sel<t && sel>=0) 432 432 { … … 496 496 int cx1, cy1, cx2, cy2; 497 497 screen->GetClip(cx1, cy1, cx2, cy2); 498 screen->SetClip( x,y,x+l,y+h);498 screen->SetClip(m_pos.x,m_pos.y,m_pos.x+l,m_pos.y+h); 499 499 int tw=(l+tex->Size().x-1)/tex->Size().x; 500 500 int th=(h+tex->Size().y-1)/tex->Size().y; 501 int dy= y;501 int dy=m_pos.y; 502 502 for (int j=0; j<th; j++,dy+=tex->Size().y) 503 for (int i=0,dx= x; i<tw; i++,dx+=tex->Size().x)503 for (int i=0,dx=m_pos.x; i<tw; i++,dx+=tex->Size().x) 504 504 screen->PutImage(tex, vec2i(dx, dy)); 505 505 506 506 screen->SetClip(cx1, cy1, cx2, cy2); 507 } else screen->Bar( vec2i(x, y), vec2i(x + l - 1, y +h - 1), wm->black());508 509 int dy= y;507 } else screen->Bar(m_pos, m_pos + vec2i(l - 1, h - 1), wm->black()); 508 509 int dy=m_pos.y; 510 510 for (int i=0; i<th; i++,dy+=wm->font()->height()+1) 511 511 { 512 512 if (i+newx==cur_sel) 513 screen->Bar(vec2i( x, dy), vec2i(x + wid * wm->font()->width() - 1,513 screen->Bar(vec2i(m_pos.x, dy), vec2i(m_pos.x + wid * wm->font()->width() - 1, 514 514 dy + wm->font()->height()), 515 515 wm->dark_color()); 516 516 if (i+newx<t) 517 wm->font()->put_string(screen, x,dy,lis[i+newx].name,wm->bright_color());517 wm->font()->put_string(screen,m_pos.x,dy,lis[i+newx].name,wm->bright_color()); 518 518 } 519 519 } … … 581 581 void spicker::draw_background(image *screen) 582 582 { 583 screen->Bar( vec2i(x, y), vec2i(x + l - 1, y +h - 1), wm->dark_color());583 screen->Bar(m_pos, m_pos + vec2i(l - 1, h - 1), wm->dark_color()); 584 584 } 585 585 … … 611 611 last_sel=newx; 612 612 int xa,ya,xo,yo; 613 xo= x+2;614 yo= y+2;613 xo=m_pos.x+2; 614 yo=m_pos.y+2; 615 615 if (vert) { xa=0; ya=item_height(); } 616 616 else { xa=item_width(); ya=0; } … … 641 641 int me; 642 642 if (vert) 643 me=last_sel+(ev.mouse_move.y- y)/item_height();643 me=last_sel+(ev.mouse_move.y-m_pos.y)/item_height(); 644 644 else 645 me=last_sel+(ev.mouse_move.x- x)/item_width();645 me=last_sel+(ev.mouse_move.x-m_pos.x)/item_width(); 646 646 if (me<t && me>=0) 647 647 { … … 659 659 int me; 660 660 if (vert) 661 me=last_sel+(ev.mouse_move.y- y)/item_height();661 me=last_sel+(ev.mouse_move.y-m_pos.y)/item_height(); 662 662 else 663 me=last_sel+(ev.mouse_move.x- x)/item_width();663 me=last_sel+(ev.mouse_move.x-m_pos.x)/item_width(); 664 664 if (me<t && me>=0) 665 665 {
Note: See TracChangeset
for help on using the changeset viewer.