mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-29 21:33:12 +00:00
Replace base::clamp -> std::clamp as now we use C++17
This commit is contained in:
parent
b2d46bf10b
commit
71d885d2a0
@ -130,9 +130,9 @@ protected:
|
||||
|
||||
* [NL.26: Use conventional const notation](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#nl26-use-conventional-const-notation)
|
||||
|
||||
## C++11
|
||||
## C++17
|
||||
|
||||
We are using some modern C++ (C++11, C++14, etc.) features, mainly:
|
||||
We are using C++17 standard. You can safely use:
|
||||
|
||||
* Use `nullptr` instead of `NULL` macro
|
||||
* Use `auto` for complex types, iterators, or when the variable type
|
||||
@ -141,7 +141,8 @@ We are using some modern C++ (C++11, C++14, etc.) features, mainly:
|
||||
* Use template alias (`template<typename T> alias = orig<T>;`)
|
||||
* Use non-generic lambda functions
|
||||
* Use `std::shared_ptr`, `std::unique_ptr`, or `base::Ref`
|
||||
* Use `base::clamp` (no `std::clamp` yet)
|
||||
* Use `std::clamp`
|
||||
* Use `std::optional`
|
||||
* Use `static constexpr T v = ...;`
|
||||
* You can use `<atomic>`, `<thread>`, `<mutex>`, and `<condition_variable>`
|
||||
* Prefer `using T = ...;` instead of `typedef ... T`
|
||||
|
2
laf
2
laf
@ -1 +1 @@
|
||||
Subproject commit 8e87122007f9e0eafbfd824bfece7ab29118a926
|
||||
Subproject commit 395a74c990f4df3889df0b7e140998ba68ea49af
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2018-2021 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -23,7 +23,6 @@
|
||||
#include "app/filename_formatter.h"
|
||||
#include "app/restore_visible_layers.h"
|
||||
#include "app/ui_context.h"
|
||||
#include "base/clamp.h"
|
||||
#include "base/convert_to.h"
|
||||
#include "base/fs.h"
|
||||
#include "base/split_string.h"
|
||||
@ -665,8 +664,8 @@ bool CliProcessor::openFile(Context* ctx, CliOpenFile& cof)
|
||||
// --frame-range with --frame-tag
|
||||
if (tag) {
|
||||
selFrames.insert(
|
||||
tag->fromFrame()+base::clamp(cof.fromFrame, 0, tag->frames()-1),
|
||||
tag->fromFrame()+base::clamp(cof.toFrame, 0, tag->frames()-1));
|
||||
tag->fromFrame()+std::clamp(cof.fromFrame, 0, tag->frames()-1),
|
||||
tag->fromFrame()+std::clamp(cof.toFrame, 0, tag->frames()-1));
|
||||
}
|
||||
// --frame-range without --frame-tag
|
||||
else {
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2020 Igara Studio S.A.
|
||||
// Copyright (C) 2020-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -18,7 +18,6 @@
|
||||
#include "app/cmd/set_cel_opacity.h"
|
||||
#include "app/cmd/set_cel_position.h"
|
||||
#include "app/doc.h"
|
||||
#include "base/clamp.h"
|
||||
#include "doc/cel.h"
|
||||
#include "doc/image.h"
|
||||
#include "doc/layer.h"
|
||||
@ -64,7 +63,7 @@ void BackgroundFromLayer::onExecute()
|
||||
bg_image.get(), cel_image,
|
||||
sprite->palette(cel->frame()),
|
||||
cel->x(), cel->y(),
|
||||
base::clamp(cel->opacity(), 0, 255),
|
||||
std::clamp(cel->opacity(), 0, 255),
|
||||
static_cast<LayerImage*>(layer)->blendMode());
|
||||
|
||||
// now we have to copy the new image (bg_image) to the cel...
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2020 Igara Studio S.A.
|
||||
// Copyright (C) 2020-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -13,7 +13,6 @@
|
||||
|
||||
#include "app/color_utils.h"
|
||||
#include "app/modules/palettes.h"
|
||||
#include "base/clamp.h"
|
||||
#include "base/debug.h"
|
||||
#include "doc/image.h"
|
||||
#include "doc/palette.h"
|
||||
@ -204,8 +203,8 @@ std::string Color::toString() const
|
||||
<< std::setprecision(2)
|
||||
<< std::fixed
|
||||
<< m_value.hsv.h << ","
|
||||
<< base::clamp(m_value.hsv.s*100.0, 0.0, 100.0) << ","
|
||||
<< base::clamp(m_value.hsv.v*100.0, 0.0, 100.0) << ","
|
||||
<< std::clamp(m_value.hsv.s*100.0, 0.0, 100.0) << ","
|
||||
<< std::clamp(m_value.hsv.v*100.0, 0.0, 100.0) << ","
|
||||
<< m_value.hsv.a << "}";
|
||||
break;
|
||||
|
||||
@ -214,8 +213,8 @@ std::string Color::toString() const
|
||||
<< std::setprecision(2)
|
||||
<< std::fixed
|
||||
<< m_value.hsl.h << ","
|
||||
<< base::clamp(m_value.hsl.s*100.0, 0.0, 100.0) << ","
|
||||
<< base::clamp(m_value.hsl.l*100.0, 0.0, 100.0) << ","
|
||||
<< std::clamp(m_value.hsl.s*100.0, 0.0, 100.0) << ","
|
||||
<< std::clamp(m_value.hsl.l*100.0, 0.0, 100.0) << ","
|
||||
<< m_value.hsl.a << "}";
|
||||
break;
|
||||
|
||||
@ -268,8 +267,8 @@ std::string Color::toHumanReadableString(PixelFormat pixelFormat, HumanReadableS
|
||||
else {
|
||||
result << "HSV "
|
||||
<< int(m_value.hsv.h) << "\xc2\xb0 "
|
||||
<< base::clamp(int(m_value.hsv.s*100.0), 0, 100) << "% "
|
||||
<< base::clamp(int(m_value.hsv.v*100.0), 0, 100) << "%";
|
||||
<< std::clamp(int(m_value.hsv.s*100.0), 0, 100) << "% "
|
||||
<< std::clamp(int(m_value.hsv.v*100.0), 0, 100) << "%";
|
||||
|
||||
if (pixelFormat == IMAGE_INDEXED)
|
||||
result << " Index " << color_utils::color_for_image(*this, IMAGE_INDEXED);
|
||||
@ -288,8 +287,8 @@ std::string Color::toHumanReadableString(PixelFormat pixelFormat, HumanReadableS
|
||||
else {
|
||||
result << "HSL "
|
||||
<< int(m_value.hsl.h) << "\xc2\xb0 "
|
||||
<< base::clamp(int(m_value.hsl.s*100.0), 0, 100) << "% "
|
||||
<< base::clamp(int(m_value.hsl.l*100.0), 0, 100) << "%";
|
||||
<< std::clamp(int(m_value.hsl.s*100.0), 0, 100) << "% "
|
||||
<< std::clamp(int(m_value.hsl.l*100.0), 0, 100) << "%";
|
||||
|
||||
if (pixelFormat == IMAGE_INDEXED)
|
||||
result << " Index " << color_utils::color_for_image(*this, IMAGE_INDEXED);
|
||||
@ -358,8 +357,8 @@ std::string Color::toHumanReadableString(PixelFormat pixelFormat, HumanReadableS
|
||||
}
|
||||
else {
|
||||
result << int(m_value.hsv.h) << "\xc2\xb0"
|
||||
<< base::clamp(int(m_value.hsv.s*100.0), 0, 100) << ","
|
||||
<< base::clamp(int(m_value.hsv.v*100.0), 0, 100);
|
||||
<< std::clamp(int(m_value.hsv.s*100.0), 0, 100) << ","
|
||||
<< std::clamp(int(m_value.hsv.v*100.0), 0, 100);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -369,8 +368,8 @@ std::string Color::toHumanReadableString(PixelFormat pixelFormat, HumanReadableS
|
||||
}
|
||||
else {
|
||||
result << int(m_value.hsl.h) << "\xc2\xb0"
|
||||
<< base::clamp(int(m_value.hsl.s*100.0), 0, 100) << ","
|
||||
<< base::clamp(int(m_value.hsl.l*100.0), 0, 100);
|
||||
<< std::clamp(int(m_value.hsl.s*100.0), 0, 100) << ","
|
||||
<< std::clamp(int(m_value.hsl.l*100.0), 0, 100);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -908,7 +907,7 @@ int Color::getAlpha() const
|
||||
|
||||
void Color::setAlpha(int alpha)
|
||||
{
|
||||
alpha = base::clamp(alpha, 0, 255);
|
||||
alpha = std::clamp(alpha, 0, 255);
|
||||
|
||||
switch (getType()) {
|
||||
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "app/ui/editor/select_box_state.h"
|
||||
#include "app/ui/skin/skin_theme.h"
|
||||
#include "app/ui_context.h"
|
||||
#include "base/clamp.h"
|
||||
#include "doc/image.h"
|
||||
#include "doc/mask.h"
|
||||
#include "doc/sprite.h"
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2020 Igara Studio S.A.
|
||||
// Copyright (C) 2020-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -19,7 +19,6 @@
|
||||
#include "app/modules/gui.h"
|
||||
#include "app/tx.h"
|
||||
#include "app/ui/timeline/timeline.h"
|
||||
#include "base/clamp.h"
|
||||
#include "doc/cel.h"
|
||||
#include "doc/cels_range.h"
|
||||
#include "doc/sprite.h"
|
||||
@ -53,7 +52,7 @@ CelOpacityCommand::CelOpacityCommand()
|
||||
void CelOpacityCommand::onLoadParams(const Params& params)
|
||||
{
|
||||
m_opacity = params.get_as<int>("opacity");
|
||||
m_opacity = base::clamp(m_opacity, 0, 255);
|
||||
m_opacity = std::clamp(m_opacity, 0, 255);
|
||||
}
|
||||
|
||||
bool CelOpacityCommand::onEnabled(Context* context)
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -32,7 +32,6 @@
|
||||
#include "app/ui/optional_alert.h"
|
||||
#include "app/ui/status_bar.h"
|
||||
#include "app/ui/timeline/timeline.h"
|
||||
#include "base/clamp.h"
|
||||
#include "base/convert_to.h"
|
||||
#include "base/fs.h"
|
||||
#include "base/string.h"
|
||||
@ -184,9 +183,9 @@ Doc* generate_sprite_sheet_from_params(
|
||||
const std::string filenameFormat = params.filenameFormat();
|
||||
const std::string layerName = params.layer();
|
||||
const std::string tagName = params.tag();
|
||||
const int borderPadding = base::clamp(params.borderPadding(), 0, 100);
|
||||
const int shapePadding = base::clamp(params.shapePadding(), 0, 100);
|
||||
const int innerPadding = base::clamp(params.innerPadding(), 0, 100);
|
||||
const int borderPadding = std::clamp(params.borderPadding(), 0, 100);
|
||||
const int shapePadding = std::clamp(params.shapePadding(), 0, 100);
|
||||
const int innerPadding = std::clamp(params.innerPadding(), 0, 100);
|
||||
const bool trimSprite = params.trimSprite();
|
||||
const bool trimCels = params.trim();
|
||||
const bool trimByGrid = params.trimByGrid();
|
||||
@ -666,17 +665,17 @@ private:
|
||||
|
||||
int borderPaddingValue() const {
|
||||
int value = borderPadding()->textInt();
|
||||
return base::clamp(value, 0, 100);
|
||||
return std::clamp(value, 0, 100);
|
||||
}
|
||||
|
||||
int shapePaddingValue() const {
|
||||
int value = shapePadding()->textInt();
|
||||
return base::clamp(value, 0, 100);
|
||||
return std::clamp(value, 0, 100);
|
||||
}
|
||||
|
||||
int innerPaddingValue() const {
|
||||
int value = innerPadding()->textInt();
|
||||
return base::clamp(value, 0, 100);
|
||||
return std::clamp(value, 0, 100);
|
||||
}
|
||||
|
||||
bool trimSpriteValue() const {
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -18,7 +18,6 @@
|
||||
#include "app/ui/editor/editor.h"
|
||||
#include "app/ui/editor/editor_customization_delegate.h"
|
||||
#include "app/ui/search_entry.h"
|
||||
#include "base/clamp.h"
|
||||
#include "doc/sprite.h"
|
||||
#include "doc/tag.h"
|
||||
#include "ui/combobox.h"
|
||||
@ -257,7 +256,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
return base::clamp(
|
||||
return std::clamp(
|
||||
m_frame-docPref.timeline.firstFrame(),
|
||||
0, editor->sprite()->lastFrame());
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2020 Igara Studio S.A.
|
||||
// Copyright (C) 2020-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2016-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -19,7 +19,6 @@
|
||||
#include "app/modules/gui.h"
|
||||
#include "app/tx.h"
|
||||
#include "app/ui/timeline/timeline.h"
|
||||
#include "base/clamp.h"
|
||||
#include "doc/layer.h"
|
||||
#include "fmt/format.h"
|
||||
|
||||
@ -51,7 +50,7 @@ LayerOpacityCommand::LayerOpacityCommand()
|
||||
void LayerOpacityCommand::onLoadParams(const Params& params)
|
||||
{
|
||||
m_opacity = params.get_as<int>("opacity");
|
||||
m_opacity = base::clamp(m_opacity, 0, 255);
|
||||
m_opacity = std::clamp(m_opacity, 0, 255);
|
||||
}
|
||||
|
||||
bool LayerOpacityCommand::onEnabled(Context* context)
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2015-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -18,7 +18,6 @@
|
||||
#include "app/modules/gui.h"
|
||||
#include "app/pref/preferences.h"
|
||||
#include "app/tx.h"
|
||||
#include "base/clamp.h"
|
||||
#include "base/convert_to.h"
|
||||
#include "doc/algorithm/modify_selection.h"
|
||||
#include "doc/brush_type.h"
|
||||
@ -113,7 +112,7 @@ void ModifySelectionCommand::onExecute(Context* context)
|
||||
return;
|
||||
|
||||
quantity = window.quantity()->textInt();
|
||||
quantity = base::clamp(quantity, 1, 100);
|
||||
quantity = std::clamp(quantity, 1, 100);
|
||||
|
||||
brush = (window.circle()->isSelected() ? doc::kCircleBrushType:
|
||||
doc::kSquareBrushType);
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2018-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -27,7 +27,6 @@
|
||||
#include "app/util/clipboard.h"
|
||||
#include "app/util/clipboard.h"
|
||||
#include "app/util/pixel_ratio.h"
|
||||
#include "base/clamp.h"
|
||||
#include "doc/cel.h"
|
||||
#include "doc/image.h"
|
||||
#include "doc/layer.h"
|
||||
@ -128,7 +127,7 @@ void NewFileCommand::onExecute(Context* ctx)
|
||||
int w = pref.newFile.width();
|
||||
int h = pref.newFile.height();
|
||||
int bg = pref.newFile.backgroundColor();
|
||||
bg = base::clamp(bg, 0, 2);
|
||||
bg = std::clamp(bg, 0, 2);
|
||||
|
||||
// If the clipboard contains an image, we can show the size of the
|
||||
// clipboard as default image size.
|
||||
@ -190,10 +189,10 @@ void NewFileCommand::onExecute(Context* ctx)
|
||||
static_assert(int(ColorMode::RGB) == 0, "RGB pixel format should be 0");
|
||||
static_assert(int(ColorMode::INDEXED) == 2, "Indexed pixel format should be 2");
|
||||
|
||||
colorMode = base::clamp(colorMode, ColorMode::RGB, ColorMode::INDEXED);
|
||||
w = base::clamp(w, 1, DOC_SPRITE_MAX_WIDTH);
|
||||
h = base::clamp(h, 1, DOC_SPRITE_MAX_HEIGHT);
|
||||
bg = base::clamp(bg, 0, 2);
|
||||
colorMode = std::clamp(colorMode, ColorMode::RGB, ColorMode::INDEXED);
|
||||
w = std::clamp(w, 1, DOC_SPRITE_MAX_WIDTH);
|
||||
h = std::clamp(h, 1, DOC_SPRITE_MAX_HEIGHT);
|
||||
bg = std::clamp(bg, 0, 2);
|
||||
|
||||
// Select the background color
|
||||
if (bg >= 0 && bg <= 3) {
|
||||
|
@ -32,7 +32,6 @@
|
||||
#include "app/ui/sampling_selector.h"
|
||||
#include "app/ui/separator_in_view.h"
|
||||
#include "app/ui/skin/skin_theme.h"
|
||||
#include "base/clamp.h"
|
||||
#include "base/convert_to.h"
|
||||
#include "base/fs.h"
|
||||
#include "base/string.h"
|
||||
@ -724,7 +723,7 @@ public:
|
||||
|
||||
int undo_size_limit_value;
|
||||
undo_size_limit_value = undoSizeLimit()->textInt();
|
||||
undo_size_limit_value = base::clamp(undo_size_limit_value, 0, 999999);
|
||||
undo_size_limit_value = std::clamp(undo_size_limit_value, 0, 999999);
|
||||
|
||||
m_pref.undo.sizeLimit(undo_size_limit_value);
|
||||
m_pref.undo.gotoModified(undoGotoModified()->isSelected());
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -14,7 +14,6 @@
|
||||
#include "app/commands/params.h"
|
||||
#include "app/context_access.h"
|
||||
#include "app/tx.h"
|
||||
#include "base/clamp.h"
|
||||
#include "doc/palette.h"
|
||||
#include "doc/sprite.h"
|
||||
|
||||
@ -70,7 +69,7 @@ void PaletteSizeCommand::onExecute(Context* context)
|
||||
if (ncolors == palette.size())
|
||||
return;
|
||||
|
||||
palette.resize(base::clamp(ncolors, 1, std::numeric_limits<int>::max()));
|
||||
palette.resize(std::clamp(ncolors, 1, std::numeric_limits<int>::max()));
|
||||
|
||||
ContextWriter writer(reader);
|
||||
Tx tx(context, "Palette Size", ModifyDocument);
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -21,7 +21,6 @@
|
||||
#include "app/ui/font_popup.h"
|
||||
#include "app/ui/timeline/timeline.h"
|
||||
#include "app/util/freetype_utils.h"
|
||||
#include "base/clamp.h"
|
||||
#include "base/fs.h"
|
||||
#include "base/string.h"
|
||||
#include "doc/image.h"
|
||||
@ -80,7 +79,7 @@ public:
|
||||
|
||||
int sizeValue() const {
|
||||
int size = fontSize()->textInt();
|
||||
size = base::clamp(size, 1, 5000);
|
||||
size = std::clamp(size, 1, 5000);
|
||||
return size;
|
||||
}
|
||||
|
||||
@ -165,7 +164,7 @@ void PasteTextCommand::onExecute(Context* ctx)
|
||||
bool antialias = window.antialias()->isSelected();
|
||||
std::string faceName = window.faceValue();
|
||||
int size = window.sizeValue();
|
||||
size = base::clamp(size, 1, 999);
|
||||
size = std::clamp(size, 1, 999);
|
||||
pref.textTool.fontFace(faceName);
|
||||
pref.textTool.fontSize(size);
|
||||
pref.textTool.antialias(antialias);
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -20,7 +20,6 @@
|
||||
#include "app/modules/palettes.h"
|
||||
#include "app/sprite_job.h"
|
||||
#include "app/util/resize_image.h"
|
||||
#include "base/clamp.h"
|
||||
#include "base/convert_to.h"
|
||||
#include "doc/algorithm/resize_image.h"
|
||||
#include "doc/cel.h"
|
||||
@ -386,8 +385,8 @@ void SpriteSizeCommand::onExecute(Context* context)
|
||||
}
|
||||
#endif // ENABLE_UI
|
||||
|
||||
new_width = base::clamp(new_width, 1, DOC_SPRITE_MAX_WIDTH);
|
||||
new_height = base::clamp(new_height, 1, DOC_SPRITE_MAX_HEIGHT);
|
||||
new_width = std::clamp(new_width, 1, DOC_SPRITE_MAX_WIDTH);
|
||||
new_height = std::clamp(new_height, 1, DOC_SPRITE_MAX_HEIGHT);
|
||||
|
||||
{
|
||||
SpriteSizeJob job(reader, new_width, new_height, resize_method);
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include "app/context.h"
|
||||
#include "app/script/engine.h"
|
||||
#include "app/ui/skin/skin_theme.h"
|
||||
#include "base/clamp.h"
|
||||
#include "base/convert_to.h"
|
||||
#include "base/file_content.h"
|
||||
#include "base/fs.h"
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -21,7 +21,6 @@
|
||||
#include "app/ini_file.h"
|
||||
#include "app/load_widget.h"
|
||||
#include "app/pref/preferences.h"
|
||||
#include "base/clamp.h"
|
||||
#include "doc/mask.h"
|
||||
#include "doc/sprite.h"
|
||||
#include "filters/median_filter.h"
|
||||
@ -78,8 +77,8 @@ private:
|
||||
m_heightEntry->textInt());
|
||||
|
||||
// Avoid negative numbers
|
||||
newSize.w = base::clamp(newSize.w, 1, 100);
|
||||
newSize.h = base::clamp(newSize.h, 1, 100);
|
||||
newSize.w = std::clamp(newSize.w, 1, 100);
|
||||
newSize.h = std::clamp(newSize.h, 1, 100);
|
||||
|
||||
// If we had a previous filter preview running in the background,
|
||||
// we explicitly request it be stopped. Otherwise, changing the
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -11,7 +11,6 @@
|
||||
|
||||
#include "app/commands/filters/color_curve_editor.h"
|
||||
|
||||
#include "base/clamp.h"
|
||||
#include "filters/color_curve.h"
|
||||
#include "ui/alert.h"
|
||||
#include "ui/entry.h"
|
||||
@ -140,8 +139,8 @@ bool ColorCurveEditor::onProcessMessage(Message* msg)
|
||||
if (m_editPoint) {
|
||||
gfx::Point mousePos = static_cast<MouseMessage*>(msg)->position();
|
||||
*m_editPoint = screenToView(mousePos);
|
||||
m_editPoint->x = base::clamp(m_editPoint->x, m_viewBounds.x, m_viewBounds.x2()-1);
|
||||
m_editPoint->y = base::clamp(m_editPoint->y, m_viewBounds.y, m_viewBounds.y2()-1);
|
||||
m_editPoint->x = std::clamp(m_editPoint->x, m_viewBounds.x, m_viewBounds.x2()-1);
|
||||
m_editPoint->y = std::clamp(m_editPoint->y, m_viewBounds.y, m_viewBounds.y2()-1);
|
||||
|
||||
// TODO this should be optional
|
||||
CurveEditorChange();
|
||||
@ -209,9 +208,9 @@ void ColorCurveEditor::onPaint(ui::PaintEvent& ev)
|
||||
// Draw curve
|
||||
for (c = client.x; c < client.x+client.w; ++c) {
|
||||
pt = clientToView(gfx::Point(c, 0));
|
||||
pt.x = base::clamp(pt.x, m_viewBounds.x, m_viewBounds.x2()-1);
|
||||
pt.x = std::clamp(pt.x, m_viewBounds.x, m_viewBounds.x2()-1);
|
||||
pt.y = values[pt.x - m_viewBounds.x];
|
||||
pt.y = base::clamp(pt.y, m_viewBounds.y, m_viewBounds.y2()-1);
|
||||
pt.y = std::clamp(pt.y, m_viewBounds.y, m_viewBounds.y2()-1);
|
||||
pt = viewToClient(pt);
|
||||
|
||||
g->putPixel(gfx::rgba(255, 255, 255), c, pt.y);
|
||||
@ -270,8 +269,8 @@ bool ColorCurveEditor::editNodeManually(gfx::Point& viewPt)
|
||||
if (window.closer() == window.ok()) {
|
||||
viewPt.x = window.x()->textInt();
|
||||
viewPt.y = window.y()->textInt();
|
||||
viewPt.x = base::clamp(viewPt.x, 0, 255);
|
||||
viewPt.y = base::clamp(viewPt.y, 0, 255);
|
||||
viewPt.x = std::clamp(viewPt.x, 0, 255);
|
||||
viewPt.y = std::clamp(viewPt.y, 0, 255);
|
||||
return true;
|
||||
}
|
||||
else if (window.closer() == window.deleteButton()) {
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include "app/console.h"
|
||||
#include "app/crash/internals.h"
|
||||
#include "app/doc.h"
|
||||
#include "base/clamp.h"
|
||||
#include "base/convert_to.h"
|
||||
#include "base/exception.h"
|
||||
#include "base/fs.h"
|
||||
@ -540,8 +539,8 @@ Doc* read_document_with_raw_images(const std::string& dir,
|
||||
info.height = 256;
|
||||
info.filename = "Unknown";
|
||||
}
|
||||
info.width = base::clamp(info.width, 1, 99999);
|
||||
info.height = base::clamp(info.height, 1, 99999);
|
||||
info.width = std::clamp(info.width, 1, 99999);
|
||||
info.height = std::clamp(info.height, 1, 99999);
|
||||
Sprite* spr = new Sprite(ImageSpec(info.mode, info.width, info.height), 256);
|
||||
|
||||
// Load each image as a new frame
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include "app/restore_visible_layers.h"
|
||||
#include "app/snap_to_grid.h"
|
||||
#include "app/util/autocrop.h"
|
||||
#include "base/clamp.h"
|
||||
#include "base/convert_to.h"
|
||||
#include "base/fs.h"
|
||||
#include "base/fstream_path.h"
|
||||
@ -127,7 +126,7 @@ int DocExporter::Item::frames() const
|
||||
return selFrames->size();
|
||||
else if (tag) {
|
||||
int result = tag->toFrame() - tag->fromFrame() + 1;
|
||||
return base::clamp(result, 1, doc->sprite()->totalFrames());
|
||||
return std::clamp(result, 1, doc->sprite()->totalFrames());
|
||||
}
|
||||
else
|
||||
return doc->sprite()->totalFrames();
|
||||
@ -140,8 +139,8 @@ doc::SelectedFrames DocExporter::Item::getSelectedFrames() const
|
||||
|
||||
doc::SelectedFrames frames;
|
||||
if (tag) {
|
||||
frames.insert(base::clamp(tag->fromFrame(), 0, doc->sprite()->lastFrame()),
|
||||
base::clamp(tag->toFrame(), 0, doc->sprite()->lastFrame()));
|
||||
frames.insert(std::clamp(tag->fromFrame(), 0, doc->sprite()->lastFrame()),
|
||||
std::clamp(tag->toFrame(), 0, doc->sprite()->lastFrame()));
|
||||
}
|
||||
else {
|
||||
frames.insert(0, doc->sprite()->lastFrame());
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2018-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -16,7 +16,6 @@
|
||||
#include "app/file/format_options.h"
|
||||
#include "app/pref/preferences.h"
|
||||
#include "base/cfile.h"
|
||||
#include "base/clamp.h"
|
||||
#include "base/exception.h"
|
||||
#include "base/file_handle.h"
|
||||
#include "base/fs.h"
|
||||
@ -964,8 +963,8 @@ static void ase_file_write_tags_chunk(FILE* f,
|
||||
tag->toFrame() < fromFrame)
|
||||
continue;
|
||||
|
||||
frame_t from = base::clamp(tag->fromFrame()-fromFrame, 0, toFrame-fromFrame);
|
||||
frame_t to = base::clamp(tag->toFrame()-fromFrame, from, toFrame-fromFrame);
|
||||
frame_t from = std::clamp(tag->fromFrame()-fromFrame, 0, toFrame-fromFrame);
|
||||
frame_t to = std::clamp(tag->toFrame()-fromFrame, from, toFrame-fromFrame);
|
||||
|
||||
fputw(from, f);
|
||||
fputw(to, f);
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2018-2021 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -19,7 +19,6 @@
|
||||
#include "app/find_widget.h"
|
||||
#include "app/load_widget.h"
|
||||
#include "app/pref/preferences.h"
|
||||
#include "base/clamp.h"
|
||||
#include "base/file_handle.h"
|
||||
#include "base/memory.h"
|
||||
#include "doc/doc.h"
|
||||
@ -358,7 +357,7 @@ bool JpegFormat::onSave(FileOp* fop)
|
||||
JDIMENSION buffer_height;
|
||||
const auto jpeg_options = std::static_pointer_cast<JpegOptions>(fop->formatOptions());
|
||||
const int qualityValue =
|
||||
(jpeg_options ? (int)base::clamp(100.0f * jpeg_options->quality, 0.f, 100.f):
|
||||
(jpeg_options ? (int)std::clamp(100.0f * jpeg_options->quality, 0.f, 100.f):
|
||||
100);
|
||||
|
||||
int c;
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2018-2021 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -14,7 +14,6 @@
|
||||
#include "app/file/file.h"
|
||||
#include "app/file/file_format.h"
|
||||
#include "app/file/file_formats_manager.h"
|
||||
#include "base/clamp.h"
|
||||
#include "base/fs.h"
|
||||
#include "base/string.h"
|
||||
#include "dio/detect_format.h"
|
||||
@ -151,7 +150,7 @@ bool save_palette(const char* filename, const Palette* pal, int columns,
|
||||
if (!ff || !ff->support(FILE_SUPPORT_SAVE))
|
||||
break;
|
||||
|
||||
int w = (columns > 0 ? base::clamp(columns, 0, pal->size()): pal->size());
|
||||
int w = (columns > 0 ? std::clamp(columns, 0, pal->size()): pal->size());
|
||||
int h = (pal->size() / w) + (pal->size() % w > 0 ? 1: 0);
|
||||
|
||||
Context tmpContext;
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2018-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -16,7 +16,6 @@
|
||||
#include "app/file/format_options.h"
|
||||
#include "app/file/png_format.h"
|
||||
#include "app/file/png_options.h"
|
||||
#include "base/clamp.h"
|
||||
#include "base/file_handle.h"
|
||||
#include "doc/doc.h"
|
||||
#include "gfx/color_space.h"
|
||||
@ -614,7 +613,7 @@ bool PngFormat::onSave(FileOp* fop)
|
||||
if (color_type == PNG_COLOR_TYPE_PALETTE) {
|
||||
int c, r, g, b;
|
||||
int pal_size = fop->sequenceGetNColors();
|
||||
pal_size = base::clamp(pal_size, 1, PNG_MAX_PALETTE_LENGTH);
|
||||
pal_size = std::clamp(pal_size, 1, PNG_MAX_PALETTE_LENGTH);
|
||||
|
||||
#if PNG_MAX_PALETTE_LENGTH != 256
|
||||
#error PNG_MAX_PALETTE_LENGTH should be 256
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (c) 2018-2020 Igara Studio S.A.
|
||||
// Copyright (c) 2018-2022 Igara Studio S.A.
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -17,7 +17,6 @@
|
||||
#include "app/file/format_options.h"
|
||||
#include "app/pref/preferences.h"
|
||||
#include "base/cfile.h"
|
||||
#include "base/clamp.h"
|
||||
#include "base/file_handle.h"
|
||||
#include "doc/doc.h"
|
||||
#include "ui/window.h"
|
||||
@ -85,7 +84,7 @@ bool SvgFormat::onSave(FileOp* fop)
|
||||
const Image* image = fop->sequenceImage();
|
||||
int x, y, c, r, g, b, a, alpha;
|
||||
const auto svg_options = std::static_pointer_cast<SvgOptions>(fop->formatOptions());
|
||||
const int pixelScaleValue = base::clamp(svg_options->pixelScale, 0, 10000);
|
||||
const int pixelScaleValue = std::clamp(svg_options->pixelScale, 0, 10000);
|
||||
FileHandle handle(open_file_with_exception_sync_on_close(fop->filename(), "wb"));
|
||||
FILE* f = handle.get();
|
||||
auto printcol = [f](int x, int y,int r, int g, int b, int a, int pxScale) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2018-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2015-2018 David Capello
|
||||
// Copyright (C) 2015 Gabriel Rauter
|
||||
//
|
||||
@ -20,7 +20,6 @@
|
||||
#include "app/file/webp_options.h"
|
||||
#include "app/ini_file.h"
|
||||
#include "app/pref/preferences.h"
|
||||
#include "base/clamp.h"
|
||||
#include "base/convert_to.h"
|
||||
#include "base/file_handle.h"
|
||||
#include "doc/doc.h"
|
||||
@ -243,7 +242,7 @@ static int progress_report(int percent, const WebPPicture* pic)
|
||||
|
||||
double newProgress = (double(wd->f) + double(percent)/100.0) / double(wd->n);
|
||||
wd->progress = std::max(wd->progress, newProgress);
|
||||
wd->progress = base::clamp(wd->progress, 0.0, 1.0);
|
||||
wd->progress = std::clamp(wd->progress, 0.0, 1.0);
|
||||
|
||||
fop->setProgress(wd->progress);
|
||||
if (fop->isStop())
|
||||
|
@ -37,7 +37,6 @@
|
||||
#include "app/ui/toolbar.h"
|
||||
#include "app/ui_context.h"
|
||||
#include "app/util/open_batch.h"
|
||||
#include "base/clamp.h"
|
||||
#include "base/fs.h"
|
||||
#include "base/memory.h"
|
||||
#include "base/string.h"
|
||||
@ -130,7 +129,7 @@ static bool create_main_window(bool gpuAccel,
|
||||
try {
|
||||
if (!spec.frame().isEmpty() ||
|
||||
!spec.contentRect().isEmpty()) {
|
||||
spec.scale(scale == 0 ? 2: base::clamp(scale, 1, 4));
|
||||
spec.scale(scale == 0 ? 2: std::clamp(scale, 1, 4));
|
||||
main_window = os::instance()->makeWindow(spec);
|
||||
}
|
||||
}
|
||||
@ -395,16 +394,16 @@ void load_window_pos(Widget* window, const char* section,
|
||||
pos = get_config_rect(section, "WindowPos", pos);
|
||||
|
||||
if (limitMinSize) {
|
||||
pos.w = base::clamp(pos.w, orig_pos.w, ui::display_w());
|
||||
pos.h = base::clamp(pos.h, orig_pos.h, ui::display_h());
|
||||
pos.w = std::clamp(pos.w, orig_pos.w, ui::display_w());
|
||||
pos.h = std::clamp(pos.h, orig_pos.h, ui::display_h());
|
||||
}
|
||||
else {
|
||||
pos.w = std::min(pos.w, ui::display_w());
|
||||
pos.h = std::min(pos.h, ui::display_h());
|
||||
}
|
||||
|
||||
pos.setOrigin(Point(base::clamp(pos.x, 0, ui::display_w()-pos.w),
|
||||
base::clamp(pos.y, 0, ui::display_h()-pos.h)));
|
||||
pos.setOrigin(Point(std::clamp(pos.x, 0, ui::display_w()-pos.w),
|
||||
std::clamp(pos.y, 0, ui::display_h()-pos.h)));
|
||||
|
||||
window->setBounds(pos);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2018-2021 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2015-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -37,7 +37,6 @@
|
||||
#include "app/ui/editor/tool_loop_impl.h"
|
||||
#include "app/ui/timeline/timeline.h"
|
||||
#include "app/ui_context.h"
|
||||
#include "base/clamp.h"
|
||||
#include "base/fs.h"
|
||||
#include "base/replace_string.h"
|
||||
#include "base/version.h"
|
||||
@ -370,14 +369,14 @@ int App_useTool(lua_State* L)
|
||||
type = lua_getfield(L, 1, "opacity");
|
||||
if (type != LUA_TNIL) {
|
||||
params.opacity = lua_tointeger(L, -1);
|
||||
params.opacity = base::clamp(params.opacity, 0, 255);
|
||||
params.opacity = std::clamp(params.opacity, 0, 255);
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
type = lua_getfield(L, 1, "tolerance");
|
||||
if (type != LUA_TNIL) {
|
||||
params.tolerance = lua_tointeger(L, -1);
|
||||
params.tolerance = base::clamp(params.tolerance, 0, 255);
|
||||
params.tolerance = std::clamp(params.tolerance, 0, 255);
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include "app/script/luacpp.h"
|
||||
#include "app/script/userdata.h"
|
||||
#include "app/tx.h"
|
||||
#include "base/clamp.h"
|
||||
#include "doc/layer.h"
|
||||
#include "doc/sprite.h"
|
||||
|
||||
@ -272,7 +271,7 @@ int Layer_set_stackIndex(lua_State* L)
|
||||
}
|
||||
|
||||
if (newStackIndex-1 < int(parent->layers().size())) {
|
||||
beforeThis = parent->layers()[base::clamp(newStackIndex-1, 0, (int)parent->layers().size())];
|
||||
beforeThis = parent->layers()[std::clamp(newStackIndex-1, 0, (int)parent->layers().size())];
|
||||
}
|
||||
else {
|
||||
beforeThis = nullptr;
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -12,7 +12,6 @@
|
||||
#include "app/site.h"
|
||||
|
||||
#include "app/pref/preferences.h"
|
||||
#include "base/clamp.h"
|
||||
#include "doc/cel.h"
|
||||
#include "doc/layer.h"
|
||||
#include "doc/sprite.h"
|
||||
@ -57,7 +56,7 @@ Image* Site::image(int* x, int* y, int* opacity) const
|
||||
image = cel->image();
|
||||
if (x) *x = cel->x();
|
||||
if (y) *y = cel->y();
|
||||
if (opacity) *opacity = base::clamp(cel->opacity(), 0, 255);
|
||||
if (opacity) *opacity = std::clamp(cel->opacity(), 0, 255);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include "app/file/file.h"
|
||||
#include "app/file_system.h"
|
||||
#include "app/util/conversion_to_surface.h"
|
||||
#include "base/clamp.h"
|
||||
#include "base/thread.h"
|
||||
#include "doc/algorithm/rotate.h"
|
||||
#include "doc/image.h"
|
||||
@ -126,8 +125,8 @@ private:
|
||||
thumb_w = w;
|
||||
thumb_h = h;
|
||||
}
|
||||
thumb_w = base::clamp(thumb_w, 1, MAX_THUMBNAIL_SIZE);
|
||||
thumb_h = base::clamp(thumb_h, 1, MAX_THUMBNAIL_SIZE);
|
||||
thumb_w = std::clamp(thumb_w, 1, MAX_THUMBNAIL_SIZE);
|
||||
thumb_h = std::clamp(thumb_h, 1, MAX_THUMBNAIL_SIZE);
|
||||
|
||||
// Stretch the 'image'
|
||||
thumbnailImage.reset(
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "app/color_utils.h"
|
||||
#include "app/util/wrap_point.h"
|
||||
#include "app/util/wrap_value.h"
|
||||
#include "base/clamp.h"
|
||||
#include "doc/blend_funcs.h"
|
||||
#include "doc/blend_internals.h"
|
||||
#include "doc/image_impl.h"
|
||||
@ -678,8 +677,8 @@ private:
|
||||
m_srcImageHeight),
|
||||
pt, false);
|
||||
|
||||
pt.x = base::clamp(pt.x, 0, m_srcImageWidth-1);
|
||||
pt.y = base::clamp(pt.y, 0, m_srcImageHeight-1);
|
||||
pt.x = std::clamp(pt.x, 0, m_srcImageWidth-1);
|
||||
pt.y = std::clamp(pt.y, 0, m_srcImageHeight-1);
|
||||
|
||||
m_color = get_pixel(m_srcImage, pt.x, pt.y);
|
||||
}
|
||||
|
@ -139,8 +139,8 @@ public:
|
||||
}
|
||||
|
||||
// Dynamic size and angle
|
||||
int size = base::clamp(int(pt.size), int(Brush::kMinBrushSize), int(Brush::kMaxBrushSize));
|
||||
int angle = base::clamp(int(pt.angle), -180, 180);
|
||||
int size = std::clamp(int(pt.size), int(Brush::kMinBrushSize), int(Brush::kMaxBrushSize));
|
||||
int angle = std::clamp(int(pt.angle), -180, 180);
|
||||
if ((brush->size() != size) ||
|
||||
(brush->angle() != angle && m_origBrushType != kCircleBrushType) ||
|
||||
(m_hasDynamicGradient && pt.gradient != m_lastGradientValue)) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -20,7 +20,6 @@
|
||||
#include "app/tools/symmetry.h"
|
||||
#include "app/tools/tool_loop.h"
|
||||
#include "app/tools/velocity.h"
|
||||
#include "base/clamp.h"
|
||||
#include "doc/brush.h"
|
||||
#include "doc/image.h"
|
||||
#include "doc/primitives.h"
|
||||
@ -29,6 +28,7 @@
|
||||
#include "gfx/rect_io.h"
|
||||
#include "gfx/region.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <climits>
|
||||
|
||||
#define TOOL_TRACE(...) // TRACEARGS
|
||||
@ -421,11 +421,11 @@ void ToolLoopManager::adjustPointWithDynamics(const Pointer& pointer,
|
||||
}
|
||||
}
|
||||
ASSERT(p >= 0.0f && p <= 1.0f);
|
||||
p = base::clamp(p, 0.0f, 1.0f);
|
||||
p = std::clamp(p, 0.0f, 1.0f);
|
||||
|
||||
// Velocity
|
||||
float v = pointer.velocity().magnitude() / VelocitySensor::kScreenPixelsForFullVelocity;
|
||||
v = base::clamp(v, 0.0f, 1.0f);
|
||||
v = std::clamp(v, 0.0f, 1.0f);
|
||||
if (v < m_dynamics.minVelocityThreshold) {
|
||||
v = 0.0f;
|
||||
}
|
||||
@ -440,7 +440,7 @@ void ToolLoopManager::adjustPointWithDynamics(const Pointer& pointer,
|
||||
(m_dynamics.maxVelocityThreshold - m_dynamics.minVelocityThreshold);
|
||||
}
|
||||
ASSERT(v >= 0.0f && v <= 1.0f);
|
||||
v = base::clamp(v, 0.0f, 1.0f);
|
||||
v = std::clamp(v, 0.0f, 1.0f);
|
||||
|
||||
switch (m_dynamics.size) {
|
||||
case DynamicSensor::Pressure:
|
||||
@ -469,8 +469,8 @@ void ToolLoopManager::adjustPointWithDynamics(const Pointer& pointer,
|
||||
break;
|
||||
}
|
||||
|
||||
pt.size = base::clamp(size, int(Brush::kMinBrushSize), int(Brush::kMaxBrushSize));
|
||||
pt.angle = base::clamp(angle, -180, 180);
|
||||
pt.size = std::clamp(size, int(Brush::kMinBrushSize), int(Brush::kMaxBrushSize));
|
||||
pt.angle = std::clamp(angle, -180, 180);
|
||||
}
|
||||
|
||||
} // namespace tools
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2020 Igara Studio S.A.
|
||||
// Copyright (C) 2020-2022 Igara Studio S.A.
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -10,7 +10,7 @@
|
||||
|
||||
#include "app/tools/velocity.h"
|
||||
|
||||
#include "base/clamp.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace app {
|
||||
namespace tools {
|
||||
@ -39,7 +39,7 @@ void VelocitySensor::updateWithScreenPoint(const gfx::Point& screenPoint)
|
||||
else {
|
||||
gfx::PointF newVelocity(screenPoint - m_lastPoint);
|
||||
|
||||
const float a = base::clamp(float(dt) / kFullUpdateMSecs, 0.0f, 1.0f);
|
||||
const float a = std::clamp(float(dt) / kFullUpdateMSecs, 0.0f, 1.0f);
|
||||
m_velocity.x = (1.0f-a)*m_velocity.x + a*newVelocity.x;
|
||||
m_velocity.y = (1.0f-a)*m_velocity.y + a*newVelocity.y;
|
||||
}
|
||||
|
@ -50,7 +50,6 @@
|
||||
#include "app/ui_context.h"
|
||||
#include "app/ui_context.h"
|
||||
#include "app/util/clipboard.h"
|
||||
#include "base/clamp.h"
|
||||
#include "base/scoped_value.h"
|
||||
#include "doc/cel.h"
|
||||
#include "doc/cels_range.h"
|
||||
@ -1232,7 +1231,7 @@ void ColorBar::fixColorIndex(ColorButton& colorButton)
|
||||
|
||||
if (color.getType() == Color::IndexType) {
|
||||
int oldIndex = color.getIndex();
|
||||
int newIndex = base::clamp(oldIndex, 0, get_current_palette()->size()-1);
|
||||
int newIndex = std::clamp(oldIndex, 0, get_current_palette()->size()-1);
|
||||
if (oldIndex != newIndex) {
|
||||
color = Color::fromIndex(newIndex);
|
||||
colorButton.setColor(color);
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "app/ui/skin/skin_theme.h"
|
||||
#include "app/ui/status_bar.h"
|
||||
#include "app/ui_context.h"
|
||||
#include "base/clamp.h"
|
||||
#include "doc/layer.h"
|
||||
#include "doc/sprite.h"
|
||||
#include "gfx/rect_io.h"
|
||||
@ -312,7 +311,7 @@ void ColorButton::openPopup(const bool forcePinned)
|
||||
if (!pinned || (forcePinned && m_hiddenPopupBounds.isEmpty())) {
|
||||
winBounds = gfx::Rect(m_window->bounds().origin(),
|
||||
m_window->sizeHint());
|
||||
winBounds.x = base::clamp(bounds().x, 0, ui::display_w()-winBounds.w);
|
||||
winBounds.x = std::clamp(bounds().x, 0, ui::display_w()-winBounds.w);
|
||||
if (bounds().y2() <= ui::display_h()-winBounds.h)
|
||||
winBounds.y = std::max(0, bounds().y2());
|
||||
else
|
||||
@ -324,8 +323,8 @@ void ColorButton::openPopup(const bool forcePinned)
|
||||
else {
|
||||
winBounds = m_windowDefaultBounds;
|
||||
}
|
||||
winBounds.x = base::clamp(winBounds.x, 0, ui::display_w()-winBounds.w);
|
||||
winBounds.y = base::clamp(winBounds.y, 0, ui::display_h()-winBounds.h);
|
||||
winBounds.x = std::clamp(winBounds.x, 0, ui::display_w()-winBounds.w);
|
||||
winBounds.y = std::clamp(winBounds.y, 0, ui::display_h()-winBounds.h);
|
||||
m_window->setBounds(winBounds);
|
||||
|
||||
m_window->manager()->dispatchMessages();
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "app/ui/skin/skin_theme.h"
|
||||
#include "app/ui/status_bar.h"
|
||||
#include "app/util/shader_helpers.h"
|
||||
#include "base/clamp.h"
|
||||
#include "base/concurrent_queue.h"
|
||||
#include "base/scoped_value.h"
|
||||
#include "base/thread.h"
|
||||
@ -299,7 +298,7 @@ app::Color ColorSelector::getAlphaBarColor(const int u, const int umax)
|
||||
{
|
||||
int alpha = (255 * u / umax);
|
||||
app::Color color = m_color;
|
||||
color.setAlpha(base::clamp(alpha, 0, 255));
|
||||
color.setAlpha(std::clamp(alpha, 0, 255));
|
||||
return color;
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include "app/shade.h"
|
||||
#include "app/ui/color_bar.h"
|
||||
#include "app/ui/skin/skin_theme.h"
|
||||
#include "base/clamp.h"
|
||||
#include "doc/color_mode.h"
|
||||
#include "doc/palette.h"
|
||||
#include "doc/palette_picks.h"
|
||||
@ -27,8 +26,8 @@
|
||||
#include "ui/paint_event.h"
|
||||
#include "ui/size_hint_event.h"
|
||||
#include "ui/system.h"
|
||||
#include <algorithm>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace app {
|
||||
|
||||
@ -213,7 +212,7 @@ bool ColorShades::onProcessMessage(ui::Message* msg)
|
||||
int count = std::max(1, size());
|
||||
int boxWidth = std::max(1, bounds.w / count);
|
||||
hot = (mousePos.x - bounds.x) / boxWidth;
|
||||
hot = base::clamp(hot, 0, count-1);
|
||||
hot = std::clamp(hot, 0, count-1);
|
||||
}
|
||||
|
||||
if (m_hotIndex != hot) {
|
||||
|
@ -185,7 +185,7 @@ namespace {
|
||||
else
|
||||
++value;
|
||||
|
||||
setTextf("%d", base::clamp(value, minValue(), maxValue()));
|
||||
setTextf("%d", std::clamp(value, minValue(), maxValue()));
|
||||
selectAllText();
|
||||
|
||||
onChange();
|
||||
@ -461,7 +461,7 @@ void ColorSliders::onEntryChange(const Channel i)
|
||||
Slider* slider = (m_mode == Mode::Absolute ?
|
||||
m_items[i].absSlider:
|
||||
m_items[i].relSlider);
|
||||
value = base::clamp(value, slider->getMinValue(), slider->getMaxValue());
|
||||
value = std::clamp(value, slider->getMinValue(), slider->getMaxValue());
|
||||
slider->setValue(value);
|
||||
|
||||
onControlChange(i);
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include "app/ui/skin/skin_theme.h"
|
||||
#include "app/ui/status_bar.h"
|
||||
#include "app/util/shader_helpers.h"
|
||||
#include "base/clamp.h"
|
||||
#include "os/surface.h"
|
||||
#include "ui/graphics.h"
|
||||
#include "ui/message.h"
|
||||
@ -88,9 +87,9 @@ app::Color ColorSpectrum::getMainAreaColor(const int u, const int umax,
|
||||
double hue = 360.0 * u / umax;
|
||||
double lit = 1.0 - (double(v)/double(vmax));
|
||||
return app::Color::fromHsl(
|
||||
base::clamp(hue, 0.0, 360.0),
|
||||
std::clamp(hue, 0.0, 360.0),
|
||||
m_color.getHslSaturation(),
|
||||
base::clamp(lit, 0.0, 1.0),
|
||||
std::clamp(lit, 0.0, 1.0),
|
||||
getCurrentAlphaForNewColor());
|
||||
}
|
||||
|
||||
@ -99,7 +98,7 @@ app::Color ColorSpectrum::getBottomBarColor(const int u, const int umax)
|
||||
double sat = double(u) / double(umax);
|
||||
return app::Color::fromHsl(
|
||||
m_color.getHslHue(),
|
||||
base::clamp(sat, 0.0, 1.0),
|
||||
std::clamp(sat, 0.0, 1.0),
|
||||
m_color.getHslLightness(),
|
||||
getCurrentAlphaForNewColor());
|
||||
}
|
||||
@ -147,9 +146,9 @@ void ColorSpectrum::onPaintSurfaceInBgThread(
|
||||
|
||||
gfx::Color color = color_utils::color_for_ui(
|
||||
app::Color::fromHsl(
|
||||
base::clamp(hue, 0.0, 360.0),
|
||||
std::clamp(hue, 0.0, 360.0),
|
||||
sat,
|
||||
base::clamp(lit, 0.0, 1.0)));
|
||||
std::clamp(lit, 0.0, 1.0)));
|
||||
|
||||
s->putPixel(color, main.x+x, main.y+y);
|
||||
}
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include "app/color_utils.h"
|
||||
#include "app/ui/skin/skin_theme.h"
|
||||
#include "app/util/shader_helpers.h"
|
||||
#include "base/clamp.h"
|
||||
#include "ui/graphics.h"
|
||||
|
||||
#include <algorithm>
|
||||
@ -84,8 +83,8 @@ app::Color ColorTintShadeTone::getMainAreaColor(const int u, const int umax,
|
||||
double val = (1.0 - double(v) / double(vmax));
|
||||
return app::Color::fromHsv(
|
||||
m_color.getHsvHue(),
|
||||
base::clamp(sat, 0.0, 1.0),
|
||||
base::clamp(val, 0.0, 1.0),
|
||||
std::clamp(sat, 0.0, 1.0),
|
||||
std::clamp(val, 0.0, 1.0),
|
||||
getCurrentAlphaForNewColor());
|
||||
}
|
||||
|
||||
@ -93,7 +92,7 @@ app::Color ColorTintShadeTone::getBottomBarColor(const int u, const int umax)
|
||||
{
|
||||
double hue = (360.0 * u / umax);
|
||||
return app::Color::fromHsv(
|
||||
base::clamp(hue, 0.0, 360.0),
|
||||
std::clamp(hue, 0.0, 360.0),
|
||||
m_color.getHsvSaturation(),
|
||||
m_color.getHsvValue(),
|
||||
getCurrentAlphaForNewColor());
|
||||
@ -141,8 +140,8 @@ void ColorTintShadeTone::onPaintSurfaceInBgThread(
|
||||
gfx::Color color = color_utils::color_for_ui(
|
||||
app::Color::fromHsv(
|
||||
hue,
|
||||
base::clamp(sat, 0.0, 1.0),
|
||||
base::clamp(val, 0.0, 1.0)));
|
||||
std::clamp(sat, 0.0, 1.0),
|
||||
std::clamp(val, 0.0, 1.0)));
|
||||
|
||||
s->putPixel(color, main.x+x, main.y+y);
|
||||
}
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include "app/ui/skin/skin_theme.h"
|
||||
#include "app/ui/status_bar.h"
|
||||
#include "app/util/shader_helpers.h"
|
||||
#include "base/clamp.h"
|
||||
#include "base/pi.h"
|
||||
#include "os/surface.h"
|
||||
#include "ui/graphics.h"
|
||||
@ -236,9 +235,9 @@ app::Color ColorWheel::getMainAreaColor(const int _u, const int umax,
|
||||
int b = 255 - di;
|
||||
if (d <= m_wheelRadius) {
|
||||
return app::Color::fromRgb(
|
||||
base::clamp(r, 0, 255),
|
||||
base::clamp(g, 0, 255),
|
||||
base::clamp(b, 128, 255));
|
||||
std::clamp(r, 0, 255),
|
||||
std::clamp(g, 0, 255),
|
||||
std::clamp(b, 128, 255));
|
||||
}
|
||||
else {
|
||||
return app::Color::fromRgb(128, 128, 255);
|
||||
@ -272,8 +271,8 @@ app::Color ColorWheel::getMainAreaColor(const int _u, const int umax,
|
||||
}
|
||||
|
||||
return app::Color::fromHsv(
|
||||
base::clamp(hue, 0, 360),
|
||||
base::clamp(sat / 100.0, 0.0, 1.0),
|
||||
std::clamp(hue, 0, 360),
|
||||
std::clamp(sat / 100.0, 0.0, 1.0),
|
||||
(m_color.getType() != Color::MaskType ? m_color.getHsvValue(): 1.0),
|
||||
getCurrentAlphaForNewColor());
|
||||
}
|
||||
@ -287,7 +286,7 @@ app::Color ColorWheel::getBottomBarColor(const int u, const int umax)
|
||||
return app::Color::fromHsv(
|
||||
m_color.getHsvHue(),
|
||||
m_color.getHsvSaturation(),
|
||||
base::clamp(val, 0.0, 1.0),
|
||||
std::clamp(val, 0.0, 1.0),
|
||||
getCurrentAlphaForNewColor());
|
||||
}
|
||||
|
||||
@ -306,7 +305,7 @@ void ColorWheel::onPaintMainArea(ui::Graphics* g, const gfx::Rect& rc)
|
||||
double angle = std::atan2(m_color.getGreen()-128,
|
||||
m_color.getRed()-128);
|
||||
double dist = (255-m_color.getBlue()) / 128.0;
|
||||
dist = base::clamp(dist, 0.0, 1.0);
|
||||
dist = std::clamp(dist, 0.0, 1.0);
|
||||
|
||||
gfx::Point pos =
|
||||
m_wheelBounds.center() +
|
||||
@ -450,18 +449,18 @@ void ColorWheel::setHarmony(Harmony harmony)
|
||||
|
||||
int ColorWheel::getHarmonies() const
|
||||
{
|
||||
int i = base::clamp((int)m_harmony, 0, (int)Harmony::LAST);
|
||||
int i = std::clamp((int)m_harmony, 0, (int)Harmony::LAST);
|
||||
return harmonies[i].n;
|
||||
}
|
||||
|
||||
app::Color ColorWheel::getColorInHarmony(int j) const
|
||||
{
|
||||
int i = base::clamp((int)m_harmony, 0, (int)Harmony::LAST);
|
||||
j = base::clamp(j, 0, harmonies[i].n-1);
|
||||
int i = std::clamp((int)m_harmony, 0, (int)Harmony::LAST);
|
||||
j = std::clamp(j, 0, harmonies[i].n-1);
|
||||
double hue = convertHueAngle(m_color.getHsvHue(), -1) + harmonies[i].hues[j];
|
||||
double sat = m_color.getHsvSaturation() * harmonies[i].sats[j] / 100.0;
|
||||
return app::Color::fromHsv(std::fmod(hue, 360),
|
||||
base::clamp(sat, 0.0, 1.0),
|
||||
std::clamp(sat, 0.0, 1.0),
|
||||
m_color.getHsvValue());
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,6 @@
|
||||
#include "app/ui/selection_mode_field.h"
|
||||
#include "app/ui/skin/skin_theme.h"
|
||||
#include "app/ui_context.h"
|
||||
#include "base/clamp.h"
|
||||
#include "base/fs.h"
|
||||
#include "base/scoped_value.h"
|
||||
#include "doc/brush.h"
|
||||
@ -643,7 +642,7 @@ private:
|
||||
|
||||
char buf[32];
|
||||
int n = get_config_int("shades", "count", 0);
|
||||
n = base::clamp(n, 0, 256);
|
||||
n = std::clamp(n, 0, 256);
|
||||
for (int i=0; i<n; ++i) {
|
||||
sprintf(buf, "shade%d", i);
|
||||
Shade shade = shade_from_string(get_config_string("shades", buf, ""));
|
||||
|
@ -12,7 +12,6 @@
|
||||
|
||||
#include "app/ui/dithering_selector.h"
|
||||
#include "app/ui/skin/skin_theme.h"
|
||||
#include "base/clamp.h"
|
||||
#include "os/font.h"
|
||||
#include "os/surface.h"
|
||||
#include "ui/message.h"
|
||||
@ -163,7 +162,7 @@ private:
|
||||
auto mouseMsg = static_cast<MouseMessage*>(msg);
|
||||
const gfx::Rect rc = bounds();
|
||||
float u = (mouseMsg->position().x - rc.x) / float(rc.w);
|
||||
u = base::clamp(u, 0.0f, 1.0f);
|
||||
u = std::clamp(u, 0.0f, 1.0f);
|
||||
switch (capture) {
|
||||
case Capture::Min:
|
||||
m_minThreshold = u;
|
||||
@ -434,7 +433,7 @@ bool DynamicsPopup::onProcessMessage(Message* msg)
|
||||
|
||||
float v = m_velocity.velocity().magnitude()
|
||||
/ tools::VelocitySensor::kScreenPixelsForFullVelocity;
|
||||
v = base::clamp(v, 0.0f, 1.0f);
|
||||
v = std::clamp(v, 0.0f, 1.0f);
|
||||
|
||||
m_velocityThreshold->setSensorValue(v);
|
||||
}
|
||||
|
@ -54,7 +54,6 @@
|
||||
#include "app/util/conversion_to_surface.h"
|
||||
#include "app/util/layer_utils.h"
|
||||
#include "base/chrono.h"
|
||||
#include "base/clamp.h"
|
||||
#include "base/convert_to.h"
|
||||
#include "doc/doc.h"
|
||||
#include "doc/mask_boundaries.h"
|
||||
@ -596,8 +595,8 @@ void Editor::drawOneSpriteUnclippedRect(ui::Graphics* g, const gfx::Rect& sprite
|
||||
|
||||
const int maxw = std::max(0, m_sprite->width()-expose.x);
|
||||
const int maxh = std::max(0, m_sprite->height()-expose.y);
|
||||
expose.w = base::clamp(expose.w, 0, maxw);
|
||||
expose.h = base::clamp(expose.h, 0, maxh);
|
||||
expose.w = std::clamp(expose.w, 0, maxw);
|
||||
expose.h = std::clamp(expose.h, 0, maxh);
|
||||
if (expose.isEmpty())
|
||||
return;
|
||||
|
||||
@ -773,7 +772,7 @@ void Editor::drawOneSpriteUnclippedRect(ui::Graphics* g, const gfx::Rect& sprite
|
||||
|
||||
if (m_docPref.pixelGrid.autoOpacity()) {
|
||||
alpha = int(alpha * (m_proj.zoom().scale()-2.) / (16.-2.));
|
||||
alpha = base::clamp(alpha, 0, 255);
|
||||
alpha = std::clamp(alpha, 0, 255);
|
||||
}
|
||||
|
||||
drawGrid(g, enclosingRect, Rect(0, 0, 1, 1),
|
||||
@ -795,7 +794,7 @@ void Editor::drawOneSpriteUnclippedRect(ui::Graphics* g, const gfx::Rect& sprite
|
||||
double len = (m_proj.applyX(gridrc.w) +
|
||||
m_proj.applyY(gridrc.h)) / 2.;
|
||||
alpha = int(alpha * len / 32.);
|
||||
alpha = base::clamp(alpha, 0, 255);
|
||||
alpha = std::clamp(alpha, 0, 255);
|
||||
}
|
||||
|
||||
if (alpha > 8) {
|
||||
@ -1379,8 +1378,8 @@ gfx::Point Editor::autoScroll(const ui::MouseMessage* msg,
|
||||
|
||||
m_oldPos = mousePos;
|
||||
mousePos = gfx::Point(
|
||||
base::clamp(mousePos.x, vp.x, vp.x2()-1),
|
||||
base::clamp(mousePos.y, vp.y, vp.y2()-1));
|
||||
std::clamp(mousePos.x, vp.x, vp.x2()-1),
|
||||
std::clamp(mousePos.y, vp.y, vp.y2()-1));
|
||||
}
|
||||
else
|
||||
m_oldPos = mousePos;
|
||||
@ -2422,8 +2421,8 @@ void Editor::setZoomAndCenterInMouse(const Zoom& zoom,
|
||||
// extra space for the zoom)
|
||||
gfx::Rect visibleBounds = editorToScreen(
|
||||
getViewportBounds().createIntersection(gfx::Rect(gfx::Point(0, 0), canvasSize())));
|
||||
screenPos.x = base::clamp(screenPos.x, visibleBounds.x, visibleBounds.x2()-1);
|
||||
screenPos.y = base::clamp(screenPos.y, visibleBounds.y, visibleBounds.y2()-1);
|
||||
screenPos.x = std::clamp(screenPos.x, visibleBounds.x, visibleBounds.x2()-1);
|
||||
screenPos.y = std::clamp(screenPos.y, visibleBounds.y, visibleBounds.y2()-1);
|
||||
|
||||
spritePos = screenToEditor(screenPos);
|
||||
|
||||
@ -2509,7 +2508,7 @@ void Editor::pasteImage(const Image* image, const Mask* mask)
|
||||
// In other case, if the center is visible, we put the pasted
|
||||
// image in its original location.
|
||||
else {
|
||||
x = base::clamp(x, visibleBounds.x-image->width(), visibleBounds.x2()-1);
|
||||
x = std::clamp(x, visibleBounds.x-image->width(), visibleBounds.x2()-1);
|
||||
}
|
||||
|
||||
if (maskCenter.y < visibleBounds.y ||
|
||||
@ -2517,7 +2516,7 @@ void Editor::pasteImage(const Image* image, const Mask* mask)
|
||||
y = visibleBounds.y + visibleBounds.h/2 - image->height()/2;
|
||||
}
|
||||
else {
|
||||
y = base::clamp(y, visibleBounds.y-image->height(), visibleBounds.y2()-1);
|
||||
y = std::clamp(y, visibleBounds.y-image->height(), visibleBounds.y2()-1);
|
||||
}
|
||||
|
||||
// Limit the image inside the sprite's bounds.
|
||||
@ -2525,13 +2524,13 @@ void Editor::pasteImage(const Image* image, const Mask* mask)
|
||||
sprite->height() <= image->height()) {
|
||||
// TODO review this (I think limits are wrong and high limit can
|
||||
// be negative here)
|
||||
x = base::clamp(x, 0, sprite->width() - image->width());
|
||||
y = base::clamp(y, 0, sprite->height() - image->height());
|
||||
x = std::clamp(x, 0, sprite->width() - image->width());
|
||||
y = std::clamp(y, 0, sprite->height() - image->height());
|
||||
}
|
||||
else {
|
||||
// Also we always limit the 1 image pixel inside the sprite's bounds.
|
||||
x = base::clamp(x, -image->width()+1, sprite->width()-1);
|
||||
y = base::clamp(y, -image->height()+1, sprite->height()-1);
|
||||
x = std::clamp(x, -image->width()+1, sprite->width()-1);
|
||||
y = std::clamp(y, -image->height()+1, sprite->height()-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2020 Igara Studio S.A.
|
||||
// Copyright (C) 2020-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2015-2016 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -13,7 +13,6 @@
|
||||
|
||||
#include "app/ui/editor/editor.h"
|
||||
#include "app/ui/status_bar.h"
|
||||
#include "base/clamp.h"
|
||||
#include "fmt/format.h"
|
||||
#include "ui/message.h"
|
||||
|
||||
@ -51,12 +50,12 @@ bool MovingSymmetryState::onMouseMove(Editor* editor, MouseMessage* msg)
|
||||
case app::gen::SymmetryMode::HORIZONTAL:
|
||||
pos = m_symmetryAxisStart + delta.x;
|
||||
pos = std::round(pos*2.0)/2.0;
|
||||
pos = base::clamp(pos, 1.0, editor->sprite()->width()-1.0);
|
||||
pos = std::clamp(pos, 1.0, editor->sprite()->width()-1.0);
|
||||
break;
|
||||
case app::gen::SymmetryMode::VERTICAL:
|
||||
pos = m_symmetryAxisStart + delta.y;
|
||||
pos = std::round(pos*2.0)/2.0;
|
||||
pos = base::clamp(pos, 1.0, editor->sprite()->height()-1.0);
|
||||
pos = std::clamp(pos, 1.0, editor->sprite()->height()-1.0);
|
||||
break;
|
||||
}
|
||||
m_symmetryAxis(pos);
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2020 Igara Studio S.A.
|
||||
// Copyright (C) 2020-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -24,7 +24,6 @@
|
||||
#include "app/ui/keyboard_shortcuts.h"
|
||||
#include "app/ui/toolbar.h"
|
||||
#include "app/ui_context.h"
|
||||
#include "base/clamp.h"
|
||||
#include "base/string.h"
|
||||
#include "doc/brush.h"
|
||||
#include "doc/layer.h"
|
||||
@ -117,7 +116,7 @@ bool StateWithWheelBehavior::onMouseWheel(Editor* editor, MouseMessage* msg)
|
||||
case WheelAction::FgColor: {
|
||||
int lastIndex = get_current_palette()->size()-1;
|
||||
int newIndex = ColorBar::instance()->getFgColor().getIndex() + int(dz);
|
||||
newIndex = base::clamp(newIndex, 0, lastIndex);
|
||||
newIndex = std::clamp(newIndex, 0, lastIndex);
|
||||
ColorBar::instance()->setFgColor(app::Color::fromIndex(newIndex));
|
||||
break;
|
||||
}
|
||||
@ -125,7 +124,7 @@ bool StateWithWheelBehavior::onMouseWheel(Editor* editor, MouseMessage* msg)
|
||||
case WheelAction::BgColor: {
|
||||
int lastIndex = get_current_palette()->size()-1;
|
||||
int newIndex = ColorBar::instance()->getBgColor().getIndex() + int(dz);
|
||||
newIndex = base::clamp(newIndex, 0, lastIndex);
|
||||
newIndex = std::clamp(newIndex, 0, lastIndex);
|
||||
ColorBar::instance()->setBgColor(app::Color::fromIndex(newIndex));
|
||||
break;
|
||||
}
|
||||
@ -203,7 +202,7 @@ bool StateWithWheelBehavior::onMouseWheel(Editor* editor, MouseMessage* msg)
|
||||
dz = -dz;
|
||||
|
||||
brush.size(
|
||||
base::clamp(
|
||||
std::clamp(
|
||||
int(brush.size()+dz),
|
||||
// If we use the "static const int" member directly here,
|
||||
// we'll get a linker error (when compiling without
|
||||
@ -224,7 +223,7 @@ bool StateWithWheelBehavior::onMouseWheel(Editor* editor, MouseMessage* msg)
|
||||
angle += 180;
|
||||
angle %= 181;
|
||||
|
||||
brush.angle(base::clamp(angle, 0, 180));
|
||||
brush.angle(std::clamp(angle, 0, 180));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -295,7 +294,7 @@ bool StateWithWheelBehavior::onMouseWheel(Editor* editor, MouseMessage* msg)
|
||||
tools::Tool* tool = getActiveTool();
|
||||
auto& toolPref = Preferences::instance().tool(tool);
|
||||
int opacity = toolPref.opacity();
|
||||
opacity = base::clamp(int(opacity+dz*255/10), 0, 255);
|
||||
opacity = std::clamp(int(opacity+dz*255/10), 0, 255);
|
||||
toolPref.opacity(opacity);
|
||||
break;
|
||||
}
|
||||
@ -308,7 +307,7 @@ bool StateWithWheelBehavior::onMouseWheel(Editor* editor, MouseMessage* msg)
|
||||
Command* command = Commands::instance()->byId(CommandId::LayerOpacity());
|
||||
if (command) {
|
||||
int opacity = static_cast<doc::LayerImage*>(site.layer())->opacity();
|
||||
opacity = base::clamp(int(opacity+dz*255/10), 0, 255);
|
||||
opacity = std::clamp(int(opacity+dz*255/10), 0, 255);
|
||||
|
||||
Params params;
|
||||
params.set("opacity",
|
||||
@ -328,7 +327,7 @@ bool StateWithWheelBehavior::onMouseWheel(Editor* editor, MouseMessage* msg)
|
||||
Command* command = Commands::instance()->byId(CommandId::CelOpacity());
|
||||
if (command) {
|
||||
int opacity = site.cel()->opacity();
|
||||
opacity = base::clamp(int(opacity+dz*255/10), 0, 255);
|
||||
opacity = std::clamp(int(opacity+dz*255/10), 0, 255);
|
||||
Params params;
|
||||
params.set("opacity",
|
||||
base::convert_to<std::string>(opacity).c_str());
|
||||
@ -344,7 +343,7 @@ bool StateWithWheelBehavior::onMouseWheel(Editor* editor, MouseMessage* msg)
|
||||
ColorBar* colorBar = ColorBar::instance();
|
||||
Color c = colorBar->getFgColor();
|
||||
int a = c.getAlpha();
|
||||
a = base::clamp(int(a+dz*255/10), 0, 255);
|
||||
a = std::clamp(int(a+dz*255/10), 0, 255);
|
||||
c.setAlpha(a);
|
||||
colorBar->setFgColor(c);
|
||||
break;
|
||||
@ -366,9 +365,9 @@ bool StateWithWheelBehavior::onMouseWheel(Editor* editor, MouseMessage* msg)
|
||||
case WheelAction::HslSaturation: s = s+dz/10.0; break;
|
||||
case WheelAction::HslLightness: l = l+dz/10.0; break;
|
||||
}
|
||||
colorBar->setFgColor(Color::fromHsl(base::clamp(h, 0.0, 360.0),
|
||||
base::clamp(s, 0.0, 1.0),
|
||||
base::clamp(l, 0.0, 1.0)));
|
||||
colorBar->setFgColor(Color::fromHsl(std::clamp(h, 0.0, 360.0),
|
||||
std::clamp(s, 0.0, 1.0),
|
||||
std::clamp(l, 0.0, 1.0)));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -388,9 +387,9 @@ bool StateWithWheelBehavior::onMouseWheel(Editor* editor, MouseMessage* msg)
|
||||
case WheelAction::HsvSaturation: s = s+dz/10.0; break;
|
||||
case WheelAction::HsvValue: v = v+dz/10.0; break;
|
||||
}
|
||||
colorBar->setFgColor(Color::fromHsv(base::clamp(h, 0.0, 360.0),
|
||||
base::clamp(s, 0.0, 1.0),
|
||||
base::clamp(v, 0.0, 1.0)));
|
||||
colorBar->setFgColor(Color::fromHsv(std::clamp(h, 0.0, 360.0),
|
||||
std::clamp(s, 0.0, 1.0),
|
||||
std::clamp(v, 0.0, 1.0)));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include "app/modules/gfx.h"
|
||||
#include "app/thumbnail_generator.h"
|
||||
#include "app/ui/skin/skin_theme.h"
|
||||
#include "base/clamp.h"
|
||||
#include "base/string.h"
|
||||
#include "base/time.h"
|
||||
#include "os/font.h"
|
||||
@ -159,7 +158,7 @@ void FileList::goUp()
|
||||
|
||||
void FileList::setZoom(const double zoom)
|
||||
{
|
||||
m_zoom = base::clamp(zoom, 1.0, 8.0);
|
||||
m_zoom = std::clamp(zoom, 1.0, 8.0);
|
||||
m_req_valid = false;
|
||||
|
||||
// if (auto view = View::getView(this))
|
||||
@ -358,7 +357,7 @@ bool FileList::onProcessMessage(Message* msg)
|
||||
}
|
||||
|
||||
if (bottom > 0)
|
||||
selectIndex(base::clamp(select, 0, bottom-1));
|
||||
selectIndex(std::clamp(select, 0, bottom-1));
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -620,7 +619,7 @@ gfx::Rect FileList::mainThumbnailBounds()
|
||||
gfx::Rect vp = view->viewportBounds();
|
||||
int x = vp.x+vp.w - 2*guiscale() - thumbnail->width();
|
||||
int y = info.bounds.center().y - thumbnail->height()/2 + bounds().y;
|
||||
y = base::clamp(y, vp.y+2*guiscale(), vp.y+vp.h-3*guiscale()-thumbnail->height());
|
||||
y = std::clamp(y, vp.y+2*guiscale(), vp.y+vp.h-3*guiscale()-thumbnail->height());
|
||||
x -= bounds().x;
|
||||
y -= bounds().y;
|
||||
return gfx::Rect(x, y, thumbnail->width(), thumbnail->height());
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "app/ui/separator_in_view.h"
|
||||
#include "app/ui/skin/skin_theme.h"
|
||||
#include "app/widget_loader.h"
|
||||
#include "base/clamp.h"
|
||||
#include "base/convert_to.h"
|
||||
#include "base/fs.h"
|
||||
#include "base/paths.h"
|
||||
@ -128,7 +127,7 @@ void adjust_navigation_history(IFileItem* item)
|
||||
}
|
||||
|
||||
if (valid && !navigation_history.empty()) {
|
||||
pos = base::clamp(pos, 0, (int)navigation_history.size()-1);
|
||||
pos = std::clamp(pos, 0, (int)navigation_history.size()-1);
|
||||
navigation_position.set(navigation_history.begin() + pos);
|
||||
|
||||
FILESEL_TRACE("FILESEL: New navigation pos [%d] = %s\n",
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "app/ui/status_bar.h"
|
||||
#include "app/util/clipboard.h"
|
||||
#include "app/util/pal_ops.h"
|
||||
#include "base/clamp.h"
|
||||
#include "base/convert_to.h"
|
||||
#include "doc/image.h"
|
||||
#include "doc/palette.h"
|
||||
@ -221,7 +220,7 @@ int PaletteView::getBoxSize() const
|
||||
|
||||
void PaletteView::setBoxSize(double boxsize)
|
||||
{
|
||||
m_boxsize = base::clamp(boxsize, 4.0, 32.0);
|
||||
m_boxsize = std::clamp(boxsize, 4.0, 32.0);
|
||||
|
||||
if (m_delegate)
|
||||
m_delegate->onPaletteViewChangeSize(int(m_boxsize));
|
||||
@ -349,7 +348,7 @@ bool PaletteView::onProcessMessage(Message* msg)
|
||||
if (m_state == State::SELECTING_COLOR &&
|
||||
m_hot.part == Hit::COLOR) {
|
||||
int idx = m_hot.color;
|
||||
idx = base::clamp(idx, 0, currentPalette()->size()-1);
|
||||
idx = std::clamp(idx, 0, currentPalette()->size()-1);
|
||||
|
||||
const MouseButton button = mouseMsg->button();
|
||||
|
||||
@ -790,7 +789,7 @@ PaletteView::Hit PaletteView::hitTest(const gfx::Point& pos)
|
||||
int colsLimit = m_columns;
|
||||
if (m_state == State::DRAGGING_OUTLINE)
|
||||
--colsLimit;
|
||||
int i = base::clamp((pos.x-vp.x)/box.w, 0, colsLimit)
|
||||
int i = std::clamp((pos.x-vp.x)/box.w, 0, colsLimit)
|
||||
+ std::max(0, pos.y/box.h)*m_columns;
|
||||
return Hit(Hit::POSSIBLE_COLOR, i);
|
||||
}
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include "app/ui/skin/skin_slider_property.h"
|
||||
#include "app/xml_document.h"
|
||||
#include "app/xml_exception.h"
|
||||
#include "base/clamp.h"
|
||||
#include "base/fs.h"
|
||||
#include "base/log.h"
|
||||
#include "base/string.h"
|
||||
@ -1694,7 +1693,7 @@ void SkinTheme::paintProgressBar(ui::Graphics* g, const gfx::Rect& rc0, double p
|
||||
rc.shrink(1);
|
||||
|
||||
int u = (int)((double)rc.w*progress);
|
||||
u = base::clamp(u, 0, rc.w);
|
||||
u = std::clamp(u, 0, rc.w);
|
||||
|
||||
if (u > 0)
|
||||
g->fillRect(colors.selected(), gfx::Rect(rc.x, rc.y, u, rc.h));
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2020 Igara Studio S.A.
|
||||
// Copyright (C) 2020-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2017 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -12,7 +12,6 @@
|
||||
#include "app/ui/slider2.h"
|
||||
|
||||
#include "app/ui/skin/skin_property.h"
|
||||
#include "base/clamp.h"
|
||||
#include "ui/manager.h"
|
||||
#include "ui/message.h"
|
||||
|
||||
@ -56,7 +55,7 @@ bool Slider2::Slider2Entry::onProcessMessage(ui::Message* msg)
|
||||
else
|
||||
++value;
|
||||
|
||||
setTextf("%d", base::clamp(value, minValue(), maxValue()));
|
||||
setTextf("%d", std::clamp(value, minValue(), maxValue()));
|
||||
selectAllText();
|
||||
|
||||
onChange();
|
||||
@ -119,7 +118,7 @@ void Slider2::onSliderChange()
|
||||
void Slider2::onEntryChange()
|
||||
{
|
||||
int v = m_entry.textInt();
|
||||
v = base::clamp(v, m_slider.getMinValue(), m_slider.getMaxValue());
|
||||
v = std::clamp(v, m_slider.getMinValue(), m_slider.getMaxValue());
|
||||
m_slider.setValue(v);
|
||||
|
||||
onChange();
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include "app/modules/gui.h"
|
||||
#include "app/ui/editor/editor_view.h"
|
||||
#include "app/ui/skin/skin_theme.h"
|
||||
#include "base/clamp.h"
|
||||
#include "os/font.h"
|
||||
#include "os/surface.h"
|
||||
#include "os/system.h"
|
||||
@ -259,7 +258,7 @@ void Tabs::setDropViewPreview(const gfx::Point& pos, TabView* view)
|
||||
|
||||
if (!m_list.empty()) {
|
||||
newIndex = (pos.x - bounds().x) / m_list[0]->width;
|
||||
newIndex = base::clamp(newIndex, 0, (int)m_list.size());
|
||||
newIndex = std::clamp(newIndex, 0, (int)m_list.size());
|
||||
}
|
||||
else
|
||||
newIndex = 0;
|
||||
@ -430,7 +429,7 @@ bool Tabs::onProcessMessage(Message* msg)
|
||||
if (it != m_list.end()) {
|
||||
int index = (it - m_list.begin());
|
||||
int newIndex = index + dz;
|
||||
newIndex = base::clamp(newIndex, 0, int(m_list.size())-1);
|
||||
newIndex = std::clamp(newIndex, 0, int(m_list.size())-1);
|
||||
if (newIndex != index) {
|
||||
selectTabInternal(m_list[newIndex]);
|
||||
}
|
||||
@ -997,14 +996,14 @@ void Tabs::updateDragTabIndexes(int mouseX, bool startAni)
|
||||
int i = (mouseX - m_border*guiscale() - bounds().x) / m_dragTab->width;
|
||||
|
||||
if (m_dragCopy) {
|
||||
i = base::clamp(i, 0, int(m_list.size()));
|
||||
i = std::clamp(i, 0, int(m_list.size()));
|
||||
if (i != m_dragCopyIndex) {
|
||||
m_dragCopyIndex = i;
|
||||
startAni = true;
|
||||
}
|
||||
}
|
||||
else if (hasMouseOver()) {
|
||||
i = base::clamp(i, 0, int(m_list.size())-1);
|
||||
i = std::clamp(i, 0, int(m_list.size())-1);
|
||||
if (i != m_dragTabIndex) {
|
||||
m_list.erase(m_list.begin()+m_dragTabIndex);
|
||||
m_list.insert(m_list.begin()+i, m_selected);
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -14,7 +14,6 @@
|
||||
#include "app/doc.h"
|
||||
#include "app/pref/preferences.h"
|
||||
#include "app/ui/layer_frame_comboboxes.h"
|
||||
#include "base/clamp.h"
|
||||
#include "doc/sprite.h"
|
||||
#include "doc/tag.h"
|
||||
|
||||
@ -54,8 +53,8 @@ void TagWindow::rangeValue(doc::frame_t& from, doc::frame_t& to)
|
||||
|
||||
from = this->from()->textInt()-m_base;
|
||||
to = this->to()->textInt()-m_base;
|
||||
from = base::clamp(from, first, last);
|
||||
to = base::clamp(to, from, last);
|
||||
from = std::clamp(from, first, last);
|
||||
to = std::clamp(to, from, last);
|
||||
}
|
||||
|
||||
doc::color_t TagWindow::colorValue()
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include "app/i18n/strings.h"
|
||||
#include "app/modules/gui.h"
|
||||
#include "app/ui/skin/skin_theme.h"
|
||||
#include "base/clamp.h"
|
||||
#include "ui/scale.h"
|
||||
|
||||
#include <limits>
|
||||
@ -56,9 +55,9 @@ TaskWidget::TaskWidget(const Type type,
|
||||
float v = m_task.progress();
|
||||
if (v > 0.0f) {
|
||||
TRACEARGS("progressBar setValue",
|
||||
int(base::clamp(v*100.0f, 0.0f, 100.0f)));
|
||||
int(std::clamp(v*100.0f, 0.0f, 100.0f)));
|
||||
m_progressBar.setValue(
|
||||
int(base::clamp(v*100.0f, 0.0f, 100.0f)));
|
||||
int(std::clamp(v*100.0f, 0.0f, 100.0f)));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -44,7 +44,6 @@
|
||||
#include "app/util/layer_boundaries.h"
|
||||
#include "app/util/layer_utils.h"
|
||||
#include "app/util/readable_time.h"
|
||||
#include "base/clamp.h"
|
||||
#include "base/convert_to.h"
|
||||
#include "base/memory.h"
|
||||
#include "base/scoped_value.h"
|
||||
@ -285,7 +284,7 @@ Timeline::~Timeline()
|
||||
|
||||
void Timeline::setZoom(const double zoom)
|
||||
{
|
||||
m_zoom = base::clamp(zoom, 1.0, 10.0);
|
||||
m_zoom = std::clamp(zoom, 1.0, 10.0);
|
||||
m_thumbnailsOverlayDirection = gfx::Point(int(frameBoxWidth()*1.0), int(frameBoxWidth()*0.5));
|
||||
m_thumbnailsOverlayVisible = false;
|
||||
}
|
||||
@ -958,7 +957,7 @@ bool Timeline::onProcessMessage(Message* msg)
|
||||
if (selectedLayersBounds(selectedLayers(),
|
||||
&layerFirst, &layerLast)) {
|
||||
layer_t layerIdx = m_clk.layer;
|
||||
layerIdx = base::clamp(layerIdx, layerFirst, layerLast);
|
||||
layerIdx = std::clamp(layerIdx, layerFirst, layerLast);
|
||||
m_clk.layer = layerIdx;
|
||||
}
|
||||
}
|
||||
@ -1905,11 +1904,11 @@ void Timeline::getDrawableLayers(layer_t* firstDrawableLayer,
|
||||
{
|
||||
layer_t i = lastLayer()
|
||||
- ((viewScroll().y + getCelsBounds().h) / layerBoxHeight());
|
||||
i = base::clamp(i, firstLayer(), lastLayer());
|
||||
i = std::clamp(i, firstLayer(), lastLayer());
|
||||
|
||||
layer_t j = lastLayer() - viewScroll().y / layerBoxHeight();;
|
||||
if (!m_rows.empty())
|
||||
j = base::clamp(j, firstLayer(), lastLayer());
|
||||
j = std::clamp(j, firstLayer(), lastLayer());
|
||||
else
|
||||
j = -1;
|
||||
|
||||
@ -2254,7 +2253,7 @@ void Timeline::drawCel(ui::Graphics* g, layer_t layerIndex, frame_t frame, Cel*
|
||||
|
||||
if (!thumb_bounds.isEmpty()) {
|
||||
if (os::SurfaceRef surface = thumb::get_cel_thumbnail(cel, thumb_bounds.size())) {
|
||||
const int t = base::clamp(thumb_bounds.w/8, 4, 16);
|
||||
const int t = std::clamp(thumb_bounds.w/8, 4, 16);
|
||||
draw_checked_grid(g, thumb_bounds, gfx::Size(t, t), docPref());
|
||||
|
||||
g->drawRgbaSurface(surface.get(),
|
||||
@ -2490,9 +2489,9 @@ void Timeline::drawTags(ui::Graphics* g)
|
||||
r = gfx::getr(bg)+32;
|
||||
g = gfx::getg(bg)+32;
|
||||
b = gfx::getb(bg)+32;
|
||||
r = base::clamp(r, 0, 255);
|
||||
g = base::clamp(g, 0, 255);
|
||||
b = base::clamp(b, 0, 255);
|
||||
r = std::clamp(r, 0, 255);
|
||||
g = std::clamp(g, 0, 255);
|
||||
b = std::clamp(b, 0, 255);
|
||||
bg = gfx::rgba(r, g, b, gfx::geta(bg));
|
||||
}
|
||||
g->fillRect(bg, bounds);
|
||||
@ -3090,11 +3089,11 @@ Timeline::Hit Timeline::hitTest(ui::Message* msg, const gfx::Point& mousePos)
|
||||
hit.veryBottom = true;
|
||||
|
||||
if (hasCapture()) {
|
||||
hit.layer = base::clamp(hit.layer, firstLayer(), lastLayer());
|
||||
hit.layer = std::clamp(hit.layer, firstLayer(), lastLayer());
|
||||
if (isMovingCel())
|
||||
hit.frame = std::max(firstFrame(), hit.frame);
|
||||
else
|
||||
hit.frame = base::clamp(hit.frame, firstFrame(), lastFrame());
|
||||
hit.frame = std::clamp(hit.frame, firstFrame(), lastFrame());
|
||||
}
|
||||
else {
|
||||
if (hit.layer > lastLayer()) hit.layer = -1;
|
||||
@ -3268,7 +3267,7 @@ Timeline::Hit Timeline::hitTestCel(const gfx::Point& mousePos)
|
||||
- m_separator_w
|
||||
+ scroll.x) / frameBoxWidth());
|
||||
|
||||
hit.layer = base::clamp(hit.layer, firstLayer(), lastLayer());
|
||||
hit.layer = std::clamp(hit.layer, firstLayer(), lastLayer());
|
||||
hit.frame = std::max(firstFrame(), hit.frame);
|
||||
|
||||
return hit;
|
||||
@ -3789,8 +3788,8 @@ void Timeline::setViewScroll(const gfx::Point& pt)
|
||||
const gfx::Point oldScroll = viewScroll();
|
||||
const gfx::Point maxPos = getMaxScrollablePos();
|
||||
gfx::Point newScroll = pt;
|
||||
newScroll.x = base::clamp(newScroll.x, 0, maxPos.x);
|
||||
newScroll.y = base::clamp(newScroll.y, 0, maxPos.y);
|
||||
newScroll.x = std::clamp(newScroll.x, 0, maxPos.x);
|
||||
newScroll.y = std::clamp(newScroll.y, 0, maxPos.y);
|
||||
|
||||
if (newScroll.y != oldScroll.y) {
|
||||
gfx::Rect rc;
|
||||
@ -4254,7 +4253,7 @@ void Timeline::setLayerCollapsedFlag(const layer_t l, const bool state)
|
||||
|
||||
int Timeline::separatorX() const
|
||||
{
|
||||
return base::clamp(m_separator_x, headerBoxWidth(), bounds().w-guiscale());
|
||||
return std::clamp(m_separator_x, headerBoxWidth(), bounds().w-guiscale());
|
||||
}
|
||||
|
||||
void Timeline::setSeparatorX(int newValue)
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2017 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -12,7 +12,8 @@
|
||||
#include "app/util/wrap_point.h"
|
||||
|
||||
#include "app/util/wrap_value.h"
|
||||
#include "base/clamp.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace app {
|
||||
|
||||
@ -26,14 +27,14 @@ gfx::Point wrap_point(const filters::TiledMode tiledMode,
|
||||
if (int(tiledMode) & int(filters::TiledMode::X_AXIS))
|
||||
out.x = wrap_value(pt.x, spriteSize.w);
|
||||
else if (clamp)
|
||||
out.x = base::clamp(pt.x, 0, spriteSize.w-1);
|
||||
out.x = std::clamp(pt.x, 0, spriteSize.w-1);
|
||||
else
|
||||
out.x = pt.x;
|
||||
|
||||
if (int(tiledMode) & int(filters::TiledMode::Y_AXIS))
|
||||
out.y = wrap_value(pt.y, spriteSize.h);
|
||||
else if (clamp)
|
||||
out.y = base::clamp(pt.y, 0, spriteSize.h-1);
|
||||
out.y = std::clamp(pt.y, 0, spriteSize.h-1);
|
||||
else
|
||||
out.y = pt.y;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite Document Library
|
||||
// Copyright (c) 2018-2021 Igara Studio S.A.
|
||||
// Copyright (c) 2018-2022 Igara Studio S.A.
|
||||
// Copyright (c) 2001-2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -11,7 +11,6 @@
|
||||
|
||||
#include "doc/algo.h"
|
||||
|
||||
#include "base/clamp.h"
|
||||
#include "base/debug.h"
|
||||
|
||||
#include <algorithm>
|
||||
@ -412,7 +411,7 @@ static void draw_rotated_ellipse_rect(int x0, int y0, int x1, int y1, double zd,
|
||||
if (w != 0.0)
|
||||
w = (w-zd) / (w+w); // squared weight of P1
|
||||
|
||||
w = base::clamp(w, 0.0, 1.0);
|
||||
w = std::clamp(w, 0.0, 1.0);
|
||||
|
||||
xd = std::floor(w*xd + 0.5);
|
||||
yd = std::floor(w*yd + 0.5);
|
||||
@ -448,7 +447,7 @@ void fill_rotated_ellipse(int cx, int cy, int a, int b, double angle, void* data
|
||||
Rows(int y0, int nrows)
|
||||
: y0(y0), row(nrows, std::make_pair(1, -1)) { }
|
||||
void update(int x, int y) {
|
||||
int i = base::clamp(y-y0, 0, int(row.size()-1));
|
||||
int i = std::clamp(y-y0, 0, int(row.size()-1));
|
||||
auto& r = row[i];
|
||||
if (r.first > r.second) {
|
||||
r.first = r.second = x;
|
||||
|
@ -1,4 +1,5 @@
|
||||
// Aseprite Document Library
|
||||
// Copyright (c) 2022 Igara Studio S.A.
|
||||
// Copyright (c) 2001-2016 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -10,7 +11,6 @@
|
||||
|
||||
#include "base/base.h"
|
||||
#include "base/cfile.h"
|
||||
#include "base/clamp.h"
|
||||
#include "doc/color_scales.h"
|
||||
#include "doc/image.h"
|
||||
#include "doc/palette.h"
|
||||
@ -59,9 +59,9 @@ Palette* load_col_file(const char* filename)
|
||||
if (ferror(f))
|
||||
break;
|
||||
|
||||
pal->setEntry(c, rgba(scale_6bits_to_8bits(base::clamp(r, 0, 63)),
|
||||
scale_6bits_to_8bits(base::clamp(g, 0, 63)),
|
||||
scale_6bits_to_8bits(base::clamp(b, 0, 63)), 255));
|
||||
pal->setEntry(c, rgba(scale_6bits_to_8bits(std::clamp(r, 0, 63)),
|
||||
scale_6bits_to_8bits(std::clamp(g, 0, 63)),
|
||||
scale_6bits_to_8bits(std::clamp(b, 0, 63)), 255));
|
||||
}
|
||||
}
|
||||
// Animator Pro format
|
||||
@ -87,9 +87,9 @@ Palette* load_col_file(const char* filename)
|
||||
if (ferror(f))
|
||||
break;
|
||||
|
||||
pal->setEntry(c, rgba(base::clamp(r, 0, 255),
|
||||
base::clamp(g, 0, 255),
|
||||
base::clamp(b, 0, 255), 255));
|
||||
pal->setEntry(c, rgba(std::clamp(r, 0, 255),
|
||||
std::clamp(g, 0, 255),
|
||||
std::clamp(b, 0, 255), 255));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite Document Library
|
||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -11,7 +11,6 @@
|
||||
|
||||
#include "doc/handle_anidir.h"
|
||||
|
||||
#include "base/clamp.h"
|
||||
#include "doc/frame.h"
|
||||
#include "doc/sprite.h"
|
||||
#include "doc/tag.h"
|
||||
@ -37,8 +36,8 @@ frame_t calculate_next_frame(
|
||||
|
||||
loopFrom = tag->fromFrame();
|
||||
loopTo = tag->toFrame();
|
||||
loopFrom = base::clamp(loopFrom, first, last);
|
||||
loopTo = base::clamp(loopTo, first, last);
|
||||
loopFrom = std::clamp(loopFrom, first, last);
|
||||
loopTo = std::clamp(loopTo, first, last);
|
||||
|
||||
first = loopFrom;
|
||||
last = loopTo;
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite Document Library
|
||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -11,7 +11,6 @@
|
||||
|
||||
#include "doc/mask.h"
|
||||
|
||||
#include "base/clamp.h"
|
||||
#include "base/memory.h"
|
||||
#include "doc/image_impl.h"
|
||||
|
||||
@ -387,10 +386,10 @@ void Mask::crop(const Image *image)
|
||||
beg_x2 = beg_x1 + m_bounds.w - 1;
|
||||
beg_y2 = beg_y1 + m_bounds.h - 1;
|
||||
|
||||
beg_x1 = base::clamp(beg_x1, 0, m_bounds.w-1);
|
||||
beg_y1 = base::clamp(beg_y1, 0, m_bounds.h-1);
|
||||
beg_x2 = base::clamp(beg_x2, beg_x1, m_bounds.w-1);
|
||||
beg_y2 = base::clamp(beg_y2, beg_y1, m_bounds.h-1);
|
||||
beg_x1 = std::clamp(beg_x1, 0, m_bounds.w-1);
|
||||
beg_y1 = std::clamp(beg_y1, 0, m_bounds.h-1);
|
||||
beg_x2 = std::clamp(beg_x2, beg_x1, m_bounds.w-1);
|
||||
beg_y2 = std::clamp(beg_y2, beg_y1, m_bounds.h-1);
|
||||
|
||||
/* left */
|
||||
ADVANCE(x1, x2, y2, <=, ++,
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite Document Library
|
||||
// Copyright (C) 2018-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -11,7 +11,6 @@
|
||||
|
||||
#include "doc/sprite.h"
|
||||
|
||||
#include "base/clamp.h"
|
||||
#include "base/memory.h"
|
||||
#include "base/remove_from_container.h"
|
||||
#include "doc/cel.h"
|
||||
@ -77,7 +76,7 @@ Sprite::Sprite(const ImageSpec& spec,
|
||||
case ColorMode::BITMAP:
|
||||
for (int c=0; c<ncolors; c++) {
|
||||
int g = 255 * c / (ncolors-1);
|
||||
g = base::clamp(g, 0, 255);
|
||||
g = std::clamp(g, 0, 255);
|
||||
pal.setEntry(c, rgba(g, g, g, 255));
|
||||
}
|
||||
break;
|
||||
@ -430,19 +429,19 @@ int Sprite::totalAnimationDuration() const
|
||||
void Sprite::setFrameDuration(frame_t frame, int msecs)
|
||||
{
|
||||
if (frame >= 0 && frame < m_frames)
|
||||
m_frlens[frame] = base::clamp(msecs, 1, 65535);
|
||||
m_frlens[frame] = std::clamp(msecs, 1, 65535);
|
||||
}
|
||||
|
||||
void Sprite::setFrameRangeDuration(frame_t from, frame_t to, int msecs)
|
||||
{
|
||||
std::fill(
|
||||
m_frlens.begin()+(std::size_t)from,
|
||||
m_frlens.begin()+(std::size_t)to+1, base::clamp(msecs, 1, 65535));
|
||||
m_frlens.begin()+(std::size_t)to+1, std::clamp(msecs, 1, 65535));
|
||||
}
|
||||
|
||||
void Sprite::setDurationForAllFrames(int msecs)
|
||||
{
|
||||
std::fill(m_frlens.begin(), m_frlens.end(), base::clamp(msecs, 1, 65535));
|
||||
std::fill(m_frlens.begin(), m_frlens.end(), std::clamp(msecs, 1, 65535));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2017 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -11,7 +11,6 @@
|
||||
|
||||
#include "filters/brightness_contrast_filter.h"
|
||||
|
||||
#include "base/clamp.h"
|
||||
#include "doc/image.h"
|
||||
#include "doc/palette.h"
|
||||
#include "doc/rgbmap.h"
|
||||
@ -189,7 +188,7 @@ void BrightnessContrastFilter::updateMap()
|
||||
double x = double(u) / double(max-1);
|
||||
double y = (m_contrast+1.0) * (x - 0.5) + 0.5;
|
||||
y = y*(1.0+m_brightness);
|
||||
y = base::clamp(y, 0.0, 1.0);
|
||||
y = std::clamp(y, 0.0, 1.0);
|
||||
m_cmap[u] = int(255.5 * y);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -11,7 +11,6 @@
|
||||
|
||||
#include "filters/color_curve_filter.h"
|
||||
|
||||
#include "base/clamp.h"
|
||||
#include "filters/color_curve.h"
|
||||
#include "filters/filter_indexed_data.h"
|
||||
#include "filters/filter_manager.h"
|
||||
@ -42,7 +41,7 @@ void ColorCurveFilter::generateMap()
|
||||
// Generate the color convertion map
|
||||
m_curve.getValues(0, 255, m_cmap);
|
||||
for (int c=0; c<256; c++)
|
||||
m_cmap[c] = base::clamp(m_cmap[c], 0, 255);
|
||||
m_cmap[c] = std::clamp(m_cmap[c], 0, 255);
|
||||
}
|
||||
|
||||
const char* ColorCurveFilter::getName()
|
||||
@ -145,7 +144,7 @@ void ColorCurveFilter::applyToIndexed(FilterManager* filterMgr)
|
||||
c = rgbmap->mapColor(r, g, b, a);
|
||||
}
|
||||
|
||||
*(dst_address++) = base::clamp(c, 0, pal->size()-1);
|
||||
*(dst_address++) = std::clamp(c, 0, pal->size()-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -11,7 +11,6 @@
|
||||
|
||||
#include "filters/convolution_matrix_filter.h"
|
||||
|
||||
#include "base/clamp.h"
|
||||
#include "filters/convolution_matrix.h"
|
||||
#include "filters/filter_indexed_data.h"
|
||||
#include "filters/filter_manager.h"
|
||||
@ -168,28 +167,28 @@ void ConvolutionMatrixFilter::applyToRgba(FilterManager* filterMgr)
|
||||
|
||||
if (target & TARGET_RED_CHANNEL) {
|
||||
delegate.r = delegate.r / delegate.div + m_matrix->getBias();
|
||||
delegate.r = base::clamp(delegate.r, 0, 255);
|
||||
delegate.r = std::clamp(delegate.r, 0, 255);
|
||||
}
|
||||
else
|
||||
delegate.r = rgba_getr(color);
|
||||
|
||||
if (target & TARGET_GREEN_CHANNEL) {
|
||||
delegate.g = delegate.g / delegate.div + m_matrix->getBias();
|
||||
delegate.g = base::clamp(delegate.g, 0, 255);
|
||||
delegate.g = std::clamp(delegate.g, 0, 255);
|
||||
}
|
||||
else
|
||||
delegate.g = rgba_getg(color);
|
||||
|
||||
if (target & TARGET_BLUE_CHANNEL) {
|
||||
delegate.b = delegate.b / delegate.div + m_matrix->getBias();
|
||||
delegate.b = base::clamp(delegate.b, 0, 255);
|
||||
delegate.b = std::clamp(delegate.b, 0, 255);
|
||||
}
|
||||
else
|
||||
delegate.b = rgba_getb(color);
|
||||
|
||||
if (target & TARGET_ALPHA_CHANNEL) {
|
||||
delegate.a = delegate.a / m_matrix->getDiv() + m_matrix->getBias();
|
||||
delegate.a = base::clamp(delegate.a, 0, 255);
|
||||
delegate.a = std::clamp(delegate.a, 0, 255);
|
||||
}
|
||||
else
|
||||
delegate.a = rgba_geta(color);
|
||||
@ -235,14 +234,14 @@ void ConvolutionMatrixFilter::applyToGrayscale(FilterManager* filterMgr)
|
||||
|
||||
if (target & TARGET_GRAY_CHANNEL) {
|
||||
delegate.v = delegate.v / delegate.div + m_matrix->getBias();
|
||||
delegate.v = base::clamp(delegate.v, 0, 255);
|
||||
delegate.v = std::clamp(delegate.v, 0, 255);
|
||||
}
|
||||
else
|
||||
delegate.v = graya_getv(color);
|
||||
|
||||
if (target & TARGET_ALPHA_CHANNEL) {
|
||||
delegate.a = delegate.a / m_matrix->getDiv() + m_matrix->getBias();
|
||||
delegate.a = base::clamp(delegate.a, 0, 255);
|
||||
delegate.a = std::clamp(delegate.a, 0, 255);
|
||||
}
|
||||
else
|
||||
delegate.a = graya_geta(color);
|
||||
@ -290,7 +289,7 @@ void ConvolutionMatrixFilter::applyToIndexed(FilterManager* filterMgr)
|
||||
|
||||
if (target & TARGET_INDEX_CHANNEL) {
|
||||
delegate.index = delegate.index / m_matrix->getDiv() + m_matrix->getBias();
|
||||
delegate.index = base::clamp(delegate.index, 0, 255);
|
||||
delegate.index = std::clamp(delegate.index, 0, 255);
|
||||
|
||||
*(dst_address++) = delegate.index;
|
||||
}
|
||||
@ -299,28 +298,28 @@ void ConvolutionMatrixFilter::applyToIndexed(FilterManager* filterMgr)
|
||||
|
||||
if (target & TARGET_RED_CHANNEL) {
|
||||
delegate.r = delegate.r / delegate.div + m_matrix->getBias();
|
||||
delegate.r = base::clamp(delegate.r, 0, 255);
|
||||
delegate.r = std::clamp(delegate.r, 0, 255);
|
||||
}
|
||||
else
|
||||
delegate.r = rgba_getr(color);
|
||||
|
||||
if (target & TARGET_GREEN_CHANNEL) {
|
||||
delegate.g = delegate.g / delegate.div + m_matrix->getBias();
|
||||
delegate.g = base::clamp(delegate.g, 0, 255);
|
||||
delegate.g = std::clamp(delegate.g, 0, 255);
|
||||
}
|
||||
else
|
||||
delegate.g = rgba_getg(color);
|
||||
|
||||
if (target & TARGET_BLUE_CHANNEL) {
|
||||
delegate.b = delegate.b / delegate.div + m_matrix->getBias();
|
||||
delegate.b = base::clamp(delegate.b, 0, 255);
|
||||
delegate.b = std::clamp(delegate.b, 0, 255);
|
||||
}
|
||||
else
|
||||
delegate.b = rgba_getb(color);
|
||||
|
||||
if (target & TARGET_ALPHA_CHANNEL) {
|
||||
delegate.a = delegate.a / delegate.div + m_matrix->getBias();
|
||||
delegate.a = base::clamp(delegate.a, 0, 255);
|
||||
delegate.a = std::clamp(delegate.a, 0, 255);
|
||||
}
|
||||
else
|
||||
delegate.a = rgba_geta(color);
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2017-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -11,7 +11,6 @@
|
||||
|
||||
#include "filters/hue_saturation_filter.h"
|
||||
|
||||
#include "base/clamp.h"
|
||||
#include "doc/image.h"
|
||||
#include "doc/palette.h"
|
||||
#include "doc/palette_picks.h"
|
||||
@ -125,7 +124,7 @@ void HueSaturationFilter::applyToGrayscale(FilterManager* filterMgr)
|
||||
gfx::Hsl hsl(gfx::Rgb(k, k, k));
|
||||
|
||||
double l = hsl.lightness()*(1.0+m_l);
|
||||
l = base::clamp(l, 0.0, 1.0);
|
||||
l = std::clamp(l, 0.0, 1.0);
|
||||
|
||||
hsl.lightness(l);
|
||||
gfx::Rgb rgb(hsl);
|
||||
@ -134,7 +133,7 @@ void HueSaturationFilter::applyToGrayscale(FilterManager* filterMgr)
|
||||
|
||||
if (a && (target & TARGET_ALPHA_CHANNEL)) {
|
||||
a = a*(1.0+m_a);
|
||||
a = base::clamp(a, 0, 255);
|
||||
a = std::clamp(a, 0, 255);
|
||||
}
|
||||
}
|
||||
|
||||
@ -217,11 +216,11 @@ void HueSaturationFilter::applyFilterToRgbT(const Target target,
|
||||
|
||||
double s = (multiply ? hsl.saturation()*(1.0+m_s):
|
||||
hsl.saturation() + m_s);
|
||||
s = base::clamp(s, 0.0, 1.0);
|
||||
s = std::clamp(s, 0.0, 1.0);
|
||||
|
||||
double l = (multiply ? (hsl.*get_lightness)()*(1.0+m_l):
|
||||
(hsl.*get_lightness)() + m_l);
|
||||
l = base::clamp(l, 0.0, 1.0);
|
||||
l = std::clamp(l, 0.0, 1.0);
|
||||
|
||||
hsl.hue(h);
|
||||
hsl.saturation(s);
|
||||
@ -233,7 +232,7 @@ void HueSaturationFilter::applyFilterToRgbT(const Target target,
|
||||
if (target & TARGET_BLUE_CHANNEL ) b = rgb.blue();
|
||||
if (a && (target & TARGET_ALPHA_CHANNEL)) {
|
||||
a = a*(1.0+m_a);
|
||||
a = base::clamp(a, 0, 255);
|
||||
a = std::clamp(a, 0, 255);
|
||||
}
|
||||
|
||||
c = rgba(r, g, b, a);
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -11,7 +11,6 @@
|
||||
|
||||
#include "filters/replace_color_filter.h"
|
||||
|
||||
#include "base/clamp.h"
|
||||
#include "doc/image.h"
|
||||
#include "doc/palette.h"
|
||||
#include "doc/rgbmap.h"
|
||||
@ -40,7 +39,7 @@ void ReplaceColorFilter::setTo(const color_t to)
|
||||
|
||||
void ReplaceColorFilter::setTolerance(int tolerance)
|
||||
{
|
||||
m_tolerance = base::clamp(tolerance, 0, 255);
|
||||
m_tolerance = std::clamp(tolerance, 0, 255);
|
||||
}
|
||||
|
||||
const char* ReplaceColorFilter::getName()
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite Render Library
|
||||
// Copyright (c) 2019-2020 Igara Studio S.A
|
||||
// Copyright (c) 2019-2022 Igara Studio S.A
|
||||
// Copyright (c) 2017 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -68,7 +68,7 @@ doc::color_t ErrorDiffusionDither::ditherRgbToIndex2D(
|
||||
};
|
||||
for (int i=0; i<kChannels; ++i) {
|
||||
v[i] += m_err[i][x+1];
|
||||
v[i] = base::clamp(v[i], 0, 255);
|
||||
v[i] = std::clamp(v[i], 0, 255);
|
||||
}
|
||||
|
||||
const doc::color_t index =
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite Render Library
|
||||
// Copyright (c) 2019-2020 Igara Studio S.A.
|
||||
// Copyright (c) 2019-2022 Igara Studio S.A.
|
||||
// Copyright (c) 2017 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -11,7 +11,6 @@
|
||||
|
||||
#include "render/ordered_dither.h"
|
||||
|
||||
#include "base/clamp.h"
|
||||
#include "render/dithering.h"
|
||||
#include "render/dithering_matrix.h"
|
||||
|
||||
@ -83,10 +82,10 @@ doc::color_t OrderedDither::ditherRgbPixelToIndex(
|
||||
int g2 = g - (g1-g);
|
||||
int b2 = b - (b1-b);
|
||||
int a2 = a - (a1-a);
|
||||
r2 = base::clamp(r2, 0, 255);
|
||||
g2 = base::clamp(g2, 0, 255);
|
||||
b2 = base::clamp(b2, 0, 255);
|
||||
a2 = base::clamp(a2, 0, 255);
|
||||
r2 = std::clamp(r2, 0, 255);
|
||||
g2 = std::clamp(g2, 0, 255);
|
||||
b2 = std::clamp(b2, 0, 255);
|
||||
a2 = std::clamp(a2, 0, 255);
|
||||
doc::color_t nearest2idx =
|
||||
(rgbmap ? rgbmap->mapColor(r2, g2, b2, a2):
|
||||
palette->findBestfit(r2, g2, b2, a2, m_transparentIndex));
|
||||
@ -201,7 +200,7 @@ doc::color_t OrderedDither2::ditherRgbPixelToIndex(
|
||||
if (mix) {
|
||||
if (div)
|
||||
mix /= div;
|
||||
mix = base::clamp(mix, 0, maxMixValue);
|
||||
mix = std::clamp(mix, 0, maxMixValue);
|
||||
}
|
||||
|
||||
const int rM = r0 + (r1-r0) * mix / maxMixValue;
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite Render Library
|
||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -11,7 +11,6 @@
|
||||
|
||||
#include "render/render.h"
|
||||
|
||||
#include "base/clamp.h"
|
||||
#include "doc/blend_internals.h"
|
||||
#include "doc/blend_mode.h"
|
||||
#include "doc/doc.h"
|
||||
@ -883,7 +882,7 @@ void Render::renderOnionskin(
|
||||
m_globalOpacity = m_onionskin.opacityBase() - m_onionskin.opacityStep() * ((frameOut - frame)-1);
|
||||
}
|
||||
|
||||
m_globalOpacity = base::clamp(m_globalOpacity, 0, 255);
|
||||
m_globalOpacity = std::clamp(m_globalOpacity, 0, 255);
|
||||
if (m_globalOpacity > 0) {
|
||||
BlendMode blendMode = BlendMode::UNSPECIFIED;
|
||||
if (m_onionskin.type() == OnionskinType::MERGE)
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite Render Library
|
||||
// Copyright (c) 2020 Igara Studio S.A.
|
||||
// Copyright (c) 2020-2022 Igara Studio S.A.
|
||||
// Copyright (c) 2001-2016 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -9,10 +9,11 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "base/clamp.h"
|
||||
#include "base/debug.h"
|
||||
#include "render/zoom.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace render {
|
||||
|
||||
static int scales[][2] = {
|
||||
@ -105,7 +106,7 @@ Zoom Zoom::fromScale(double scale)
|
||||
// static
|
||||
Zoom Zoom::fromLinearScale(int i)
|
||||
{
|
||||
i = base::clamp(i, 0, scales_size-1);
|
||||
i = std::clamp(i, 0, scales_size-1);
|
||||
return Zoom(scales[i][0], scales[i][1]);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite UI Library
|
||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -35,7 +35,6 @@
|
||||
|
||||
#include "ui/alert.h"
|
||||
|
||||
#include "base/clamp.h"
|
||||
#include "base/string.h"
|
||||
#include "ui/box.h"
|
||||
#include "ui/button.h"
|
||||
@ -46,6 +45,7 @@
|
||||
#include "ui/slider.h"
|
||||
#include "ui/theme.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
|
||||
namespace ui {
|
||||
@ -143,7 +143,7 @@ CheckBox* Alert::addCheckBox(const std::string& text)
|
||||
void Alert::setProgress(double progress)
|
||||
{
|
||||
ASSERT(m_progress);
|
||||
m_progress->setValue(int(base::clamp(progress * 100.0, 0.0, 100.0)));
|
||||
m_progress->setValue(int(std::clamp(progress * 100.0, 0.0, 100.0)));
|
||||
}
|
||||
|
||||
// static
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite UI Library
|
||||
// Copyright (C) 2018-2019 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -9,7 +9,6 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "base/clamp.h"
|
||||
#include "gfx/size.h"
|
||||
#include "ui/box.h"
|
||||
#include "ui/message.h"
|
||||
@ -117,8 +116,8 @@ void Box::onResize(ResizeEvent& ev)
|
||||
} \
|
||||
\
|
||||
Rect childPos = defChildPos; \
|
||||
childPos.w = size = base::clamp(size, child->minSize().w, child->maxSize().w); \
|
||||
childPos.h = base::clamp(childPos.h, child->minSize().h, child->maxSize().h); \
|
||||
childPos.w = size = std::clamp(size, child->minSize().w, child->maxSize().w); \
|
||||
childPos.h = std::clamp(childPos.h, child->minSize().h, child->maxSize().h); \
|
||||
child->setBounds(childPos); \
|
||||
\
|
||||
defChildPos.x += size + childSpacing(); \
|
||||
|
@ -11,7 +11,6 @@
|
||||
|
||||
#include "ui/combobox.h"
|
||||
|
||||
#include "base/clamp.h"
|
||||
#include "gfx/size.h"
|
||||
#include "os/font.h"
|
||||
#include "ui/button.h"
|
||||
@ -628,7 +627,7 @@ void ComboBox::openListBox()
|
||||
size.h += item->sizeHint().h;
|
||||
|
||||
int max = std::max(entryBounds.y, ui::display_h() - entryBounds.y2()) - 8*guiscale();
|
||||
size.h = base::clamp(size.h, textHeight(), max);
|
||||
size.h = std::clamp(size.h, textHeight(), max);
|
||||
viewport->setMinSize(size);
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,6 @@
|
||||
|
||||
#include "ui/entry.h"
|
||||
|
||||
#include "base/clamp.h"
|
||||
#include "base/string.h"
|
||||
#include "os/draw_text.h"
|
||||
#include "os/font.h"
|
||||
@ -121,8 +120,8 @@ void Entry::setCaretPos(int pos)
|
||||
{
|
||||
gfx::Size caretSize = theme()->getEntryCaretSize(this);
|
||||
int textlen = lastCaretPos();
|
||||
m_caret = base::clamp(pos, 0, textlen);
|
||||
m_scroll = base::clamp(m_scroll, 0, textlen);
|
||||
m_caret = std::clamp(pos, 0, textlen);
|
||||
m_scroll = std::clamp(m_scroll, 0, textlen);
|
||||
|
||||
// Backward scroll
|
||||
if (m_caret < m_scroll)
|
||||
@ -577,7 +576,7 @@ int Entry::getCaretFromMouse(MouseMessage* mousemsg)
|
||||
break;
|
||||
}
|
||||
|
||||
return base::clamp(i, 0, lastPos);
|
||||
return std::clamp(i, 0, lastPos);
|
||||
}
|
||||
|
||||
void Entry::executeCmd(EntryCmd cmd, int unicodeChar, bool shift_pressed)
|
||||
@ -823,7 +822,7 @@ void Entry::backwardWord()
|
||||
Entry::Range Entry::wordRange(int pos)
|
||||
{
|
||||
const int last = lastCaretPos();
|
||||
pos = base::clamp(pos, 0, last);
|
||||
pos = std::clamp(pos, 0, last);
|
||||
|
||||
int i, j;
|
||||
i = j = pos;
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite UI Library
|
||||
// Copyright (C) 2019 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -9,11 +9,12 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "base/clamp.h"
|
||||
#include "gfx/rect.h"
|
||||
#include "ui/base.h"
|
||||
#include "ui/system.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace ui {
|
||||
|
||||
int fit_bounds(int arrowAlign, const gfx::Rect& target, gfx::Rect& bounds)
|
||||
@ -58,8 +59,8 @@ int fit_bounds(int arrowAlign, const gfx::Rect& target, gfx::Rect& bounds)
|
||||
break;
|
||||
}
|
||||
|
||||
bounds.x = base::clamp(bounds.x, 0, ui::display_w()-bounds.w);
|
||||
bounds.y = base::clamp(bounds.y, 0, ui::display_h()-bounds.h);
|
||||
bounds.x = std::clamp(bounds.x, 0, ui::display_w()-bounds.w);
|
||||
bounds.y = std::clamp(bounds.y, 0, ui::display_h()-bounds.h);
|
||||
|
||||
if (target.intersects(bounds)) {
|
||||
switch (trycount) {
|
||||
|
@ -11,7 +11,6 @@
|
||||
|
||||
#include "ui/int_entry.h"
|
||||
|
||||
#include "base/clamp.h"
|
||||
#include "base/scoped_value.h"
|
||||
#include "gfx/rect.h"
|
||||
#include "gfx/region.h"
|
||||
@ -54,12 +53,12 @@ IntEntry::~IntEntry()
|
||||
int IntEntry::getValue() const
|
||||
{
|
||||
int value = m_slider.convertTextToValue(text());
|
||||
return base::clamp(value, m_min, m_max);
|
||||
return std::clamp(value, m_min, m_max);
|
||||
}
|
||||
|
||||
void IntEntry::setValue(int value)
|
||||
{
|
||||
value = base::clamp(value, m_min, m_max);
|
||||
value = std::clamp(value, m_min, m_max);
|
||||
|
||||
setText(m_slider.convertValueToText(value));
|
||||
|
||||
@ -75,7 +74,7 @@ bool IntEntry::onProcessMessage(Message* msg)
|
||||
|
||||
// Reset value if it's out of bounds when focus is lost
|
||||
case kFocusLeaveMessage:
|
||||
setValue(base::clamp(getValue(), m_min, m_max));
|
||||
setValue(std::clamp(getValue(), m_min, m_max));
|
||||
deselectText();
|
||||
break;
|
||||
|
||||
@ -106,7 +105,7 @@ bool IntEntry::onProcessMessage(Message* msg)
|
||||
int newValue = oldValue
|
||||
+ static_cast<MouseMessage*>(msg)->wheelDelta().x
|
||||
- static_cast<MouseMessage*>(msg)->wheelDelta().y;
|
||||
newValue = base::clamp(newValue, m_min, m_max);
|
||||
newValue = std::clamp(newValue, m_min, m_max);
|
||||
if (newValue != oldValue) {
|
||||
setValue(newValue);
|
||||
selectAllText();
|
||||
|
@ -11,7 +11,6 @@
|
||||
|
||||
#include "ui/listbox.h"
|
||||
|
||||
#include "base/clamp.h"
|
||||
#include "base/fs.h"
|
||||
#include "ui/listitem.h"
|
||||
#include "ui/message.h"
|
||||
@ -341,7 +340,7 @@ bool ListBox::onProcessMessage(Message* msg)
|
||||
return Widget::onProcessMessage(msg);
|
||||
}
|
||||
|
||||
selectIndex(base::clamp(select, 0, bottom), msg);
|
||||
selectIndex(std::clamp(select, 0, bottom), msg);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
@ -417,7 +416,7 @@ int ListBox::advanceIndexThroughVisibleItems(
|
||||
const int sgn = SGN(delta);
|
||||
int index = startIndex;
|
||||
|
||||
startIndex = base::clamp(startIndex, 0, bottom);
|
||||
startIndex = std::clamp(startIndex, 0, bottom);
|
||||
int lastVisibleIndex = startIndex;
|
||||
|
||||
bool cycle = false;
|
||||
|
@ -18,7 +18,6 @@
|
||||
|
||||
#include "ui/manager.h"
|
||||
|
||||
#include "base/clamp.h"
|
||||
#include "base/concurrent_queue.h"
|
||||
#include "base/scoped_value.h"
|
||||
#include "base/time.h"
|
||||
@ -1354,8 +1353,8 @@ void Manager::onInitTheme(InitThemeEvent& ev)
|
||||
gfx::Rect bounds = window->bounds();
|
||||
bounds *= newUIScale;
|
||||
bounds /= oldUIScale;
|
||||
bounds.x = base::clamp(bounds.x, 0, m_display->width() - bounds.w);
|
||||
bounds.y = base::clamp(bounds.y, 0, m_display->height() - bounds.h);
|
||||
bounds.x = std::clamp(bounds.x, 0, m_display->width() - bounds.w);
|
||||
bounds.y = std::clamp(bounds.y, 0, m_display->height() - bounds.h);
|
||||
window->setBounds(bounds);
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,6 @@
|
||||
|
||||
#include "ui/menu.h"
|
||||
|
||||
#include "base/clamp.h"
|
||||
#include "gfx/size.h"
|
||||
#include "os/font.h"
|
||||
#include "ui/intern.h"
|
||||
@ -326,8 +325,8 @@ void Menu::showPopup(const gfx::Point& pos)
|
||||
|
||||
// Menubox position
|
||||
window->positionWindow(
|
||||
base::clamp(pos.x, 0, ui::display_w() - window->bounds().w),
|
||||
base::clamp(pos.y, 0, ui::display_h() - window->bounds().h));
|
||||
std::clamp(pos.x, 0, ui::display_w() - window->bounds().w),
|
||||
std::clamp(pos.y, 0, ui::display_h() - window->bounds().h));
|
||||
|
||||
add_scrollbars_if_needed(window.get());
|
||||
|
||||
@ -861,7 +860,7 @@ bool MenuItem::onProcessMessage(Message* msg)
|
||||
Rect pos = window->bounds();
|
||||
|
||||
if (inBar()) {
|
||||
pos.x = base::clamp(bounds().x, 0, ui::display_w()-pos.w);
|
||||
pos.x = std::clamp(bounds().x, 0, ui::display_w()-pos.w);
|
||||
pos.y = std::max(0, bounds().y2());
|
||||
}
|
||||
else {
|
||||
@ -870,9 +869,9 @@ bool MenuItem::onProcessMessage(Message* msg)
|
||||
int x, y = bounds().y-3*guiscale();
|
||||
Rect r1(0, 0, pos.w, pos.h), r2(0, 0, pos.w, pos.h);
|
||||
|
||||
r1.x = x_left = base::clamp(x_left, 0, ui::display_w()-pos.w);
|
||||
r2.x = x_right = base::clamp(x_right, 0, ui::display_w()-pos.w);
|
||||
r1.y = r2.y = y = base::clamp(y, 0, ui::display_h()-pos.h);
|
||||
r1.x = x_left = std::clamp(x_left, 0, ui::display_w()-pos.w);
|
||||
r2.x = x_right = std::clamp(x_right, 0, ui::display_w()-pos.w);
|
||||
r1.y = r2.y = y = std::clamp(y, 0, ui::display_h()-pos.h);
|
||||
|
||||
// Calculate both intersections
|
||||
gfx::Rect s1 = r1.createIntersection(old_pos);
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite UI Library
|
||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -9,7 +9,6 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "base/clamp.h"
|
||||
#include "gfx/size.h"
|
||||
#include "ui/message.h"
|
||||
#include "ui/paint_event.h"
|
||||
@ -148,13 +147,13 @@ bool ScrollBar::onProcessMessage(Message* msg)
|
||||
|
||||
if (align() & HORIZONTAL) {
|
||||
pos = (m_wherepos + mousePos.x - m_whereclick);
|
||||
pos = base::clamp(pos, 0, bar_size - len);
|
||||
pos = std::clamp(pos, 0, bar_size - len);
|
||||
|
||||
scroll.x = (m_size - viewport_size) * pos / (bar_size - len);
|
||||
}
|
||||
else {
|
||||
pos = (m_wherepos + mousePos.y - m_whereclick);
|
||||
pos = base::clamp(pos, 0, bar_size - len);
|
||||
pos = std::clamp(pos, 0, bar_size - len);
|
||||
|
||||
scroll.y = (m_size - viewport_size) * pos / (bar_size - len);
|
||||
}
|
||||
@ -222,9 +221,9 @@ void ScrollBar::getScrollBarInfo(int *_pos, int *_len, int *_bar_size, int *_vie
|
||||
}
|
||||
else if (m_size > 0) {
|
||||
len = bar_size * viewport_size / m_size;
|
||||
len = base::clamp(len, theme()->getScrollbarSize()*2-border_width, bar_size);
|
||||
len = std::clamp(len, theme()->getScrollbarSize()*2-border_width, bar_size);
|
||||
pos = (bar_size-len) * m_pos / (m_size-viewport_size);
|
||||
pos = base::clamp(pos, 0, bar_size-len);
|
||||
pos = std::clamp(pos, 0, bar_size-len);
|
||||
}
|
||||
else {
|
||||
len = pos = 0;
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite UI Library
|
||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -11,7 +11,6 @@
|
||||
|
||||
#include "ui/slider.h"
|
||||
|
||||
#include "base/clamp.h"
|
||||
#include "os/font.h"
|
||||
#include "ui/manager.h"
|
||||
#include "ui/message.h"
|
||||
@ -34,7 +33,7 @@ Slider::Slider(int min, int max, int value, SliderDelegate* delegate)
|
||||
: Widget(kSliderWidget)
|
||||
, m_min(min)
|
||||
, m_max(max)
|
||||
, m_value(base::clamp(value, min, max))
|
||||
, m_value(std::clamp(value, min, max))
|
||||
, m_readOnly(false)
|
||||
, m_delegate(delegate)
|
||||
{
|
||||
@ -46,7 +45,7 @@ void Slider::setRange(int min, int max)
|
||||
{
|
||||
m_min = min;
|
||||
m_max = max;
|
||||
m_value = base::clamp(m_value, min, max);
|
||||
m_value = std::clamp(m_value, min, max);
|
||||
|
||||
invalidate();
|
||||
}
|
||||
@ -55,7 +54,7 @@ void Slider::setValue(int value)
|
||||
{
|
||||
int old_value = m_value;
|
||||
|
||||
m_value = base::clamp(value, m_min, m_max);
|
||||
m_value = std::clamp(value, m_min, m_max);
|
||||
|
||||
if (m_value != old_value)
|
||||
invalidate();
|
||||
@ -132,13 +131,13 @@ bool Slider::onProcessMessage(Message* msg)
|
||||
}
|
||||
// With right click
|
||||
else {
|
||||
accuracy = base::clamp(rc.w / range, 1, rc.w);
|
||||
accuracy = std::clamp(rc.w / range, 1, rc.w);
|
||||
|
||||
value = slider_press_value +
|
||||
(mousePos.x - slider_press_x) / accuracy;
|
||||
}
|
||||
|
||||
value = base::clamp(value, m_min, m_max);
|
||||
value = std::clamp(value, m_min, m_max);
|
||||
if (m_value != value) {
|
||||
setValue(value);
|
||||
onChange();
|
||||
@ -180,7 +179,7 @@ bool Slider::onProcessMessage(Message* msg)
|
||||
goto not_used;
|
||||
}
|
||||
|
||||
value = base::clamp(value, m_min, m_max);
|
||||
value = std::clamp(value, m_min, m_max);
|
||||
if (m_value != value) {
|
||||
setValue(value);
|
||||
onChange();
|
||||
@ -196,7 +195,7 @@ bool Slider::onProcessMessage(Message* msg)
|
||||
+ static_cast<MouseMessage*>(msg)->wheelDelta().x
|
||||
- static_cast<MouseMessage*>(msg)->wheelDelta().y;
|
||||
|
||||
value = base::clamp(value, m_min, m_max);
|
||||
value = std::clamp(value, m_min, m_max);
|
||||
|
||||
if (m_value != value) {
|
||||
this->setValue(value);
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite UI Library
|
||||
// Copyright (C) 2019-2021 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -11,7 +11,6 @@
|
||||
|
||||
#include "ui/splitter.h"
|
||||
|
||||
#include "base/clamp.h"
|
||||
#include "ui/load_layout_event.h"
|
||||
#include "ui/manager.h"
|
||||
#include "ui/message.h"
|
||||
@ -359,22 +358,22 @@ void Splitter::calcPos()
|
||||
if (align() & HORIZONTAL) {
|
||||
switch (m_type) {
|
||||
case ByPercentage:
|
||||
m_pos = base::clamp<double>(m_userPos, 0, 100);
|
||||
m_pos = std::clamp<double>(m_userPos, 0, 100);
|
||||
break;
|
||||
case ByPixel:
|
||||
if (isVisible())
|
||||
m_pos = base::clamp<double>(m_userPos, 0, bounds().w);
|
||||
m_pos = std::clamp<double>(m_userPos, 0, bounds().w);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch (m_type) {
|
||||
case ByPercentage:
|
||||
m_pos = base::clamp<double>(m_userPos, 0, 100);
|
||||
m_pos = std::clamp<double>(m_userPos, 0, 100);
|
||||
break;
|
||||
case ByPixel:
|
||||
if (isVisible())
|
||||
m_pos = base::clamp<double>(m_userPos, 0, bounds().h);
|
||||
m_pos = std::clamp<double>(m_userPos, 0, bounds().h);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite UI Library
|
||||
// Copyright (C) 2018-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -11,7 +11,6 @@
|
||||
|
||||
#include "ui/tooltips.h"
|
||||
|
||||
#include "base/clamp.h"
|
||||
#include "gfx/size.h"
|
||||
#include "ui/graphics.h"
|
||||
#include "ui/intern.h"
|
||||
@ -212,8 +211,8 @@ bool TipWindow::pointAt(int arrowAlign, const gfx::Rect& target)
|
||||
break;
|
||||
}
|
||||
|
||||
x = base::clamp(x, 0, ui::display_w()-w);
|
||||
y = base::clamp(y, 0, ui::display_h()-h);
|
||||
x = std::clamp(x, 0, ui::display_w()-w);
|
||||
y = std::clamp(y, 0, ui::display_h()-h);
|
||||
|
||||
if (m_target.intersects(gfx::Rect(x, y, w, h))) {
|
||||
switch (trycount) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite UI Library
|
||||
// Copyright (C) 2018-2021 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -11,7 +11,6 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "base/clamp.h"
|
||||
#include "gfx/size.h"
|
||||
#include "ui/intern.h"
|
||||
#include "ui/manager.h"
|
||||
@ -390,8 +389,8 @@ gfx::Point View::limitScrollPosToViewport(const gfx::Point& pt) const
|
||||
{
|
||||
const Size maxSize = getScrollableSize();
|
||||
const Size visible = visibleSize();
|
||||
return Point(base::clamp(pt.x, 0, std::max(0, maxSize.w - visible.w)),
|
||||
base::clamp(pt.y, 0, std::max(0, maxSize.h - visible.h)));
|
||||
return Point(std::clamp(pt.x, 0, std::max(0, maxSize.w - visible.w)),
|
||||
std::clamp(pt.y, 0, std::max(0, maxSize.h - visible.h)));
|
||||
}
|
||||
|
||||
} // namespace ui
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
#include "ui/widget.h"
|
||||
|
||||
#include "base/clamp.h"
|
||||
#include "base/memory.h"
|
||||
#include "base/string.h"
|
||||
#include "base/utf8_decode.h"
|
||||
@ -614,7 +613,7 @@ void Widget::insertChild(int index, Widget* child)
|
||||
ASSERT_VALID_WIDGET(this);
|
||||
ASSERT_VALID_WIDGET(child);
|
||||
|
||||
index = base::clamp(index, 0, int(m_children.size()));
|
||||
index = std::clamp(index, 0, int(m_children.size()));
|
||||
|
||||
auto it = m_children.begin() + index;
|
||||
it = m_children.insert(it, child);
|
||||
@ -1298,8 +1297,8 @@ Size Widget::sizeHint()
|
||||
onSizeHint(ev);
|
||||
|
||||
Size sz(ev.sizeHint());
|
||||
sz.w = base::clamp(sz.w, m_minSize.w, m_maxSize.w);
|
||||
sz.h = base::clamp(sz.h, m_minSize.h, m_maxSize.h);
|
||||
sz.w = std::clamp(sz.w, m_minSize.w, m_maxSize.w);
|
||||
sz.h = std::clamp(sz.h, m_minSize.h, m_maxSize.h);
|
||||
return sz;
|
||||
}
|
||||
}
|
||||
@ -1327,8 +1326,8 @@ Size Widget::sizeHint(const Size& fitIn)
|
||||
onSizeHint(ev);
|
||||
|
||||
Size sz(ev.sizeHint());
|
||||
sz.w = base::clamp(sz.w, m_minSize.w, m_maxSize.w);
|
||||
sz.h = base::clamp(sz.h, m_minSize.h, m_maxSize.h);
|
||||
sz.w = std::clamp(sz.w, m_minSize.w, m_maxSize.w);
|
||||
sz.h = std::clamp(sz.h, m_minSize.h, m_maxSize.h);
|
||||
return sz;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user