Skip to content

Fix excessive redraw from status bar#112

Open
dannye wants to merge 1 commit intoRangi42:masterfrom
dannye:fix-excessive-redraw
Open

Fix excessive redraw from status bar#112
dannye wants to merge 1 commit intoRangi42:masterfrom
dannye:fix-excessive-redraw

Conversation

@dannye
Copy link
Copy Markdown
Contributor

@dannye dannye commented Apr 27, 2026

Fixes #100

Comment thread src/event.cpp
Fl_Box(0, 0, 0, 0), _line(line), _meta(meta), _event_x(0), _event_y(0), _prelude(prelude), _macro(macro), _prefix(),
_suffix(), _tip(tip_), _warp_id(warp_id), _warp_to(NULL), _prefixed(false), _suffixed(false), _hex_coords(false) {
user_data(NULL);
box(OS_NO_BOX);
Copy link
Copy Markdown
Contributor Author

@dannye dannye Apr 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OS_NO_BOX is like FL_NO_BOX except redrawing it doesn't request that the parent window redraws the child region background.

OS_NO_BOX is intended for widgets that definitely draw their entire region, eg with an image, without the need for a box or frame or a background provided by the window.

Comment thread src/event.cpp
mw->update_status(this);
mw->update_gameboy_screen(this);
redraw();
mw->redraw_map();
Copy link
Copy Markdown
Contributor Author

@dannye dannye Apr 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The map needs to be redrawn when the mouse enters or leaves an Event, especially when the Event is outside the map.

Comment thread src/event.cpp
mw->redraw_map();
return 1;
case FL_MOVE:
mw->redraw_map();
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't think of any reason why the map would need to be redrawn for each mouse movement within an Event. If this needs to be added back, let me know.

Comment thread src/main-window.cpp
_hover_xy->box(OS_NO_BOX);
new Spacer(0, 0, 2, 21);
_hover_event = new Label(0, 0, text_width("Event: X/Y ($999, $999)", 8), 21, "");
_hover_event->box(OS_NO_BOX);
Copy link
Copy Markdown
Contributor Author

@dannye dannye Apr 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OS_NO_BOX is also used for the 5 Labels inside the _status_bar.

Even though the Labels don't "draw their entire region" like the image buttons, they need to use OS_NO_BOX because otherwise when their parent window is asked to redraw the child background region, that ends up triggering a redraw of other sibling widgets, like the main Workspace+OS_Scroll. This is specifically what was causing the laggy cursor reported in #100.

To avoid this, the Labels will never automatically ask their parent window to redraw their background, but then you must explicitly redraw the parent Toolbar any time a Label's label text is updated. (The Toolbar is now responsible for drawing the background, eg in the Brushed Metal theme.)

Comment thread src/main-window.cpp
event->redraw();
}
}
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the status bar was always causing constant redraws of the entire map, that hid an existing bug where Blocks are redrawn and then obscure the 0-4 events that overlap on top of that Block.

Now that the constant redrawing is no longer happening, when a Block is redrawn then we need to ensure any overlapping Events also get redrawn.

Comment thread src/widgets.cpp
Toolbar::Toolbar(int x, int y, int w, int h, const char *l) : Fl_Group(x, y, w, h, l), _spacer(0, 0, 0, 0) {
labeltype(FL_NO_LABEL);
box(OS_TOOLBAR_FRAME);
box(OS_TOOLBAR_BOX);
Copy link
Copy Markdown
Contributor Author

@dannye dannye Apr 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, now that the parent window will not be responsible for drawing the child background region for the status bar Labels, then the Toolbar must draw the background. So this had to be changed from simply a frame to a full box. (This is only super relevant for the Brushed Metal theme.)

Comment thread src/widgets.cpp
if (d & FL_DAMAGE_ALL) {
draw_box();
draw_label();
}
Copy link
Copy Markdown
Contributor Author

@dannye dannye Apr 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the Toolbar now has a full box and not just a frame, the box needs to be drawn before the children.

This is the most questionable change in this PR because d can be modified while drawing the children, but now the box is drawn earlier before d can be modified.

This seems OK to me, but let me know if it causes any issues.

I think it's OK because Polished Map doesn't really leverage the "dynamic" nature of auto-packing the widgets inside the Toolbar, except on first draw.

This "auto-packing" is actually annoying enough that I removed it completely in Crystal Tracker here, and now the Toolbar is a lot "dumber" and easier to work with. I'm curious if you really prefer to keep the auto-packing here or if you'd be OK with simplifying the Toolbar like I did.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cursor lags behind mouse since upgrade to FLTK 1.4.4

1 participant