FLTK logo

[fltk.coredev] Re: Fl_Scroll x/yposition and scroll_to confusion

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.coredev  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: Fl_Scroll x/yposition and scroll_to confusion Mo_Al_ Jan 26, 2023  
  Sorry for posting this here, I meant to post it in fltk-general

On Thursday, January 26, 2023 at 11:51:23 AM UTC+3 Mo_Al_ wrote:
Hello

It seems Fl_Scroll takes into account the position of the topmost leftmost widget among its children, where the docs state:
```
Fl_Scroll scroll (10,10,200,200);
Fl_Box b1 ( 10, 10,50,50,"b1"); // relative (x,y) = (0,0)
Fl_Box b2 ( 60, 60,50,50,"b2"); // relative (x,y) = (50,50)
Fl_Box b3 ( 60,110,50,50,"b3"); // relative (x,y) = (50,100)
```

a modified example from the docs:
```
#include <FL/Fl.H>
#include <FL/Fl_Scroll.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Window.H>

void btn_cb(Fl_Widget *w, void *data) {
auto s = (Fl_Scroll*)data;
s->scroll_to(0, 0);
}

int main() {
Fl_Window win(400, 300);
Fl_Scroll s(0, 0, 400, 300);
Fl_Button b1(10, 10, 30, 30, "B1");
Fl_Button b2(60, 60, 30, 30, "B2");
Fl_Button b3(60, 110, 30, 30, "B3");
s.end();
win.end();
win.show();
b3.callback(btn_cb, &s);
return Fl::run();
}
```

This makes the relative position of b1 (following the docs) be (10, 10), but using s.scroll_to(0, 0), actually appears to scroll to 10, 10, making the the first button appear at position 0, 0 of the window. To get the initial appearance, one would need to s.scroll_to(-10, -10).
I could be misunderstanding the docs, or is the position of the topleft-most widget the reference for the Fl_Scroll?


--
You received this message because you are subscribed to the Google Groups "fltk.coredev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkcoredev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkcoredev/c409619b-2ecd-46ab-9335-3cbbac543446n%40googlegroups.com.
Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.