Skip to content

Commit

Permalink
BrushEditor: size preview based on max dimension to avoid jumping
Browse files Browse the repository at this point in the history
  • Loading branch information
dsizzle committed Oct 29, 2023
1 parent addb47e commit 773b224
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions artpaint/tools/Brush.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,13 +382,20 @@ Brush::PreviewBrush(BBitmap* preview_bitmap)
float preview_width = width_;
float preview_height = height_;

float bmap_width = preview_bitmap->Bounds().Width() + 1;
float bmap_height = preview_bitmap->Bounds().Height() + 1;
float max_dim = max_c(actual_width, actual_height);

while ((preview_width > bmap_width) || (preview_height > bmap_height)) {
preview_width /= 2.0;
preview_height /= 2.0;
float bmap_width = (preview_bitmap->Bounds().Width() + 1);
float bmap_height = (preview_bitmap->Bounds().Height() + 1);
int32 fac = 1;

while ((max_dim > bmap_width) || (max_dim > bmap_height)) {
fac *= 2;
max_dim /= 2;;
}

preview_width /= fac;
preview_height /= fac;

int32 scale = (int32)(width_ / preview_width);

int32 top = (int32)((bmap_height - preview_height) / 2.0);
Expand Down

0 comments on commit 773b224

Please sign in to comment.