Skip to content

Commit

Permalink
In case of initialzoom set, set up drawpath first and then do the…
Browse files Browse the repository at this point in the history
… layout and render

This commit saves the extra layouting and rendering before the zoom.
  • Loading branch information
tobiolo committed Jan 17, 2024
1 parent 045caf2 commit e1f8368
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/document.h
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ struct Document {
return;
}

void Zoom(int dir, wxDC &dc, bool fromroot = false, bool selectionmaybedrawroot = true, bool needsrefresh = true) {
void Zoom(int dir, wxDC &dc, bool fromroot = false, bool selectionmaybedrawroot = true, bool onlysetupdrawpath = false) {
int len = max(0, (fromroot ? 0 : drawpath.size()) + dir);
if (!len && !drawpath.size()) return;
if (dir > 0) {
Expand All @@ -525,6 +525,7 @@ struct Document {
SetSelect(drawroot->parent->grid->FindCell(drawroot));
}
while (len < drawpath.size()) drawpath.remove(0);
if (onlysetupdrawpath) return;
Cell *drawroot = WalkPath(drawpath);
if (selected.GetCell() == drawroot && drawroot->grid) {
// We can't have the drawroot selected, so we must move the selection to the children.
Expand All @@ -533,7 +534,7 @@ struct Document {
drawroot->ResetLayout();
drawroot->ResetChildren();
Layout(dc);
DrawSelectMove(dc, selected, needsrefresh, false);
DrawSelectMove(dc, selected, true, false);
}

const wxChar *NoSel() { return _(L"This operation requires a selection."); }
Expand Down Expand Up @@ -634,6 +635,10 @@ struct Document {
dc.Clear();
if (!rootgrid) return;
sw->GetClientSize(&maxx, &maxy);
if (initialzoomlevel) {
Zoom(initialzoomlevel, dc, true, true, true);
initialzoomlevel = 0;
}
Layout(dc);
double xscale = maxx / (double)layoutxs;
double yscale = maxy / (double)layoutys;
Expand Down Expand Up @@ -667,12 +672,7 @@ struct Document {
sw->DoPrepareDC(dc);
ShiftToCenter(dc);
Render(dc);
if (initialzoomlevel) {
Zoom(initialzoomlevel, dc, false, true, false);
initialzoomlevel = 0;
} else {
DrawSelect(dc, selected);
}
DrawSelect(dc, selected);
if (scrolltoselection) {
ScrollIfSelectionOutOfView(dc, selected, false, false);
scrolltoselection = false;
Expand Down

0 comments on commit e1f8368

Please sign in to comment.