From 0d0f8635218a2893fcd00385019089253474f634 Mon Sep 17 00:00:00 2001 From: "B. Stack" Date: Mon, 10 May 2021 08:05:45 -0400 Subject: add upstream 11.10 --- wx+/choice_enum.h | 16 ++++++++-------- wx+/graph.cpp | 11 +++++------ wx+/graph.h | 6 +++--- wx+/grid.cpp | 6 ++++++ wx+/grid.h | 16 ++++------------ 5 files changed, 26 insertions(+), 29 deletions(-) (limited to 'wx+') diff --git a/wx+/choice_enum.h b/wx+/choice_enum.h index a590861a..a25bf104 100644 --- a/wx+/choice_enum.h +++ b/wx+/choice_enum.h @@ -48,7 +48,7 @@ struct EnumDescrList using DescrList = std::vector>>; DescrList descrList; - std::unordered_map> itemsSetLast; + std::unordered_map> labelsSetLast; }; template void setEnumVal(const EnumDescrList& mapping, wxChoice& ctrl, Enum value); template Enum getEnumVal(const EnumDescrList& mapping, const wxChoice& ctrl); @@ -71,16 +71,16 @@ template void updateTooltipEnumVal(const EnumDescrList& mappi template void setEnumVal(EnumDescrList& mapping, wxChoice& ctrl, Enum value) { - auto& itemsSetLast = mapping.itemsSetLast[&ctrl]; + auto& labelsSetLast = mapping.labelsSetLast[&ctrl]; - std::vector items; - for (auto it = mapping.descrList.begin(); it != mapping.descrList.end(); ++it) - items.push_back(it->second.first); + std::vector labels; + for (const auto& [val, texts] : mapping.descrList) + labels.push_back(texts.first); - if (items != itemsSetLast) + if (labels != labelsSetLast) { - ctrl.Set(items); //expensive as fuck! => only call when absolutely needed! - itemsSetLast = std::move(items); + ctrl.Set(labels); //expensive as fuck! => only call when absolutely needed! + labelsSetLast = std::move(labels); } //----------------------------------------------------------------- diff --git a/wx+/graph.cpp b/wx+/graph.cpp index be75ac4d..8dec2074 100644 --- a/wx+/graph.cpp +++ b/wx+/graph.cpp @@ -511,7 +511,7 @@ void Graph2D::onMouseCaptureLost(wxMouseCaptureLostEvent& event) } -void Graph2D::addCurve(const std::shared_ptr& data, const CurveAttributes& ca) +void Graph2D::addCurve(const SharedRef& data, const CurveAttributes& ca) { CurveAttributes newAttr = ca; if (newAttr.autoColor) @@ -587,10 +587,9 @@ void Graph2D::render(wxDC& dc) const //detect x value range double minX = attr_.minX ? *attr_.minX : std::numeric_limits::infinity(); //automatic: ensure values are initialized by first curve double maxX = attr_.maxX ? *attr_.maxX : -std::numeric_limits::infinity(); // - for (auto it = curves_.begin(); it != curves_.end(); ++it) - if (const CurveData* curve = it->first.get()) + for (const auto& [curve, attrib] : curves_) { - const std::pair rangeX = curve->getRangeX(); + const std::pair rangeX = curve.ref().getRangeX(); assert(rangeX.first <= rangeX.second + 1.0e-9); //GCC fucks up badly when comparing two *binary identical* doubles and finds "begin > end" with diff of 1e-18 @@ -620,12 +619,12 @@ void Graph2D::render(wxDC& dc) const std::vector> oobMarker (curves_.size()); //effectively a std::vector marking points that start an out-of-bounds line for (size_t index = 0; index < curves_.size(); ++index) - if (const CurveData* curve = curves_[index].first.get()) { + const CurveData& curve = curves_ [index].first.ref(); std::vector& points = curvePoints[index]; auto& marker = oobMarker [index]; - points = curve->getPoints(minX, maxX, graphArea.GetSize()); + points = curve.getPoints(minX, maxX, graphArea.GetSize()); marker.resize(points.size()); //default value: false if (!points.empty()) { diff --git a/wx+/graph.h b/wx+/graph.h index 288ef9e7..55734a06 100644 --- a/wx+/graph.h +++ b/wx+/graph.h @@ -25,7 +25,7 @@ namespace zen setLabelX(Graph2D::LABEL_X_BOTTOM, 20, std::make_shared()). setLabelY(Graph2D::LABEL_Y_RIGHT, 60, std::make_shared())); //set graph data - std::shared_ptr curveDataBytes_ = ... + SharedRef curveDataBytes_ = ... m_panelGraph->setCurve(curveDataBytes_, Graph2D::CurveAttributes().setLineWidth(2).setColor(wxColor(0, 192, 0))); */ struct CurvePoint @@ -215,7 +215,7 @@ public: int lineWidth = fastFromDIP(2); }; - void addCurve(const std::shared_ptr& data, const CurveAttributes& ca = CurveAttributes()); + void addCurve(const SharedRef& data, const CurveAttributes& ca = CurveAttributes()); void clearCurves() { curves_.clear(); } static wxColor getBorderColor() { return {130, 135, 144}; } //medium grey, the same Win7 uses for other frame borders => not accessible! but no big deal... @@ -326,7 +326,7 @@ private: std::optional doubleBuffer_; - using CurveList = std::vector, CurveAttributes>>; + using CurveList = std::vector, CurveAttributes>>; CurveList curves_; //perf!!! generating the font is *very* expensive! => buffer for Graph2D::render()! diff --git a/wx+/grid.cpp b/wx+/grid.cpp index ab9babbb..fb9aacbc 100644 --- a/wx+/grid.cpp +++ b/wx+/grid.cpp @@ -1641,6 +1641,12 @@ void Grid::updateWindowSizes(bool updateScrollbar) wxSize Grid::GetSizeAvailableForScrollTarget(const wxSize& size) { + //1. "size == GetSize() == (0, 0)" happens temporarily during initialization + //2. often it's even (0, 20) + //3. fuck knows why, but we *temporarily* get "size == GetSize() == (1, 1)" when wxAUI panel containing Grid is dropped + if (size.x <= 1 || size.y <= 1) + return {}; //probably best considering calling code in generic/scrlwing.cpp: wxScrollHelper::AdjustScrollbars() + //1. calculate row label width independent from scrollbars const int mainWinHeightGross = std::max(0, size.GetHeight() - getColumnLabelHeight()); //independent from client sizes and scrollbars! const ptrdiff_t logicalHeight = rowLabelWin_->getLogicalHeight(); // diff --git a/wx+/grid.h b/wx+/grid.h index 4de76b66..8ab03932 100644 --- a/wx+/grid.h +++ b/wx+/grid.h @@ -12,6 +12,7 @@ #include #include #include +#include //#include #include @@ -366,18 +367,9 @@ private: template std::vector makeConsistent(const std::vector& attribs, const std::vector& defaults) { - using ColTypeReal = decltype(ColAttrReal().type); - std::vector output; - - std::set usedTypes; //remove duplicates - auto appendUnique = [&](const std::vector& attr) - { - std::copy_if(attr.begin(), attr.end(), std::back_inserter(output), - [&](const ColAttrReal& a) { return usedTypes.insert(a.type).second; }); - }; - appendUnique(attribs); - appendUnique(defaults); //make sure each type is existing! - + std::vector output = attribs; + append(output, defaults); //make sure each type is existing! + removeDuplicatesStable(output, [](const ColAttrReal& lhs, const ColAttrReal& rhs) { return lhs.type < rhs.type; }); return output; } -- cgit