1

Because I'm unsatisfied with the styling of fltk's built in Scroll group, I would like to create my own scroll group component , with similar functionality. Reading over the source code for FL_Scroll, I gather that the process of "masking out" unneeded parts of the scroll groups children involves using fltk's damage functionality. I'm finding widget damage a difficult concept to understand. It seems like it relates to the way widgets are drawn, but I don't understand how it can be used to selectively draw parts of a widget.

Based on the fltk-rs docs for WidgetExt::set_damage() and WidgetExt::damage(), it seems like damaged is some kind of on/off state, like set_resizeable().

Yet in the FLTK docs I see this definition:

When redrawing your widgets you should look at the damage bits to see what parts of your widget need redrawing. 
The handle() method can then set individual damage bits to limit the amount of drawing that needs to be done:
MyClass::handle(int event) {
    ...
    if (change_to_part1) damage(1);
    if (change_to_part2) damage(2);
    if (change_to_part3) damage(4);
  }
  
  MyClass::draw() {
    if (damage() & fltk::DAMAGE_ALL) {
      ... draw frame/box and other static stuff ...
    }
    if (damage() & (fltk::DAMAGE_ALL | 1)) draw_part1();
    if (damage() & (fltk::DAMAGE_ALL | 2)) draw_part2();
    if (damage() & (fltk::DAMAGE_ALL | 4)) draw_part3();
  }

This description makes it seem like widget damage is referring to some kind of array of byte data about the widgets. I'm guessing for the scroll group, you just want to draw the byte data within the scroll group's area. But where is this byte data stored? How can one access it? What does damage have to do with this data?

ANimator120
  • 2,556
  • 1
  • 20
  • 52

0 Answers0