summaryrefslogtreecommitdiff
path: root/wx+
diff options
context:
space:
mode:
authorB Stack <bgstack15@gmail.com>2018-11-15 11:22:00 +0000
committerB Stack <bgstack15@gmail.com>2018-11-15 11:22:00 +0000
commit77c5c2503d459288720a8894349ac74e5eeec7c6 (patch)
tree30bf08d782d58174a0ca212b2e4b172fabd9c42c /wx+
parentMerge branch '10.5' into 'master' (diff)
parent10.6 (diff)
downloadFreeFileSync-77c5c2503d459288720a8894349ac74e5eeec7c6.tar.gz
FreeFileSync-77c5c2503d459288720a8894349ac74e5eeec7c6.tar.bz2
FreeFileSync-77c5c2503d459288720a8894349ac74e5eeec7c6.zip
Merge branch '10.6' into 'master'10.6
10.6 See merge request opensource-tracking/FreeFileSync!3
Diffstat (limited to 'wx+')
-rwxr-xr-xwx+/async_task.h4
-rwxr-xr-xwx+/graph.cpp18
-rwxr-xr-xwx+/grid.cpp20
-rwxr-xr-xwx+/grid.h4
-rwxr-xr-xwx+/image_holder.h2
-rwxr-xr-xwx+/image_resources.cpp2
6 files changed, 25 insertions, 25 deletions
diff --git a/wx+/async_task.h b/wx+/async_task.h
index df4c3ec6..074f5337 100755
--- a/wx+/async_task.h
+++ b/wx+/async_task.h
@@ -83,9 +83,9 @@ public:
inRecursion_ = true;
ZEN_ON_SCOPE_EXIT(inRecursion_ = false);
- std::vector<std::unique_ptr<Task>> readyTasks; //Reentrancy; access to AsyncTasks::add is not protected! => evaluate outside erase_if
+ std::vector<std::unique_ptr<Task>> readyTasks; //Reentrancy; access to AsyncTasks::add is not protected! => evaluate outside eraseIf
- erase_if(tasks_, [&](std::unique_ptr<Task>& task)
+ eraseIf(tasks_, [&](std::unique_ptr<Task>& task)
{
if (task->resultReady())
{
diff --git a/wx+/graph.cpp b/wx+/graph.cpp
index e00bed86..9cacd1bf 100755
--- a/wx+/graph.cpp
+++ b/wx+/graph.cpp
@@ -91,7 +91,7 @@ public:
int realToScreenRound(double realPos) const //returns -1 and screenSize + 1 if out of bounds!
{
//catch large double values: if double is larger than what int can represent => undefined behavior!
- numeric::clamp(realPos, outOfBoundsLow_, outOfBoundsHigh_);
+ realPos = std::clamp(realPos, outOfBoundsLow_, outOfBoundsHigh_);
return numeric::round(realToScreen(realPos));
}
@@ -724,10 +724,10 @@ void Graph2D::render(wxDC& dc) const
const wxPoint screenCurrent = activeSel_->refCurrentPos() - graphAreaOrigin;
//normalize positions: a mouse selection is symmetric and *not* an half-open range!
- double screenFromX = numeric::clampCpy(screenStart .x, 0, graphArea.width - 1);
- double screenFromY = numeric::clampCpy(screenStart .y, 0, graphArea.height - 1);
- double screenToX = numeric::clampCpy(screenCurrent.x, 0, graphArea.width - 1);
- double screenToY = numeric::clampCpy(screenCurrent.y, 0, graphArea.height - 1);
+ double screenFromX = std::clamp(screenStart .x, 0, graphArea.width - 1);
+ double screenFromY = std::clamp(screenStart .y, 0, graphArea.height - 1);
+ double screenToX = std::clamp(screenCurrent.x, 0, graphArea.width - 1);
+ double screenToY = std::clamp(screenCurrent.y, 0, graphArea.height - 1);
widen(&screenFromX, &screenToX); //use full pixel range for selection!
widen(&screenFromY, &screenToY);
@@ -782,10 +782,10 @@ void Graph2D::render(wxDC& dc) const
shrink(&screenFromX, &screenToX);
shrink(&screenFromY, &screenToY);
- numeric::clamp(screenFromX, 0.0, graphArea.width - 1.0);
- numeric::clamp(screenFromY, 0.0, graphArea.height - 1.0);
- numeric::clamp(screenToX, 0.0, graphArea.width - 1.0);
- numeric::clamp(screenToY, 0.0, graphArea.height - 1.0);
+ screenFromX = std::clamp(screenFromX, 0.0, graphArea.width - 1.0);
+ screenFromY = std::clamp(screenFromY, 0.0, graphArea.height - 1.0);
+ screenToX = std::clamp(screenToX, 0.0, graphArea.width - 1.0);
+ screenToY = std::clamp(screenToY, 0.0, graphArea.height - 1.0);
const wxPoint pixelFrom = wxPoint(numeric::round(screenFromX),
numeric::round(screenFromY)) + graphAreaOrigin;
diff --git a/wx+/grid.cpp b/wx+/grid.cpp
index 65311ffa..3c19c246 100755
--- a/wx+/grid.cpp
+++ b/wx+/grid.cpp
@@ -171,7 +171,6 @@ wxSize GridData::drawCellText(wxDC& dc, const wxRect& rect, const std::wstring&
if (high > 1)
for (;;)
{
- const size_t middle = (low + high) / 2; //=> never 0 when "high - low > 1"
if (high - low <= 1)
{
if (low == 0)
@@ -181,6 +180,7 @@ wxSize GridData::drawCellText(wxDC& dc, const wxRect& rect, const std::wstring&
}
break;
}
+ const size_t middle = (low + high) / 2; //=> never 0 when "high - low > 1"
const std::wstring& candidate = getUnicodeSubstring(text, 0, middle) + ELLIPSIS;
const wxSize extentCand = dc.GetTextExtent(candidate); //perf: most expensive call of this routine!
@@ -1193,7 +1193,7 @@ private:
//select current row *after* scrolling
wxPoint clientPosTrimmed = clientPos;
- numeric::clamp(clientPosTrimmed.y, 0, clientSize.GetHeight() - 1); //do not select row outside client window!
+ clientPosTrimmed.y = std::clamp(clientPosTrimmed.y, 0, clientSize.GetHeight() - 1); //do not select row outside client window!
const wxPoint absPos = wnd_.refParent().CalcUnscrolledPosition(clientPosTrimmed);
const ptrdiff_t newRow = wnd_.rowLabelWin_.getRowAtPos(absPos.y); //return -1 for invalid position; >= rowCount if out of range
@@ -1357,8 +1357,8 @@ void Grid::updateWindowSizes(bool updateScrollbar)
{
ptrdiff_t yFrom = CalcUnscrolledPosition(wxPoint(0, 0)).y;
ptrdiff_t yTo = CalcUnscrolledPosition(wxPoint(0, mainWinHeightGross - 1)).y ;
- numeric::clamp<ptrdiff_t>(yFrom, 0, logicalHeight - 1);
- numeric::clamp<ptrdiff_t>(yTo, 0, logicalHeight - 1);
+ yFrom = std::clamp<ptrdiff_t>(yFrom, 0, logicalHeight - 1);
+ yTo = std::clamp<ptrdiff_t>(yTo, 0, logicalHeight - 1);
const ptrdiff_t rowFrom = rowLabelWin_->getRowAtPos(yFrom);
const ptrdiff_t rowTo = rowLabelWin_->getRowAtPos(yTo);
@@ -1465,8 +1465,8 @@ wxSize Grid::GetSizeAvailableForScrollTarget(const wxSize& size)
{
ptrdiff_t yFrom = CalcUnscrolledPosition(wxPoint(0, 0)).y;
ptrdiff_t yTo = CalcUnscrolledPosition(wxPoint(0, mainWinHeightGross - 1)).y ;
- numeric::clamp<ptrdiff_t>(yFrom, 0, logicalHeight - 1);
- numeric::clamp<ptrdiff_t>(yTo, 0, logicalHeight - 1);
+ yFrom = std::clamp<ptrdiff_t>(yFrom, 0, logicalHeight - 1);
+ yTo = std::clamp<ptrdiff_t>(yTo, 0, logicalHeight - 1);
const ptrdiff_t rowFrom = rowLabelWin_->getRowAtPos(yFrom);
const ptrdiff_t rowTo = rowLabelWin_->getRowAtPos(yTo);
@@ -1499,7 +1499,7 @@ void Grid::onKeyDown(wxKeyEvent& event)
{
if (rowCount > 0)
{
- numeric::clamp<ptrdiff_t>(row, 0, rowCount - 1);
+ row = std::clamp<ptrdiff_t>(row, 0, rowCount - 1);
setGridCursor(row, GridEventPolicy::ALLOW);
}
};
@@ -1508,7 +1508,7 @@ void Grid::onKeyDown(wxKeyEvent& event)
{
if (rowCount > 0)
{
- numeric::clamp<ptrdiff_t>(row, 0, rowCount - 1);
+ row = std::clamp<ptrdiff_t>(row, 0, rowCount - 1);
selectWithCursor(row); //emits GridSelectEvent
}
};
@@ -2018,8 +2018,8 @@ void Grid::selectRange(ptrdiff_t rowFrom, ptrdiff_t rowTo, bool positive, const
auto rowLast = std::max(rowFrom, rowTo) + 1;
const size_t rowCount = getRowCount();
- numeric::clamp<ptrdiff_t>(rowFirst, 0, rowCount);
- numeric::clamp<ptrdiff_t>(rowLast, 0, rowCount);
+ rowFirst = std::clamp<ptrdiff_t>(rowFirst, 0, rowCount);
+ rowLast = std::clamp<ptrdiff_t>(rowLast, 0, rowCount);
selection_.selectRange(rowFirst, rowLast, positive);
mainWin_->Refresh();
diff --git a/wx+/grid.h b/wx+/grid.h
index ccf7ad64..102396c3 100755
--- a/wx+/grid.h
+++ b/wx+/grid.h
@@ -271,8 +271,8 @@ private:
{
if (rowFirst <= rowLast)
{
- numeric::clamp<size_t>(rowFirst, 0, selected_.size());
- numeric::clamp<size_t>(rowLast, 0, selected_.size());
+ rowFirst = std::clamp<size_t>(rowFirst, 0, selected_.size());
+ rowLast = std::clamp<size_t>(rowLast, 0, selected_.size());
std::fill(selected_.begin() + rowFirst, selected_.begin() + rowLast, positive);
}
diff --git a/wx+/image_holder.h b/wx+/image_holder.h
index aada581f..b11ae451 100755
--- a/wx+/image_holder.h
+++ b/wx+/image_holder.h
@@ -39,9 +39,9 @@ struct ImageHolder //prepare conversion to wxImage as much as possible while sta
unsigned char* releaseRgb () { return rgb_ .release(); }
unsigned char* releaseAlpha() { return alpha_.release(); }
+private:
struct CLibFree { void operator()(unsigned char* p) const { ::free(p); } }; //use malloc/free to allow direct move into wxImage!
-private:
int width_ = 0;
int height_ = 0;
std::unique_ptr<unsigned char, CLibFree> rgb_; //optional
diff --git a/wx+/image_resources.cpp b/wx+/image_resources.cpp
index d09a188b..5bc8006f 100755
--- a/wx+/image_resources.cpp
+++ b/wx+/image_resources.cpp
@@ -214,7 +214,7 @@ void GlobalBitmaps::init(const Zstring& filePath)
//do NOT rely on wxConvLocal! On failure shows unhelpful popup "Cannot convert from the charset 'Unknown encoding (-1)'!"
//do we need xBRZ scaling for high quality DPI images?
- const int hqScale = numeric::clampCpy<int>(std::ceil(fastFromDIP(1000) / 1000.0), 1, xbrz::SCALE_FACTOR_MAX);
+ const int hqScale = std::clamp<int>(std::ceil(fastFromDIP(1000) / 1000.0), 1, xbrz::SCALE_FACTOR_MAX);
//even for 125% DPI scaling, "2xBRZ + bilinear downscale" gives a better result than mere "125% bilinear upscale"!
if (hqScale > 1)
dpiScaler_ = std::make_unique<DpiParallelScaler>(hqScale);
bgstack15