diff --git a/laf b/laf index 4f0acaa1f..58941d538 160000 --- a/laf +++ b/laf @@ -1 +1 @@ -Subproject commit 4f0acaa1ffb456b335201ca457b09f3cb99369cc +Subproject commit 58941d53846be4e1a90eda6e2293ad3559d419a1 diff --git a/src/app/cli/cli_processor.cpp b/src/app/cli/cli_processor.cpp index 90c49dd10..b7325eb83 100644 --- a/src/app/cli/cli_processor.cpp +++ b/src/app/cli/cli_processor.cpp @@ -35,6 +35,7 @@ #include "doc/tags.h" #include "render/dithering_algorithm.h" +#include #include #include @@ -518,7 +519,7 @@ int CliProcessor::process(Context* ctx) scaleWidth = (doc->width() > maxWidth ? maxWidth / doc->width() : 1.0); scaleHeight = (doc->height() > maxHeight ? maxHeight / doc->height() : 1.0); if (scaleWidth < 1.0 || scaleHeight < 1.0) { - scale = MIN(scaleWidth, scaleHeight); + scale = std::min(scaleWidth, scaleHeight); Params params; params.set("scale", base::convert_to(scale).c_str()); ctx->executeCommand(Commands::instance()->byId(CommandId::SpriteSize()), diff --git a/src/app/cmd/set_palette.cpp b/src/app/cmd/set_palette.cpp index bca10e9c2..aa8b1be10 100644 --- a/src/app/cmd/set_palette.cpp +++ b/src/app/cmd/set_palette.cpp @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2019 Igara Studio S.A. +// Copyright (C) 2019-2020 Igara Studio S.A. // Copyright (C) 2001-2015 David Capello // // This program is distributed under the terms of @@ -37,11 +37,11 @@ SetPalette::SetPalette(Sprite* sprite, frame_t frame, const Palette* newPalette) ASSERT(diffs > 0); if (m_from >= 0 && m_to >= m_from) { - int oldColors = MIN(m_to+1, m_oldNColors)-m_from; + int oldColors = std::min(m_to+1, m_oldNColors)-m_from; if (oldColors > 0) m_oldColors.resize(oldColors); - int newColors = MIN(m_to+1, m_newNColors)-m_from; + int newColors = std::min(m_to+1, m_newNColors)-m_from; if (newColors > 0) m_newColors.resize(newColors); diff --git a/src/app/commands/cmd_keyboard_shortcuts.cpp b/src/app/commands/cmd_keyboard_shortcuts.cpp index df570ab2f..81cdf4e89 100644 --- a/src/app/commands/cmd_keyboard_shortcuts.cpp +++ b/src/app/commands/cmd_keyboard_shortcuts.cpp @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2018-2019 Igara Studio S.A. +// Copyright (C) 2018-2020 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This program is distributed under the terms of @@ -45,6 +45,7 @@ #include "keyboard_shortcuts.xml.h" +#include #include #include @@ -260,7 +261,7 @@ private: m_headerItem->contextXPos() + Graphics::measureUITextLength( convertKeyContextToUserFriendlyString(m_key->keycontext()), font()); - size.w = MAX(size.w, w); + size.w = std::max(size.w, w); } if (m_key && !m_key->accels().empty()) { diff --git a/src/app/commands/cmd_new_layer.cpp b/src/app/commands/cmd_new_layer.cpp index 54c56514e..43186dc8e 100644 --- a/src/app/commands/cmd_new_layer.cpp +++ b/src/app/commands/cmd_new_layer.cpp @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2019 Igara Studio S.A. +// Copyright (C) 2019-2020 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This program is distributed under the terms of @@ -41,8 +41,10 @@ #include "new_layer.xml.h" -#include +#include #include +#include +#include namespace app { @@ -419,8 +421,8 @@ std::string NewLayerCommand::onGetFriendlyName() const void NewLayerCommand::adjustRefCelBounds(Cel* cel, gfx::RectF bounds) { Sprite* sprite = cel->sprite(); - double scale = MIN(double(sprite->width()) / bounds.w, - double(sprite->height()) / bounds.h); + double scale = std::min(double(sprite->width()) / bounds.w, + double(sprite->height()) / bounds.h); bounds.w *= scale; bounds.h *= scale; bounds.x = sprite->width()/2 - bounds.w/2; @@ -447,7 +449,7 @@ int NewLayerCommand::getMaxLayerNum(const Layer* layer) const if (layer->isGroup()) { for (const Layer* child : static_cast(layer)->layers()) { int tmp = getMaxLayerNum(child); - max = MAX(tmp, max); + max = std::max(tmp, max); } } diff --git a/src/app/commands/cmd_sprite_size.cpp b/src/app/commands/cmd_sprite_size.cpp index c3b07e0c5..07cd59c1b 100644 --- a/src/app/commands/cmd_sprite_size.cpp +++ b/src/app/commands/cmd_sprite_size.cpp @@ -36,6 +36,8 @@ #include "sprite_size.xml.h" +#include + #define PERC_FORMAT "%.4g" namespace app { @@ -130,7 +132,9 @@ protected: new_mask->replace( gfx::Rect( scale_x(document()->mask()->bounds().x-1), - scale_y(document()->mask()->bounds().y-1), MAX(1, w), MAX(1, h))); + scale_y(document()->mask()->bounds().y-1), + std::max(1, w), + std::max(1, h))); // Always use the nearest-neighbor method to resize the bitmap // mask. diff --git a/src/app/file/file.cpp b/src/app/file/file.cpp index e400752d4..f43cb51a1 100644 --- a/src/app/file/file.cpp +++ b/src/app/file/file.cpp @@ -168,8 +168,8 @@ FileOpROI::FileOpROI(const Doc* doc, m_selFrames.displace(m_tag->fromFrame()); m_selFrames = - m_selFrames.filter(MAX(0, m_tag->fromFrame()), - MIN(m_tag->toFrame(), doc->sprite()->lastFrame())); + m_selFrames.filter(std::max(0, m_tag->fromFrame()), + std::min(m_tag->toFrame(), doc->sprite()->lastFrame())); } // All frames if selected frames is empty else if (m_selFrames.empty()) diff --git a/src/app/file/fli_format.cpp b/src/app/file/fli_format.cpp index 3f0310ef8..3b2c823ab 100644 --- a/src/app/file/fli_format.cpp +++ b/src/app/file/fli_format.cpp @@ -20,6 +20,7 @@ #include "flic/flic.h" #include "render/render.h" +#include #include namespace app { @@ -239,7 +240,7 @@ bool FliFormat::onSave(FileOp* fop) frame_t frame = *frame_it; const Palette* pal = sprite->palette(frame); - int size = MIN(256, pal->size()); + int size = std::min(256, pal->size()); for (int c=0; cgetEntry(c); @@ -255,7 +256,7 @@ bool FliFormat::onSave(FileOp* fop) // time that it has in the sprite if (f < nframes) { int times = sprite->frameDuration(frame) / header.speed; - times = MAX(1, times); + times = std::max(1, times); for (int c=0; c + #include #ifdef _WIN32 @@ -52,7 +54,7 @@ #define GIF_TRACE(...) // GifBitSize can return 9 (it's a bug in giflib) -#define GifBitSizeLimited(v) (MIN(GifBitSize(v), 8)) +#define GifBitSizeLimited(v) (std::min(GifBitSize(v), 8)) namespace app { @@ -539,7 +541,7 @@ private: palette.reset(new Palette(*m_sprite->palette(m_frameNum-1))); palette->setFrame(m_frameNum); } - resetRemap(MAX(ncolors, palette->size())); + resetRemap(std::max(ncolors, palette->size())); // Number of colors in the colormap that are part of the current // sprite palette. @@ -588,7 +590,7 @@ private: Palette oldPalette(*palette); palette->resize(base + missing + (needsExtraBgColor ? 1: 0)); - resetRemap(MAX(ncolors, palette->size())); + resetRemap(std::max(ncolors, palette->size())); for (int i=0; ipalette(MAX(0, m_frameNum-1)), + m_sprite->palette(std::max(0, m_frameNum-1)), m_opaque, m_bgIndex)); @@ -906,7 +908,7 @@ public: if (m_sprite->pixelFormat() == IMAGE_INDEXED) { for (Palette* palette : m_sprite->getPalettes()) { int bpp = GifBitSizeLimited(palette->size()); - m_bitsPerPixel = MAX(m_bitsPerPixel, bpp); + m_bitsPerPixel = std::max(m_bitsPerPixel, bpp); } } else { @@ -1092,9 +1094,9 @@ private: // 1/4 of its duration for some strange reason in the Twitter // conversion from GIF to video. if (fixDuration) - frameDelay = MAX(2, frameDelay/4); + frameDelay = std::max(2, frameDelay/4); if (fix_last_frame_duration) - frameDelay = MAX(2, frameDelay); + frameDelay = std::max(2, frameDelay); extension_bytes[0] = (((int(disposalMethod) & 7) << 2) | (transparentIndex >= 0 ? 1: 0)); diff --git a/src/app/modules/gfx.cpp b/src/app/modules/gfx.cpp index 750fe1022..50d346bbb 100644 --- a/src/app/modules/gfx.cpp +++ b/src/app/modules/gfx.cpp @@ -30,6 +30,8 @@ #include "ui/system.h" #include "ui/theme.h" +#include + namespace app { using namespace app::skin; @@ -183,7 +185,7 @@ void draw_alpha_slider(ui::Graphics* g, const gfx::Rect& rc, const app::Color& color) { - const int xmax = MAX(1, rc.w-1); + const int xmax = std::max(1, rc.w-1); const doc::color_t c = (color.getType() != app::Color::MaskType ? doc::rgba(color.getRed(), @@ -210,7 +212,7 @@ void draw_alpha_slider(os::Surface* s, const gfx::Rect& rc, const app::Color& color) { - const int xmax = MAX(1, rc.w-1); + const int xmax = std::max(1, rc.w-1); const doc::color_t c = (color.getType() != app::Color::MaskType ? doc::rgba(color.getRed(), diff --git a/src/app/thumbnail_generator.cpp b/src/app/thumbnail_generator.cpp index ab6007c52..c0c1572d4 100644 --- a/src/app/thumbnail_generator.cpp +++ b/src/app/thumbnail_generator.cpp @@ -30,6 +30,7 @@ #include "render/projection.h" #include "render/render.h" +#include #include #include @@ -119,9 +120,9 @@ private: const int h = sprite->height()*sprite->pixelRatio().h; // Calculate the thumbnail size - int thumb_w = MAX_THUMBNAIL_SIZE * w / MAX(w, h); - int thumb_h = MAX_THUMBNAIL_SIZE * h / MAX(w, h); - if (MAX(thumb_w, thumb_h) > MAX(w, h)) { + int thumb_w = MAX_THUMBNAIL_SIZE * w / std::max(w, h); + int thumb_h = MAX_THUMBNAIL_SIZE * h / std::max(w, h); + if (std::max(thumb_w, thumb_h) > std::max(w, h)) { thumb_w = w; thumb_h = h; } diff --git a/src/app/tools/controllers.h b/src/app/tools/controllers.h index c5b8cda42..7da6d7971 100644 --- a/src/app/tools/controllers.h +++ b/src/app/tools/controllers.h @@ -9,6 +9,7 @@ #include "base/gcd.h" #include "base/pi.h" +#include #include namespace app { @@ -154,8 +155,8 @@ public: if ((int(loop->getModifiers()) & int(ToolLoopModifiers::kSquareAspect))) { int dx = stroke[1].x - m_first.x; int dy = stroke[1].y - m_first.y; - int minsize = MIN(ABS(dx), ABS(dy)); - int maxsize = MAX(ABS(dx), ABS(dy)); + int minsize = std::min(ABS(dx), ABS(dy)); + int maxsize = std::max(ABS(dx), ABS(dy)); // Lines if (loop->getIntertwine()->snapByAngle()) { diff --git a/src/app/ui/button_set.cpp b/src/app/ui/button_set.cpp index 826adf18d..3a8531963 100644 --- a/src/app/ui/button_set.cpp +++ b/src/app/ui/button_set.cpp @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2018-2019 Igara Studio S.A. +// Copyright (C) 2018-2020 Igara Studio S.A. // Copyright (C) 2001-2017 David Capello // // This program is distributed under the terms of @@ -26,6 +26,7 @@ #include "ui/theme.h" #include "ui/widget.h" +#include #include namespace app { @@ -264,8 +265,8 @@ void ButtonSet::Item::onSizeHint(ui::SizeHintEvent& ev) gfx::Size iconSize; if (m_icon) { iconSize = m_icon->size(); - iconSize.w = MAX(iconSize.w, 16*guiscale()); - iconSize.h = MAX(iconSize.h, 16*guiscale()); + iconSize.w = std::max(iconSize.w, 16*guiscale()); + iconSize.h = std::max(iconSize.h, 16*guiscale()); } gfx::Rect boxRc; diff --git a/src/app/ui/color_button.cpp b/src/app/ui/color_button.cpp index 76cf18512..3692c3bc1 100644 --- a/src/app/ui/color_button.cpp +++ b/src/app/ui/color_button.cpp @@ -29,6 +29,8 @@ #include "gfx/rect_io.h" #include "ui/ui.h" +#include + namespace app { using namespace app::skin; @@ -306,9 +308,9 @@ void ColorButton::openPopup(const bool forcePinned) m_window->sizeHint()); winBounds.x = base::clamp(bounds().x, 0, ui::display_w()-winBounds.w); if (bounds().y2() <= ui::display_h()-winBounds.h) - winBounds.y = MAX(0, bounds().y2()); + winBounds.y = std::max(0, bounds().y2()); else - winBounds.y = MAX(0, bounds().y-winBounds.h); + winBounds.y = std::max(0, bounds().y-winBounds.h); } else if (forcePinned) { winBounds = m_hiddenPopupBounds; diff --git a/src/app/ui/color_selector.cpp b/src/app/ui/color_selector.cpp index 21b550a60..90eb7d2ae 100644 --- a/src/app/ui/color_selector.cpp +++ b/src/app/ui/color_selector.cpp @@ -33,6 +33,7 @@ #include "ui/size_hint_event.h" #include "ui/system.h" +#include #include #include #include @@ -261,7 +262,7 @@ app::Color ColorSelector::getColorByPosition(const gfx::Point& pos) return app::Color::fromMask(); const int u = pos.x - rc.x; - const int umax = MAX(1, rc.w-1); + const int umax = std::max(1, rc.w-1); const gfx::Rect bottomBarBounds = this->bottomBarBounds(); if (( hasCapture() && m_capturedInBottom) || @@ -274,7 +275,7 @@ app::Color ColorSelector::getColorByPosition(const gfx::Point& pos) return getAlphaBarColor(u, umax); const int v = pos.y - rc.y; - const int vmax = MAX(1, rc.h-bottomBarBounds.h-alphaBarBounds.h-1); + const int vmax = std::max(1, rc.h-bottomBarBounds.h-alphaBarBounds.h-1); return getMainAreaColor(u, umax, v, vmax); } diff --git a/src/app/ui/color_sliders.cpp b/src/app/ui/color_sliders.cpp index 5daefa62d..d3c3e1afe 100644 --- a/src/app/ui/color_sliders.cpp +++ b/src/app/ui/color_sliders.cpp @@ -29,6 +29,7 @@ #include "ui/slider.h" #include "ui/theme.h" +#include #include namespace app { @@ -62,7 +63,7 @@ namespace { auto convertColor = convert_from_current_to_screen_color_space(); gfx::Color color = gfx::ColorNone; - int w = MAX(rc.w-1, 1); + int w = std::max(rc.w-1, 1); for (int x=0; x <= w; ++x) { switch (m_channel) { diff --git a/src/app/ui/color_spectrum.cpp b/src/app/ui/color_spectrum.cpp index 2f36dda59..79fe0a615 100644 --- a/src/app/ui/color_spectrum.cpp +++ b/src/app/ui/color_spectrum.cpp @@ -23,6 +23,8 @@ #include "ui/size_hint_event.h" #include "ui/system.h" +#include + namespace app { using namespace app::skin; @@ -88,8 +90,8 @@ void ColorSpectrum::onPaintSurfaceInBgThread( { if (m_paintFlags & MainAreaFlag) { double sat = m_color.getHslSaturation(); - int umax = MAX(1, main.w-1); - int vmax = MAX(1, main.h-1); + int umax = std::max(1, main.w-1); + int vmax = std::max(1, main.h-1); for (int y=0; y + namespace app { using namespace app::skin; @@ -78,8 +80,8 @@ void ColorTintShadeTone::onPaintSurfaceInBgThread( bool& stop) { double hue = m_color.getHsvHue(); - int umax = MAX(1, main.w-1); - int vmax = MAX(1, main.h-1); + int umax = std::max(1, main.w-1); + int vmax = std::max(1, main.h-1); if (m_paintFlags & MainAreaFlag) { for (int y=0; y 0) { const gfx::Point pos(_u, _v); int n = getHarmonies(); - int boxsize = MIN(umax/10, vmax/10); + int boxsize = std::min(umax/10, vmax/10); for (int i=0; i + namespace app { using namespace ui; @@ -122,7 +124,7 @@ private: void onSizeHint(SizeHintEvent& ev) override { gfx::Size sz = textSize(); - sz.w = MAX(sz.w, preview()->width()) + 4*guiscale(); + sz.w = std::max(sz.w, preview()->width()) + 4*guiscale(); sz.h += 6*guiscale() + preview()->height(); ev.setSizeHint(sz); diff --git a/src/app/ui/editor/moving_cel_state.cpp b/src/app/ui/editor/moving_cel_state.cpp index 86506718b..b4e628785 100644 --- a/src/app/ui/editor/moving_cel_state.cpp +++ b/src/app/ui/editor/moving_cel_state.cpp @@ -30,6 +30,7 @@ #include "doc/sprite.h" #include "ui/message.h" +#include #include namespace app { @@ -234,7 +235,7 @@ bool MovingCelState::onMouseMove(Editor* editor, MouseMessage* msg) if (int(editor->getCustomizationDelegate() ->getPressedKeyAction(KeyContext::ScalingSelection) & KeyAction::MaintainAspectRatio)) { - m_celScale.w = m_celScale.h = MAX(m_celScale.w, m_celScale.h); + m_celScale.w = m_celScale.h = std::max(m_celScale.w, m_celScale.h); } m_scaled = true; diff --git a/src/app/ui/file_list.cpp b/src/app/ui/file_list.cpp index 7649e9009..6c33a2488 100644 --- a/src/app/ui/file_list.cpp +++ b/src/app/ui/file_list.cpp @@ -343,7 +343,7 @@ bool FileList::onProcessMessage(Message* msg) FileItemList::iterator link = m_list.begin() + ((select >= 0) ? select: 0); - for (i=MAX(select, 0); idisplayName(), m_isearch, chrs) == 0) { select = i; diff --git a/src/app/ui/font_popup.cpp b/src/app/ui/font_popup.cpp index 67047668c..ae59804fb 100644 --- a/src/app/ui/font_popup.cpp +++ b/src/app/ui/font_popup.cpp @@ -1,4 +1,5 @@ // Aseprite +// Copyright (C) 2020 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This program is distributed under the terms of @@ -39,10 +40,12 @@ #include "font_popup.xml.h" #ifdef _WIN32 -#include -#include + #include + #include + #undef max #endif +#include #include namespace app { @@ -87,7 +90,7 @@ private: gfx::Size sz = ev.sizeHint(); ev.setSizeHint( sz.w + 4 + m_image->width(), - MAX(sz.h, m_image->height())); + std::max(sz.h, m_image->height())); } } diff --git a/src/app/ui/palette_view.cpp b/src/app/ui/palette_view.cpp index fbe73e660..bdec55a9d 100644 --- a/src/app/ui/palette_view.cpp +++ b/src/app/ui/palette_view.cpp @@ -238,7 +238,7 @@ void PaletteView::clearSelection() Palette palette(*currentPalette()); Palette newPalette(palette); - newPalette.resize(MAX(1, newPalette.size() - m_selectedEntries.picks())); + newPalette.resize(std::max(1, newPalette.size() - m_selectedEntries.picks())); Remap remap = create_remap_to_move_picks(m_selectedEntries, palette.size()); for (int i=0; ichildSpacing()) / (boxSizePx() +this->childSpacing()); - setColumns(MAX(1, columns)); + setColumns(std::max(1, columns)); } m_isUpdatingColumns = false; } @@ -915,7 +915,7 @@ void PaletteView::setStatusBar() m_hot.part == Hit::OUTLINE || m_hot.part == Hit::POSSIBLE_COLOR) && (m_hot.color < currentPalette()->size())) { - int i = MAX(0, m_hot.color); + int i = std::max(0, m_hot.color); statusBar->showColor( 0, "", app::Color::fromIndex(i)); @@ -928,11 +928,11 @@ void PaletteView::setStatusBar() case State::DRAGGING_OUTLINE: if (m_hot.part == Hit::COLOR) { const int picks = m_selectedEntries.picks(); - const int destIndex = MAX(0, m_hot.color); + const int destIndex = std::max(0, m_hot.color); const int palSize = currentPalette()->size(); const int newPalSize = - (m_copy ? MAX(palSize + picks, destIndex + picks): - MAX(palSize, destIndex + picks)); + (m_copy ? std::max(palSize + picks, destIndex + picks): + std::max(palSize, destIndex + picks)); statusBar->setStatusText( 0, "%s to %d - New Palette Size %d", @@ -948,7 +948,7 @@ void PaletteView::setStatusBar() if (m_hot.part == Hit::COLOR || m_hot.part == Hit::POSSIBLE_COLOR || m_hot.part == Hit::RESIZE_HANDLE) { - int newPalSize = MAX(1, m_hot.color); + int newPalSize = std::max(1, m_hot.color); statusBar->setStatusText( 0, "New Palette Size %d", newPalSize); diff --git a/src/app/ui/recent_listbox.cpp b/src/app/ui/recent_listbox.cpp index 56014c8ca..2717ea497 100644 --- a/src/app/ui/recent_listbox.cpp +++ b/src/app/ui/recent_listbox.cpp @@ -82,7 +82,7 @@ protected: setTextQuiet(m_path); gfx::Size sz2 = theme->calcSizeHint(this, styleDetail); - ev.setSizeHint(gfx::Size(sz1.w+sz2.w, MAX(sz1.h, sz2.h))); + ev.setSizeHint(gfx::Size(sz1.w+sz2.w, std::max(sz1.h, sz2.h))); } bool onProcessMessage(Message* msg) override { diff --git a/src/app/ui/search_entry.cpp b/src/app/ui/search_entry.cpp index 491f05d17..6b93cfbac 100644 --- a/src/app/ui/search_entry.cpp +++ b/src/app/ui/search_entry.cpp @@ -1,4 +1,5 @@ // Aseprite +// Copyright (c) 2020 Igara Studio S.A. // Copyright (C) 2001-2015 David Capello // // This program is distributed under the terms of @@ -17,6 +18,8 @@ #include "ui/paint_event.h" #include "ui/size_hint_event.h" +#include + namespace app { using namespace app::skin; @@ -75,7 +78,7 @@ void SearchEntry::onSizeHint(SizeHintEvent& ev) SkinTheme* theme = static_cast(this->theme()); auto icon = theme->parts.iconSearch()->bitmap(0); - sz.h = MAX(sz.h, icon->height()+border().height()); + sz.h = std::max(sz.h, icon->height()+border().height()); ev.setSizeHint(sz); } diff --git a/src/app/ui/skin/skin_theme.cpp b/src/app/ui/skin/skin_theme.cpp index 263b7c7ed..efcccf066 100644 --- a/src/app/ui/skin/skin_theme.cpp +++ b/src/app/ui/skin/skin_theme.cpp @@ -43,6 +43,7 @@ #include "tinyxml.h" +#include #include #define BGCOLOR (getWidgetBgColor(widget)) @@ -1078,7 +1079,7 @@ void SkinTheme::drawEntryText(ui::Graphics* g, ui::Entry* widget) const std::string& textString = widget->text(); base::utf8_const_iterator utf8_it((textString.begin())); int textlen = base::utf8_length(textString); - scroll = MIN(scroll, textlen); + scroll = std::min(scroll, textlen); if (scroll) utf8_it += scroll; diff --git a/src/app/ui/tabs.cpp b/src/app/ui/tabs.cpp index 30fe57312..1e1a1cc39 100644 --- a/src/app/ui/tabs.cpp +++ b/src/app/ui/tabs.cpp @@ -154,7 +154,7 @@ void Tabs::updateTabs() double tabWidth = defTabWidth; if (tabWidth * m_list.size() > availWidth) { tabWidth = availWidth / double(m_list.size()); - tabWidth = MAX(4*ui::guiscale(), tabWidth); + tabWidth = std::max(double(4*ui::guiscale()), tabWidth); } double x = 0.0; int i = 0; diff --git a/src/app/ui/timeline/timeline.cpp b/src/app/ui/timeline/timeline.cpp index ee8cfa66f..7c57a9641 100644 --- a/src/app/ui/timeline/timeline.cpp +++ b/src/app/ui/timeline/timeline.cpp @@ -57,6 +57,7 @@ #include "os/system.h" #include "ui/ui.h" +#include #include #include @@ -998,7 +999,7 @@ bool Timeline::onProcessMessage(Message* msg) gfx::Rect onionRc = getOnionskinFramesBounds(); int newValue = m_origFrames + (m_clk.frame - hit.frame); - docPref().onionskin.prevFrames(MAX(0, newValue)); + docPref().onionskin.prevFrames(std::max(0, newValue)); onionRc |= getOnionskinFramesBounds(); invalidateRect(onionRc.offset(origin())); @@ -1009,7 +1010,7 @@ bool Timeline::onProcessMessage(Message* msg) gfx::Rect onionRc = getOnionskinFramesBounds(); int newValue = m_origFrames - (m_clk.frame - hit.frame); - docPref().onionskin.nextFrames(MAX(0, newValue)); + docPref().onionskin.nextFrames(std::max(0, newValue)); onionRc |= getOnionskinFramesBounds(); invalidateRect(onionRc.offset(origin())); @@ -1055,7 +1056,7 @@ bool Timeline::onProcessMessage(Message* msg) // we shouldn't change the hot (so the separator can be // tracked to the mouse's released). if (m_clk.part == PART_SEPARATOR) { - m_separator_x = MAX(0, mousePos.x); + m_separator_x = std::max(0, mousePos.x); layout(); return true; } @@ -1520,7 +1521,7 @@ void Timeline::onResize(ui::ResizeEvent& ev) gfx::Rect( rc.x, rc.y+(visibleTagBands()-1)*oneTagHeight(), - MIN(sz.w, m_separator_x), + std::min(sz.w, m_separator_x), oneTagHeight())); updateScrollBars(); @@ -2707,7 +2708,7 @@ gfx::Rect Timeline::getPartBounds(const Hit& hit) const case PART_HEADER_FRAME: return gfx::Rect( bounds.x + m_separator_x + m_separator_w - 1 - + frameBoxWidth()*MAX(firstFrame(), hit.frame) - viewScroll().x, + + frameBoxWidth()*std::max(firstFrame(), hit.frame) - viewScroll().x, bounds.y + y, frameBoxWidth(), headerBoxHeight()); case PART_ROW: @@ -2806,7 +2807,7 @@ gfx::Rect Timeline::getPartBounds(const Hit& hit) const return gfx::Rect( bounds.x + m_separator_x + m_separator_w - 1, bounds.y - + (m_tagFocusBand < 0 ? oneTagHeight() * MAX(0, hit.band): 0), + + (m_tagFocusBand < 0 ? oneTagHeight() * std::max(0, hit.band): 0), bounds.w - m_separator_x - m_separator_w + 1, oneTagHeight()); @@ -2827,7 +2828,7 @@ gfx::Rect Timeline::getPartBounds(const Hit& hit) const return gfx::Rect( bounds.x + bounds.w - sz.w - 2*ui::guiscale(), bounds.y - + (m_tagFocusBand < 0 ? oneTagHeight() * MAX(0, hit.band): 0) + + (m_tagFocusBand < 0 ? oneTagHeight() * std::max(0, hit.band): 0) + oneTagHeight()/2 - sz.h/2, sz.w, sz.h); } @@ -2986,7 +2987,7 @@ void Timeline::regenerateTagBands() const int oldVisibleBands = visibleTagBands(); m_tagBands = 0; for (int i : tagsPerFrame) - m_tagBands = MAX(m_tagBands, i); + m_tagBands = std::max(m_tagBands, i); if (m_tagFocusBand >= m_tagBands) m_tagFocusBand = -1; @@ -3540,8 +3541,8 @@ gfx::Point Timeline::getMaxScrollablePos() const gfx::Size size = getScrollableSize(); int max_scroll_x = size.w - getCelsBounds().w + 1*guiscale(); int max_scroll_y = size.h - getCelsBounds().h + 1*guiscale(); - max_scroll_x = MAX(0, max_scroll_x); - max_scroll_y = MAX(0, max_scroll_y); + max_scroll_x = std::max(0, max_scroll_x); + max_scroll_y = std::max(0, max_scroll_y); return gfx::Point(max_scroll_x, max_scroll_y); } else @@ -3927,9 +3928,9 @@ double Timeline::zoom() const int Timeline::calcTagVisibleToFrame(Tag* tag) const { return - MAX(tag->toFrame(), - tag->fromFrame() + - font()->textLength(tag->name())/frameBoxWidth()); + std::max(tag->toFrame(), + tag->fromFrame() + + font()->textLength(tag->name())/frameBoxWidth()); } int Timeline::topHeight() const diff --git a/src/app/util/resize_image.cpp b/src/app/util/resize_image.cpp index abcd3e56f..3c78f714c 100644 --- a/src/app/util/resize_image.cpp +++ b/src/app/util/resize_image.cpp @@ -1,5 +1,5 @@ // Aseprite -// Copyright (c) 2019 Igara Studio S.A. +// Copyright (c) 2019-2020 Igara Studio S.A. // // This program is distributed under the terms of // the End-User License Agreement for Aseprite. @@ -20,6 +20,7 @@ #include "doc/layer.h" #include "doc/sprite.h" +#include #include namespace app { @@ -80,7 +81,7 @@ void resize_cel_image( const int h = std::max(1, int(scale.h*image->height())); doc::ImageRef newImage( doc::Image::create( - image->pixelFormat(), MAX(1, w), MAX(1, h))); + image->pixelFormat(), std::max(1, w), std::max(1, h))); newImage->setMaskColor(image->maskColor()); doc::algorithm::fixup_image_transparent_colors(image); diff --git a/src/doc/algo.cpp b/src/doc/algo.cpp index 149ebe34f..c8a0d2fd2 100644 --- a/src/doc/algo.cpp +++ b/src/doc/algo.cpp @@ -291,8 +291,8 @@ void fill_rotated_ellipse(int cx, int cy, int a, int b, double angle, void* data r.first = r.second = x; } else { - r.first = MIN(r.first, x); - r.second = MAX(r.second, x); + r.first = std::min(r.first, x); + r.second = std::max(r.second, x); } } }; diff --git a/src/doc/algorithm/rotsprite.cpp b/src/doc/algorithm/rotsprite.cpp index 9c18766c2..436327d26 100644 --- a/src/doc/algorithm/rotsprite.cpp +++ b/src/doc/algorithm/rotsprite.cpp @@ -1,4 +1,5 @@ // Aseprite Document Library +// Copyright (c) 2020 Igara Studio S.A. // Copyright (c) 2001-2018 David Capello // // This file is released under the terms of the MIT license. @@ -8,11 +9,11 @@ #include "config.h" #endif -#include "base/base.h" #include "doc/algorithm/rotate.h" #include "doc/image_impl.h" #include "doc/primitives.h" +#include #include namespace doc { @@ -173,10 +174,10 @@ void rotsprite_image(Image* bmp, const Image* spr, const Image* mask, if (!buf[i]) buf[i].reset(new ImageBuffer(1)); - int xmin = MIN(x1, MIN(x2, MIN(x3, x4))); - int xmax = MAX(x1, MAX(x2, MAX(x3, x4))); - int ymin = MIN(y1, MIN(y2, MIN(y3, y4))); - int ymax = MAX(y1, MAX(y2, MAX(y3, y4))); + int xmin = std::min(x1, std::min(x2, std::min(x3, x4))); + int xmax = std::max(x1, std::max(x2, std::max(x3, x4))); + int ymin = std::min(y1, std::min(y2, std::min(y3, y4))); + int ymax = std::max(y1, std::max(y2, std::max(y3, y4))); int rot_width = xmax - xmin; int rot_height = ymax - ymin; diff --git a/src/doc/blend_funcs.cpp b/src/doc/blend_funcs.cpp index 1a92e346e..12fb692de 100644 --- a/src/doc/blend_funcs.cpp +++ b/src/doc/blend_funcs.cpp @@ -19,10 +19,10 @@ #include "doc/blend_funcs.h" -#include "base/base.h" #include "base/debug.h" #include "doc/blend_internals.h" +#include #include namespace { @@ -30,8 +30,8 @@ namespace { #define blend_multiply(b, s, t) (MUL_UN8((b), (s), (t))) #define blend_screen(b, s, t) ((b) + (s) - MUL_UN8((b), (s), (t))) #define blend_overlay(b, s, t) (blend_hard_light(s, b, t)) -#define blend_darken(b, s) (MIN((b), (s))) -#define blend_lighten(b, s) (MAX((b), (s))) +#define blend_darken(b, s) (std::min((b), (s))) +#define blend_lighten(b, s) (std::max((b), (s))) #define blend_hard_light(b, s, t) ((s) < 128 ? \ blend_multiply((b), (s)<<1, (t)): \ blend_screen((b), ((s)<<1)-255, (t))) @@ -365,14 +365,14 @@ static double lum(double r, double g, double b) static double sat(double r, double g, double b) { - return MAX(r, MAX(g, b)) - MIN(r, MIN(g, b)); + return std::max(r, std::max(g, b)) - std::min(r, std::min(g, b)); } static void clip_color(double& r, double& g, double& b) { double l = lum(r, g, b); - double n = MIN(r, MIN(g, b)); - double x = MAX(r, MAX(g, b)); + double n = std::min(r, std::min(g, b)); + double x = std::max(r, std::max(g, b)); if (n < 0) { r = l + (((r - l) * l) / (l - n)); @@ -399,7 +399,11 @@ static void set_lum(double& r, double& g, double& b, double l) // TODO replace this with a better impl (and test this, not sure if it's correct) static void set_sat(double& r, double& g, double& b, double s) { +#undef MIN +#undef MAX #undef MID +#define MIN(x,y) (((x) < (y)) ? (x) : (y)) +#define MAX(x,y) (((x) > (y)) ? (x) : (y)) #define MID(x,y,z) ((x) > (y) ? ((y) > (z) ? (y) : ((x) > (z) ? \ (z) : (x))) : ((y) > (z) ? ((z) > (x) ? (z) : \ (x)): (y))) @@ -495,7 +499,9 @@ color_t rgba_blender_addition(color_t backdrop, color_t src, int opacity) int r = rgba_getr(backdrop) + rgba_getr(src); int g = rgba_getg(backdrop) + rgba_getg(src); int b = rgba_getb(backdrop) + rgba_getb(src); - src = rgba(MIN(r, 255), MIN(g, 255), MIN(b, 255), 0) | (src & rgba_a_mask); + src = rgba(std::min(r, 255), + std::min(g, 255), + std::min(b, 255), 0) | (src & rgba_a_mask); return rgba_blender_normal(backdrop, src, opacity); } @@ -707,14 +713,14 @@ color_t graya_blender_exclusion(color_t backdrop, color_t src, int opacity) color_t graya_blender_addition(color_t backdrop, color_t src, int opacity) { int v = graya_getv(backdrop) + graya_getv(src); - src = graya(MIN(v, 255), 0) | (src & graya_a_mask); + src = graya(std::min(v, 255), 0) | (src & graya_a_mask); return graya_blender_normal(backdrop, src, opacity); } color_t graya_blender_subtract(color_t backdrop, color_t src, int opacity) { int v = graya_getv(backdrop) - graya_getv(src); - src = graya(MAX(v, 0), 0) | (src & graya_a_mask); + src = graya(std::max(v, 0), 0) | (src & graya_a_mask); return graya_blender_normal(backdrop, src, opacity); } diff --git a/src/doc/file/act_file.cpp b/src/doc/file/act_file.cpp index 5f84d7cd2..d953cc79a 100644 --- a/src/doc/file/act_file.cpp +++ b/src/doc/file/act_file.cpp @@ -1,4 +1,5 @@ // Aseprite Document Library +// Copyright (c) 2020 Igara Studio S.A. // Copyright (c) 2001-2018 David Capello // // This file is released under the terms of the MIT license. @@ -12,6 +13,7 @@ #include "base/serialization.h" #include "doc/palette.h" +#include #include #include #include @@ -36,7 +38,7 @@ Palette* load_act_file(const char *filename) int colors = ActMaxColors; // If there's extra bytes, it's the number of colors to use if (!f.eof()) { - colors = MIN(read16(f), ActMaxColors); + colors = std::min(read16(f), (uint16_t)ActMaxColors); } std::unique_ptr pal(new Palette(frame_t(0), colors)); @@ -63,7 +65,7 @@ bool save_act_file(const Palette *pal, const char *filename) uint8_t rgb[ActMaxColors * 3] = { 0 }; uint8_t *c = rgb; - int colors = MIN(pal->size(), ActMaxColors); + int colors = std::min(pal->size(), ActMaxColors); for (int i = 0; i < colors; ++i) { uint32_t col = pal->getEntry(i); diff --git a/src/doc/file/col_file.cpp b/src/doc/file/col_file.cpp index 594c24968..9728902e8 100644 --- a/src/doc/file/col_file.cpp +++ b/src/doc/file/col_file.cpp @@ -78,7 +78,7 @@ Palette* load_col_file(const char* filename) return NULL; } - pal = new Palette(frame_t(0), MIN(d.quot, 256)); + pal = new Palette(frame_t(0), std::min(d.quot, 256)); for (c=0; csize(); c++) { r = fgetc(f); diff --git a/src/doc/image_io.cpp b/src/doc/image_io.cpp index c8ab4f0fe..39fe56e3a 100644 --- a/src/doc/image_io.cpp +++ b/src/doc/image_io.cpp @@ -1,4 +1,5 @@ // Aseprite Document Library +// Copyright (c) 2020 Igara Studio S.A. // Copyright (c) 2001-2018 David Capello // // This file is released under the terms of the MIT license. @@ -10,13 +11,13 @@ #include "doc/image_io.h" -#include "base/base.h" #include "base/exception.h" #include "base/serialization.h" #include "doc/cancel_io.h" #include "doc/image.h" #include "zlib.h" +#include #include #include @@ -145,7 +146,7 @@ Image* read_image(std::istream& is, bool setId) uint8_t* address_end = image->getPixelAddress(0, 0) + uncompressed_size; while (remain > 0) { - int len = MIN(remain, (int)compressed.size()); + int len = std::min(remain, int(compressed.size())); if (is.read((char*)&compressed[0], len).fail()) { ASSERT(false); throw base::Exception("Error reading stream to restore image"); diff --git a/src/doc/palette.cpp b/src/doc/palette.cpp index b997dd629..e1487089c 100644 --- a/src/doc/palette.cpp +++ b/src/doc/palette.cpp @@ -1,4 +1,5 @@ // Aseprite Document Library +// Copyright (c) 2020 Igara Studio S.A. // Copyright (c) 2001-2017 David Capello // // This file is released under the terms of the MIT license. @@ -111,8 +112,8 @@ void Palette::copyColorsTo(Palette* dst) const int Palette::countDiff(const Palette* other, int* from, int* to) const { int c, diff = 0; - int min = MIN(this->m_colors.size(), other->m_colors.size()); - int max = MAX(this->m_colors.size(), other->m_colors.size()); + int min = std::min(this->m_colors.size(), other->m_colors.size()); + int max = std::max(this->m_colors.size(), other->m_colors.size()); if (from) *from = -1; if (to) *to = -1; @@ -244,7 +245,7 @@ int Palette::findBestfit(int r, int g, int b, int a, int mask_index) const int bestfit = 0; int lowest = std::numeric_limits::max(); - int size = MIN(256, m_colors.size()); + int size = std::min(256, int(m_colors.size())); for (int i=0; i + namespace doc { Remap create_remap_to_move_picks(const PalettePicks& picks, int beforeIndex) @@ -71,7 +73,7 @@ Remap create_remap_to_change_palette( const int oldMaskIndex, const bool remapMaskIndex) { - Remap remap(MAX(oldPalette->size(), newPalette->size())); + Remap remap(std::max(oldPalette->size(), newPalette->size())); int maskIndex = oldMaskIndex; if (maskIndex >= 0) { diff --git a/src/doc/sprite.cpp b/src/doc/sprite.cpp index 80f180577..05c5936e2 100644 --- a/src/doc/sprite.cpp +++ b/src/doc/sprite.cpp @@ -394,7 +394,7 @@ void Sprite::removeFrame(frame_t frame) void Sprite::setTotalFrames(frame_t frames) { - frames = MAX(frame_t(1), frames); + frames = std::max(frame_t(1), frames); m_frlens.resize(frames); if (frames > m_frames) { diff --git a/src/filters/median_filter.cpp b/src/filters/median_filter.cpp index cb2219606..f57ca234d 100644 --- a/src/filters/median_filter.cpp +++ b/src/filters/median_filter.cpp @@ -1,4 +1,5 @@ // Aseprite +// Copyright (C) 2020 Igara Studio S.A. // Copyright (C) 2001-2017 David Capello // // This program is distributed under the terms of @@ -107,8 +108,8 @@ void MedianFilter::setSize(int width, int height) ASSERT(width >= 1); ASSERT(height >= 1); - m_width = MAX(1, width); - m_height = MAX(1, height); + m_width = std::max(1, width); + m_height = std::max(1, height); m_ncolors = width*height; for (int c = 0; c < 4; ++c) diff --git a/src/render/quantization.cpp b/src/render/quantization.cpp index f8601684c..ab6d39f4d 100644 --- a/src/render/quantization.cpp +++ b/src/render/quantization.cpp @@ -1,5 +1,5 @@ // Aseprite Render Library -// Copyright (c) 2019 Igara Studio S.A. +// Copyright (c) 2019-2020 Igara Studio S.A. // Copyright (c) 2001-2018 David Capello // // This file is released under the terms of the MIT license. @@ -436,8 +436,9 @@ void PaletteOptimizer::calculate(Palette* palette, int maskIndex) if (maskIndex < palette->size()) palette->setEntry(maskIndex, rgba(0, 0, 0, (m_withAlpha ? 0: 255))); } - else - palette->resize(MAX(1, usedColors)); + else { + palette->resize(std::max(1, usedColors)); + } } } // namespace render