Skip to content

Commit

Permalink
Fixed LogicUICanvas background
Browse files Browse the repository at this point in the history
  • Loading branch information
Haspamelodica committed Dec 16, 2024
1 parent c818101 commit 5e93fc1
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ public LogicUICanvas(Composite parent, int style, LogicModel model, RenderPrefer
setBackground(background);

LogicUIRenderer renderer = new LogicUIRenderer(model);
addZoomedRenderer(gc ->
{
// No idea why, but the background color sometimes is reset; at least one time once the constructor is done.
// So, we just set it again each time we want to render.
// To avoid infinite redraw loops, only set background if actually necessary.
// Also, this enables changing background color when preferences change while a LogicUICanvas is already existing
Color newBackground = renderPrefs.getColor(BACKGROUND_COLOR);
if (newBackground != null)
if (!getBackground().equals(newBackground))
setBackground(newBackground);
});
addZoomedRenderer(gc -> renderer.render(gc, renderPrefs, new Rectangle(-offX / zoom, -offY / zoom, gW / zoom, gH / zoom)));
model.setRedrawHandler(() ->
{
Expand Down

0 comments on commit 5e93fc1

Please sign in to comment.