Limit the brush size for preview to an odd-size to align the center correctly for big brushes

As now the BrushType button has an odd number width (15px), it's
better to limit the brush size to an odd number size (9px instead of
10px). In previous versions the BrushType button had an even number
width (16px) so the 10px brush size was correctly centered.
This commit is contained in:
David Capello 2023-02-27 11:58:52 -03:00
parent 672f371622
commit fa4f0d1fa9

View File

@ -460,12 +460,14 @@ void BrushPopup::onBrushChanges()
os::SurfaceRef BrushPopup::createSurfaceForBrush(const BrushRef& origBrush,
const bool useOriginalImage)
{
constexpr int kMaxSize = 9;
Image* image = nullptr;
BrushRef brush = origBrush;
if (brush) {
if (brush->type() != kImageBrushType && brush->size() > 10) {
if (brush->type() != kImageBrushType && brush->size() > kMaxSize) {
brush.reset(new Brush(*brush));
brush->setSize(10);
brush->setSize(kMaxSize);
}
// Show the original image in the popup (without the image colors
// modified if there were some modification).
@ -476,8 +478,8 @@ os::SurfaceRef BrushPopup::createSurfaceForBrush(const BrushRef& origBrush,
}
os::SurfaceRef surface = os::instance()->makeRgbaSurface(
std::min(10, image ? image->width(): 4),
std::min(10, image ? image->height(): 4));
std::min(kMaxSize, (image ? image->width(): 4)),
std::min(kMaxSize, (image ? image->height(): 4)));
if (image) {
Palette* palette = get_current_palette();