From 462d2bb8fab8c71e497a6f1dbb7163b191144786 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 1 Sep 2019 00:42:31 -0400 Subject: [PATCH 01/23] Icon: std::move ObjToken instances where applicable Allows the callers to move the token instance into the type if able to, allowing avoiding an unnecessary atomic reference count increment and decrement. --- specter/include/specter/Icon.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/specter/include/specter/Icon.hpp b/specter/include/specter/Icon.hpp index 52402226e..2bfa42241 100644 --- a/specter/include/specter/Icon.hpp +++ b/specter/include/specter/Icon.hpp @@ -17,7 +17,7 @@ struct Icon { boo::ObjToken m_tex; zeus::CVector2f m_uvCoords[4]; Icon() = default; - Icon(const boo::ObjToken& tex, float rect[4]) : m_tex(tex) { + Icon(boo::ObjToken tex, float rect[4]) : m_tex(std::move(tex)) { m_uvCoords[0][0] = rect[0]; m_uvCoords[0][1] = -rect[3]; @@ -46,8 +46,8 @@ class IconAtlas { public: IconAtlas() = default; operator bool() const { return m_tex.operator bool(); } - void initializeAtlas(const boo::ObjToken& tex) { - m_tex = tex; + void initializeAtlas(boo::ObjToken tex) { + m_tex = std::move(tex); for (size_t c = 0; c < COLS; ++c) for (size_t r = 0; r < ROWS; ++r) m_icons[c][r] = MakeIcon(c, r); From 532e6909f3fda8d0b1902697322252bacfd70e07 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 1 Sep 2019 00:49:18 -0400 Subject: [PATCH 02/23] Icon: Use std::array where applicable --- specter/include/specter/Icon.hpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/specter/include/specter/Icon.hpp b/specter/include/specter/Icon.hpp index 2bfa42241..ad30b1bd0 100644 --- a/specter/include/specter/Icon.hpp +++ b/specter/include/specter/Icon.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include "specter/View.hpp" @@ -15,9 +16,9 @@ class ViewResources; struct Icon { boo::ObjToken m_tex; - zeus::CVector2f m_uvCoords[4]; + std::array m_uvCoords; Icon() = default; - Icon(boo::ObjToken tex, float rect[4]) : m_tex(std::move(tex)) { + Icon(boo::ObjToken tex, const std::array& rect) : m_tex(std::move(tex)) { m_uvCoords[0][0] = rect[0]; m_uvCoords[0][1] = -rect[3]; @@ -35,11 +36,15 @@ struct Icon { template class IconAtlas { boo::ObjToken m_tex; - Icon m_icons[COLS][ROWS]; + std::array, COLS> m_icons; - Icon MakeIcon(float x, float y) { - float rect[] = {x / float(COLS), y / float(ROWS), x / float(COLS) + 1.f / float(COLS), - y / float(ROWS) + 1.f / float(ROWS)}; + Icon MakeIcon(float x, float y) const { + const std::array rect{ + x / float(COLS), + y / float(ROWS), + x / float(COLS) + 1.f / float(COLS), + y / float(ROWS) + 1.f / float(ROWS), + }; return Icon(m_tex.get(), rect); } From b2e45e28fa60dec8c30ee3e5aa5f6384fb03d78a Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 1 Sep 2019 01:07:43 -0400 Subject: [PATCH 03/23] View: Implement load() in terms of the other Same thing, but with less code duplication. --- specter/include/specter/View.hpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/specter/include/specter/View.hpp b/specter/include/specter/View.hpp index eee603430..0412dec71 100644 --- a/specter/include/specter/View.hpp +++ b/specter/include/specter/View.hpp @@ -111,20 +111,15 @@ public: void load(const VertStruct* data, size_t count) { if (m_vertsBuf) { - VertStruct* out = m_vertsBuf.access(); - for (size_t i = 0; i < count; ++i) - out[i] = data[i]; + VertStruct* const out = m_vertsBuf.access(); + std::copy(data, data + count, out); } } template void load(const VertArray data) { - static_assert(std::is_same, VertStruct>::value, "mismatched type"); - if (m_vertsBuf) { - constexpr size_t count = sizeof(VertArray) / sizeof(VertStruct); - VertStruct* out = m_vertsBuf.access(); - for (size_t i = 0; i < count; ++i) - out[i] = data[i]; - } + static_assert(std::is_same_v, VertStruct>, "mismatched type"); + constexpr size_t count = sizeof(VertArray) / sizeof(VertStruct); + load(data, count); } operator const boo::ObjToken&() { return m_shaderBinding; } From eefcbb534092f500875e763486835c3e20965a6b Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 1 Sep 2019 01:49:27 -0400 Subject: [PATCH 04/23] View: Add load() overload for arbitrary containers We can utilize this to allow for transitions to other container types while retaining support for C-style arrays (e.g. We can seamlessly transition over to std::array). --- specter/include/specter/View.hpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/specter/include/specter/View.hpp b/specter/include/specter/View.hpp index 0412dec71..d67f2a782 100644 --- a/specter/include/specter/View.hpp +++ b/specter/include/specter/View.hpp @@ -1,7 +1,9 @@ #pragma once #include +#include #include +#include #include #include @@ -115,11 +117,15 @@ public: std::copy(data, data + count, out); } } - template - void load(const VertArray data) { - static_assert(std::is_same_v, VertStruct>, "mismatched type"); - constexpr size_t count = sizeof(VertArray) / sizeof(VertStruct); - load(data, count); + template + void load(const ContiguousContainer& container) { + // All contiguous containers (even those that aren't containers like C arrays) are usable + // with std::begin(). Because of that, we can use it to deduce the contained type. + static_assert(std::is_same_v()))>, + VertStruct>, + "Supplied container doesn't contain same type of vertex struct"); + + load(std::data(container), std::size(container)); } operator const boo::ObjToken&() { return m_shaderBinding; } From b0c865ba81fe6b53f49f32f6c222988a5b1c4202 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 1 Sep 2019 02:37:57 -0400 Subject: [PATCH 05/23] Toolbar: Correct log module name This isn't the space-related code, so we can amend this. --- specter/lib/Toolbar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specter/lib/Toolbar.cpp b/specter/lib/Toolbar.cpp index ccf55205b..dd88c4746 100644 --- a/specter/lib/Toolbar.cpp +++ b/specter/lib/Toolbar.cpp @@ -6,7 +6,7 @@ #define TOOLBAR_PADDING 10 namespace specter { -static logvisor::Module Log("specter::Space"); +static logvisor::Module Log("specter::Toolbar"); static const zeus::RGBA32 Tex[] = {{{255, 255, 255, 64}}, {{255, 255, 255, 64}}, {{0, 0, 0, 64}}, {{0, 0, 0, 64}}}; From 8073b3ea6226dda4367dd100e16dc9107b0df99f Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 1 Sep 2019 02:44:18 -0400 Subject: [PATCH 06/23] CMakeLists: Add standard-compliance flags for MSVC Enforces standard compliant behavior capable by MSVC. --- specter/CMakeLists.txt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/specter/CMakeLists.txt b/specter/CMakeLists.txt index 6bd90414c..9aece31b3 100644 --- a/specter/CMakeLists.txt +++ b/specter/CMakeLists.txt @@ -63,6 +63,25 @@ add_library(specter include/specter/specter.hpp ) +if (MSVC) + target_compile_options(specter PRIVATE + # Enforce various standards compliant behavior. + /permissive- + + # Enable standard volatile semantics. + /volatile:iso + + # Reports the proper value for the __cplusplus preprocessor macro. + /Zc:__cplusplus + + # Allow constexpr variables to have explicit external linkage. + /Zc:externConstexpr + + # Assume that new throws exceptions, allowing better code generation. + /Zc:throwingNew + ) +endif() + target_link_libraries(specter PUBLIC freetype hecl-full From 8eef6471f20585c1a806f9aedea9faa42360e19e Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Sun, 1 Sep 2019 11:07:32 -0700 Subject: [PATCH 07/23] Update zeus --- specter/zeus | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specter/zeus b/specter/zeus index c5d90a5d5..050e86aae 160000 --- a/specter/zeus +++ b/specter/zeus @@ -1 +1 @@ -Subproject commit c5d90a5d5efe436d1a06568be911cfafa973dd83 +Subproject commit 050e86aae8f920a74466d8ab5e3d94330af9573a From ba2e7b22a94b33e12663e400e5a586fa452c61f8 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 3 Sep 2019 16:52:51 -0400 Subject: [PATCH 08/23] ModalWindow: Migrate from zeus::clamp to std::clamp Migrates to standard library facilities. --- specter/lib/ModalWindow.cpp | 52 +++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/specter/lib/ModalWindow.cpp b/specter/lib/ModalWindow.cpp index 8b63c77a8..ba6adc697 100644 --- a/specter/lib/ModalWindow.cpp +++ b/specter/lib/ModalWindow.cpp @@ -1,5 +1,7 @@ #include "specter/ModalWindow.hpp" +#include + #include "specter/MultiLineTextView.hpp" #include "specter/RootView.hpp" #include "specter/ViewResources.hpp" @@ -20,9 +22,9 @@ namespace specter { #define WINDOW_MIN_DIM 16 void ModalWindow::setLineVerts(int width, int height, float pf, float t) { - std::pair margin = m_cornersOutline[0]->queryGlyphDimensions(0); - float t1 = zeus::clamp(0.f, t * 2.f, 1.f); - float t2 = zeus::clamp(0.f, t * 2.f - 1.f, 1.f); + const std::pair margin = m_cornersOutline[0]->queryGlyphDimensions(0); + const float t1 = std::clamp(t * 2.f, 0.f, 1.f); + const float t2 = std::clamp(t * 2.f - 1.f, 0.f, 1.f); float lineLeft = 0; float lineRight = pf * LINE_WIDTH; @@ -68,9 +70,9 @@ void ModalWindow::setLineVerts(int width, int height, float pf, float t) { } void ModalWindow::setLineVertsOut(int width, int height, float pf, float t) { - std::pair margin = m_cornersOutline[0]->queryGlyphDimensions(0); - float t1 = zeus::clamp(0.f, t * 2.f - 1.f, 1.f); - float t2 = zeus::clamp(0.f, t * 2.f, 1.f); + const std::pair margin = m_cornersOutline[0]->queryGlyphDimensions(0); + const float t1 = std::clamp(t * 2.f - 1.f, 0.f, 1.f); + const float t2 = std::clamp(t * 2.f, 0.f, 1.f); float lineLeft = 0; float lineRight = pf * LINE_WIDTH; @@ -116,13 +118,13 @@ void ModalWindow::setLineVertsOut(int width, int height, float pf, float t) { } void ModalWindow::setLineColors(float t) { - float t1 = zeus::clamp(0.f, t * 2.f, 1.f); - float t2 = zeus::clamp(0.f, t * 2.f - 1.f, 1.f); - float t3 = zeus::clamp(0.f, t * 2.f - 2.f, 1.f); + const float t1 = std::clamp(t * 2.f, 0.f, 1.f); + const float t2 = std::clamp(t * 2.f - 1.f, 0.f, 1.f); + const float t3 = std::clamp(t * 2.f - 2.f, 0.f, 1.f); - zeus::CColor c1 = zeus::CColor::lerp(m_line1, m_line2, t1); - zeus::CColor c2 = zeus::CColor::lerp(m_line1, m_line2, t2); - zeus::CColor c3 = zeus::CColor::lerp(m_line1, m_line2, t3); + const zeus::CColor c1 = zeus::CColor::lerp(m_line1, m_line2, t1); + const zeus::CColor c2 = zeus::CColor::lerp(m_line1, m_line2, t2); + const zeus::CColor c3 = zeus::CColor::lerp(m_line1, m_line2, t3); m_cornersOutline[0]->colorGlyphs(c1); if (t < 0.5) { @@ -167,13 +169,13 @@ void ModalWindow::setLineColors(float t) { } void ModalWindow::setLineColorsOut(float t) { - float t1 = zeus::clamp(0.f, t * 2.f, 1.f); - float t2 = zeus::clamp(0.f, t * 2.f - 1.f, 1.f); - float t3 = zeus::clamp(0.f, t * 2.f - 2.f, 1.f); + const float t1 = std::clamp(t * 2.f, 0.f, 1.f); + const float t2 = std::clamp(t * 2.f - 1.f, 0.f, 1.f); + const float t3 = std::clamp(t * 2.f - 2.f, 0.f, 1.f); - zeus::CColor c1 = zeus::CColor::lerp(m_line2Clear, m_line2, t1); - zeus::CColor c2 = zeus::CColor::lerp(m_line2Clear, m_line2, t2); - zeus::CColor c3 = zeus::CColor::lerp(m_line2Clear, m_line2, t3); + const zeus::CColor c1 = zeus::CColor::lerp(m_line2Clear, m_line2, t1); + const zeus::CColor c2 = zeus::CColor::lerp(m_line2Clear, m_line2, t2); + const zeus::CColor c3 = zeus::CColor::lerp(m_line2Clear, m_line2, t3); m_cornersOutline[2]->colorGlyphs(c1); if (t < 0.5) { @@ -253,7 +255,7 @@ void ModalWindow::setFillVerts(int width, int height, float pf) { } void ModalWindow::setFillColors(float t) { - t = zeus::clamp(0.f, t, 1.f); + t = std::clamp(t, 0.f, 1.f); zeus::CColor color = zeus::CColor::lerp(m_windowBgClear, m_windowBg, t); for (int i = 0; i < 16; ++i) @@ -324,7 +326,7 @@ void ModalWindow::think() { int doneCount = 0; if (m_frame > WIRE_START) { float wt = (m_frame - WIRE_START) / float(WIRE_FRAMES); - wt = zeus::clamp(0.f, wt, 2.f); + wt = std::clamp(wt, 0.f, 2.f); m_lineTime = CubicEase(wt); setLineVerts(m_width, m_height, pf, m_lineTime); setLineColors(wt); @@ -334,7 +336,7 @@ void ModalWindow::think() { } if (m_frame > SOLID_START) { float ft = (m_frame - SOLID_START) / float(SOLID_FRAMES); - ft = zeus::clamp(0.f, ft, 2.f); + ft = std::clamp(ft, 0.f, 2.f); setFillColors(ft); if (ft == 2.f) ++doneCount; @@ -344,7 +346,7 @@ void ModalWindow::think() { if (!m_contentStartFrame) m_contentStartFrame = m_frame; float tt = (m_frame - m_contentStartFrame) / float(CONTENT_FRAMES); - tt = zeus::clamp(0.f, tt, 1.f); + tt = std::clamp(tt, 0.f, 1.f); updateContentOpacity(tt); if (tt == 1.f) ++doneCount; @@ -366,7 +368,7 @@ void ModalWindow::think() { case Phase::BuildOut: { { float wt = (WIRE_FRAMES - m_frame) / float(WIRE_FRAMES); - wt = zeus::clamp(0.f, wt, 1.f); + wt = std::clamp(wt, 0.f, 1.f); m_lineTime = CubicEase(wt); setLineVertsOut(m_width, m_height, pf, m_lineTime); setLineColorsOut(wt); @@ -375,12 +377,12 @@ void ModalWindow::think() { } { float ft = (SOLID_FRAMES - m_frame) / float(SOLID_FRAMES); - ft = zeus::clamp(0.f, ft, 1.f); + ft = std::clamp(ft, 0.f, 1.f); setFillColors(ft); } if (res.fontCacheReady()) { float tt = (CONTENT_FRAMES - m_frame) / float(CONTENT_FRAMES); - tt = zeus::clamp(0.f, tt, 1.f); + tt = std::clamp(tt, 0.f, 1.f); updateContentOpacity(tt); } _loadVerts(); From acc39c38522f06c06e280d204f698a7ade08688e Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Tue, 3 Sep 2019 23:10:37 -0700 Subject: [PATCH 09/23] Update zeus --- specter/zeus | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specter/zeus b/specter/zeus index 050e86aae..35127116f 160000 --- a/specter/zeus +++ b/specter/zeus @@ -1 +1 @@ -Subproject commit 050e86aae8f920a74466d8ab5e3d94330af9573a +Subproject commit 35127116f83bd2055702dc59ed6f244c9854676b From d65fec7e2b3ec2788a17fdce42a6e36f3140468a Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Wed, 4 Sep 2019 19:36:06 -0700 Subject: [PATCH 10/23] Update zeus --- specter/zeus | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specter/zeus b/specter/zeus index 35127116f..63ecd3181 160000 --- a/specter/zeus +++ b/specter/zeus @@ -1 +1 @@ -Subproject commit 35127116f83bd2055702dc59ed6f244c9854676b +Subproject commit 63ecd3181380726d7e3fefbad6a7de33dc53e3c2 From 5beb046f9eba558700074dd9c296f86b19540bd1 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 5 Sep 2019 00:42:16 -0400 Subject: [PATCH 11/23] General: Add necessary includes where applicable As part of the changes within hecl, this exposed a few indirect inclusions. We can simply include the headers to resolve these cases. --- specter/include/specter/RootView.hpp | 1 + specter/lib/Button.cpp | 1 + specter/lib/Icon.cpp | 2 ++ specter/lib/Menu.cpp | 2 ++ specter/lib/ModalWindow.cpp | 1 + specter/lib/PathButtons.cpp | 2 ++ specter/lib/RootView.cpp | 1 + specter/lib/ScrollView.cpp | 2 ++ specter/lib/Space.cpp | 1 + specter/lib/SplitView.cpp | 7 +++++-- specter/lib/Table.cpp | 3 +++ specter/lib/TextField.cpp | 2 ++ specter/lib/Toolbar.cpp | 7 +++++-- specter/lib/Tooltip.cpp | 2 ++ 14 files changed, 30 insertions(+), 4 deletions(-) diff --git a/specter/include/specter/RootView.hpp b/specter/include/specter/RootView.hpp index 2bf6c5d56..d0a6678f3 100644 --- a/specter/include/specter/RootView.hpp +++ b/specter/include/specter/RootView.hpp @@ -11,6 +11,7 @@ #include "specter/View.hpp" #include +#include #include #include #include diff --git a/specter/lib/Button.cpp b/specter/lib/Button.cpp index 449408cf7..4af7183a3 100644 --- a/specter/lib/Button.cpp +++ b/specter/lib/Button.cpp @@ -5,6 +5,7 @@ #include "specter/TextView.hpp" #include "specter/ViewResources.hpp" +#include #include namespace specter { diff --git a/specter/lib/Icon.cpp b/specter/lib/Icon.cpp index efb004d45..025b2e29d 100644 --- a/specter/lib/Icon.cpp +++ b/specter/lib/Icon.cpp @@ -1,6 +1,8 @@ #include "specter/Icon.hpp" #include "specter/RootView.hpp" +#include + namespace specter { IconView::IconView(ViewResources& res, View& parentView, Icon& icon) : View(res, parentView) { diff --git a/specter/lib/Menu.cpp b/specter/lib/Menu.cpp index 27ceefa0c..6f75abcc1 100644 --- a/specter/lib/Menu.cpp +++ b/specter/lib/Menu.cpp @@ -6,6 +6,8 @@ #include "specter/TextView.hpp" #include "specter/ViewResources.hpp" +#include + #define ROW_HEIGHT 18 #define ITEM_MARGIN 1 diff --git a/specter/lib/ModalWindow.cpp b/specter/lib/ModalWindow.cpp index ba6adc697..de5d36d0e 100644 --- a/specter/lib/ModalWindow.cpp +++ b/specter/lib/ModalWindow.cpp @@ -7,6 +7,7 @@ #include "specter/ViewResources.hpp" #include +#include namespace specter { diff --git a/specter/lib/PathButtons.cpp b/specter/lib/PathButtons.cpp index d4ff13b56..79833537e 100644 --- a/specter/lib/PathButtons.cpp +++ b/specter/lib/PathButtons.cpp @@ -4,6 +4,8 @@ #include "specter/RootView.hpp" #include "specter/ViewResources.hpp" +#include + namespace specter { struct PathButtons::PathButton final : IButtonBinding { PathButtons& m_pb; diff --git a/specter/lib/RootView.cpp b/specter/lib/RootView.cpp index 1140c9104..099cd84bf 100644 --- a/specter/lib/RootView.cpp +++ b/specter/lib/RootView.cpp @@ -8,6 +8,7 @@ #include "specter/Tooltip.hpp" #include "specter/ViewResources.hpp" +#include #include namespace specter { diff --git a/specter/lib/ScrollView.cpp b/specter/lib/ScrollView.cpp index 64550d9fb..5abb8f291 100644 --- a/specter/lib/ScrollView.cpp +++ b/specter/lib/ScrollView.cpp @@ -7,6 +7,8 @@ #include "specter/RootView.hpp" #include "specter/ViewResources.hpp" +#include + namespace specter { #define MAX_SCROLL_SPEED 100 diff --git a/specter/lib/Space.cpp b/specter/lib/Space.cpp index e444799b0..140731362 100644 --- a/specter/lib/Space.cpp +++ b/specter/lib/Space.cpp @@ -4,6 +4,7 @@ #include "specter/RootView.hpp" #include "specter/ViewResources.hpp" +#include #include namespace specter { diff --git a/specter/lib/SplitView.cpp b/specter/lib/SplitView.cpp index 207738485..7551e9d28 100644 --- a/specter/lib/SplitView.cpp +++ b/specter/lib/SplitView.cpp @@ -1,8 +1,11 @@ -#include "logvisor/logvisor.hpp" #include "specter/SplitView.hpp" + +#include "specter/Space.hpp" #include "specter/RootView.hpp" #include "specter/ViewResources.hpp" -#include "specter/Space.hpp" + +#include +#include namespace specter { static logvisor::Module Log("specter::SplitView"); diff --git a/specter/lib/Table.cpp b/specter/lib/Table.cpp index c5563633f..a43a2aa1b 100644 --- a/specter/lib/Table.cpp +++ b/specter/lib/Table.cpp @@ -2,9 +2,12 @@ #include "specter/RootView.hpp" #include "specter/ScrollView.hpp" + #include "specter/TextView.hpp" #include "specter/ViewResources.hpp" +#include + namespace specter { static logvisor::Module Log("specter::Table"); #define ROW_HEIGHT 18 diff --git a/specter/lib/TextField.cpp b/specter/lib/TextField.cpp index 3e924469a..05584af57 100644 --- a/specter/lib/TextField.cpp +++ b/specter/lib/TextField.cpp @@ -4,6 +4,8 @@ #include "specter/TextView.hpp" #include "specter/ViewResources.hpp" +#include + namespace specter { TextField::TextField(ViewResources& res, View& parentView, IStringBinding* strBind) diff --git a/specter/lib/Toolbar.cpp b/specter/lib/Toolbar.cpp index dd88c4746..10d93d5aa 100644 --- a/specter/lib/Toolbar.cpp +++ b/specter/lib/Toolbar.cpp @@ -1,7 +1,10 @@ -#include "logvisor/logvisor.hpp" #include "specter/Toolbar.hpp" -#include "specter/ViewResources.hpp" + #include "specter/RootView.hpp" +#include "specter/ViewResources.hpp" + +#include +#include #define TOOLBAR_PADDING 10 diff --git a/specter/lib/Tooltip.cpp b/specter/lib/Tooltip.cpp index e2a30cd93..3d07b3051 100644 --- a/specter/lib/Tooltip.cpp +++ b/specter/lib/Tooltip.cpp @@ -4,6 +4,8 @@ #include "specter/RootView.hpp" #include "specter/ViewResources.hpp" +#include + namespace specter { #define TOOLTIP_MAX_WIDTH 316 From ba7a48764d7dcd4211b7e4827d6251e056123187 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 5 Sep 2019 18:57:23 -0400 Subject: [PATCH 12/23] FileBrowser: Move constructor definition into cpp file Avoids requiring hecl.hpp to be included within the header. --- specter/include/specter/FileBrowser.hpp | 3 +-- specter/lib/FileBrowser.cpp | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/specter/include/specter/FileBrowser.hpp b/specter/include/specter/FileBrowser.hpp index b49743296..2b02ff574 100644 --- a/specter/include/specter/FileBrowser.hpp +++ b/specter/include/specter/FileBrowser.hpp @@ -226,8 +226,7 @@ private: public: FileBrowser(ViewResources& res, View& parentView, std::string_view title, Type type, - std::function returnFunc) - : FileBrowser(res, parentView, title, type, hecl::GetcwdStr(), returnFunc) {} + std::function returnFunc); FileBrowser(ViewResources& res, View& parentView, std::string_view title, Type type, hecl::SystemStringView initialPath, std::function returnFunc); ~FileBrowser() override; diff --git a/specter/lib/FileBrowser.cpp b/specter/lib/FileBrowser.cpp index 3ae19a947..3b9bd59d6 100644 --- a/specter/lib/FileBrowser.cpp +++ b/specter/lib/FileBrowser.cpp @@ -43,6 +43,10 @@ std::vector FileBrowser::PathComponents(hecl::SystemStringVi return ret; } +FileBrowser::FileBrowser(ViewResources& res, View& parentView, std::string_view title, Type type, + std::function returnFunc) +: FileBrowser(res, parentView, title, type, hecl::GetcwdStr(), std::move(returnFunc)) {} + FileBrowser::FileBrowser(ViewResources& res, View& parentView, std::string_view title, Type type, hecl::SystemStringView initialPath, std::function returnFunc) From b25cfdd3051333e3d226b26aba8dd37aefb5f9f1 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 5 Sep 2019 19:03:58 -0400 Subject: [PATCH 13/23] FontCache: Default destructor within the cpp file Avoids potentially inlining a lot of repeated destruction logic. This also allows the class to play nicer with forward declarations. While we're at it, we can also explicitly delete the move assignment/constructor (previously they were implicitly deleted, given the class contains a const reference). --- specter/include/specter/FontCache.hpp | 2 ++ specter/lib/FontCache.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/specter/include/specter/FontCache.hpp b/specter/include/specter/FontCache.hpp index fc291e426..fe1f14e03 100644 --- a/specter/include/specter/FontCache.hpp +++ b/specter/include/specter/FontCache.hpp @@ -176,6 +176,8 @@ class FontCache { public: FontCache(const hecl::Runtime::FileStoreManager& fileMgr); + ~FontCache(); + FontCache(const FontCache& other) = delete; FontCache& operator=(const FontCache& other) = delete; diff --git a/specter/lib/FontCache.cpp b/specter/lib/FontCache.cpp index 1add829ac..c6ba42461 100644 --- a/specter/lib/FontCache.cpp +++ b/specter/lib/FontCache.cpp @@ -613,6 +613,8 @@ FontCache::FontCache(const hecl::Runtime::FileStoreManager& fileMgr) hecl::MakeDir(m_cacheRoot.c_str()); } +FontCache::~FontCache() = default; + FontTag FontCache::prepCustomFont(std::string_view name, FT_Face face, FCharFilter filter, bool subpixel, float points, uint32_t dpi) { /* Quick validation */ From 5c54fd73a1ce48ebc0e23e6a96d0f46995bfb298 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 5 Sep 2019 19:19:06 -0400 Subject: [PATCH 14/23] FontCache: Make filters non-allocating Avoids the creation of three allocating static constructors that run during program start. --- specter/include/specter/FontCache.hpp | 3 +-- specter/lib/FontCache.cpp | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/specter/include/specter/FontCache.hpp b/specter/include/specter/FontCache.hpp index fe1f14e03..88155ca00 100644 --- a/specter/include/specter/FontCache.hpp +++ b/specter/include/specter/FontCache.hpp @@ -5,7 +5,6 @@ #include #include -#include #include #include #include @@ -66,7 +65,7 @@ public: } }; -using FCharFilter = std::pair>; +using FCharFilter = std::pair; class FontAtlas { FT_Face m_face; diff --git a/specter/lib/FontCache.cpp b/specter/lib/FontCache.cpp index c6ba42461..db491ec09 100644 --- a/specter/lib/FontCache.cpp +++ b/specter/lib/FontCache.cpp @@ -43,15 +43,16 @@ extern "C" const FT_Driver_ClassRec tt_driver_class; namespace specter { static logvisor::Module Log("specter::FontCache"); -const FCharFilter AllCharFilter = std::make_pair("all-glyphs", [](uint32_t) -> bool { return true; }); +const FCharFilter AllCharFilter{"all-glyphs", [](uint32_t) { return true; }}; -const FCharFilter LatinCharFilter = - std::make_pair("latin-glyphs", [](uint32_t c) -> bool { return c <= 0xff || ((c - 0x2200) <= (0x23FF - 0x2200)); }); +const FCharFilter LatinCharFilter{"latin-glyphs", + [](uint32_t c) { return c <= 0xff || (c - 0x2200) <= (0x23FF - 0x2200); }}; -const FCharFilter LatinAndJapaneseCharFilter = std::make_pair("latin-and-jp-glyphs", [](uint32_t c) -> bool { - return LatinCharFilter.second(c) || ((c - 0x2E00) <= (0x30FF - 0x2E00)) || ((c - 0x4E00) <= (0x9FFF - 0x4E00)) || - ((c - 0xFF00) <= (0xFFEF - 0xFF00)); -}); +const FCharFilter LatinAndJapaneseCharFilter{"latin-and-jp-glyphs", [](uint32_t c) { + return LatinCharFilter.second(c) || (c - 0x2E00) <= (0x30FF - 0x2E00) || + (c - 0x4E00) <= (0x9FFF - 0x4E00) || + (c - 0xFF00) <= (0xFFEF - 0xFF00); + }}; FontTag::FontTag(std::string_view name, bool subpixel, float points, uint32_t dpi) { XXH64_state_t st; @@ -628,10 +629,11 @@ FontTag FontCache::prepCustomFont(std::string_view name, FT_Face face, FCharFilt FT_Set_Char_Size(face, 0, points * 64.0, 0, dpi); /* Make tag and search for cached version */ - FontTag tag(std::string(name) + '_' + filter.first, subpixel, points, dpi); - auto search = m_cachedAtlases.find(tag); - if (search != m_cachedAtlases.end()) + const FontTag tag(std::string(name).append(1, '_').append(filter.first), subpixel, points, dpi); + const auto search = m_cachedAtlases.find(tag); + if (search != m_cachedAtlases.end()) { return tag; + } /* Now check filesystem cache */ hecl::SystemString cachePath = m_cacheRoot + _SYS_STR('/') + fmt::format(fmt(_SYS_STR("{}")), tag.hash()); From fa56ba5db641979b89f5c72ca1d2b91ffe67356d Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 5 Sep 2019 19:36:40 -0400 Subject: [PATCH 15/23] General: Use emplace_back's return value where applicable emplace_back() returns a reference to the added element, so we can use that instead of querying right after the emplacement. --- specter/lib/FileBrowser.cpp | 3 +-- specter/lib/FontCache.cpp | 28 ++++++++++++---------------- specter/lib/Menu.cpp | 4 +--- specter/lib/Toolbar.cpp | 10 ++++++---- 4 files changed, 20 insertions(+), 25 deletions(-) diff --git a/specter/lib/FileBrowser.cpp b/specter/lib/FileBrowser.cpp index 3ae19a947..a902cfb64 100644 --- a/specter/lib/FileBrowser.cpp +++ b/specter/lib/FileBrowser.cpp @@ -334,8 +334,7 @@ void FileBrowser::FileListingDataBind::updateListing(const hecl::DirectoryEnumer m_entries.reserve(dEnum.size()); for (const hecl::DirectoryEnumerator::Entry& d : dEnum) { - m_entries.emplace_back(); - Entry& ent = m_entries.back(); + Entry& ent = m_entries.emplace_back(); ent.m_path = d.m_path; hecl::SystemUTF8Conv nameUtf8(d.m_name); ent.m_name = nameUtf8.str(); diff --git a/specter/lib/FontCache.cpp b/specter/lib/FontCache.cpp index 1add829ac..4f3bdf88d 100644 --- a/specter/lib/FontCache.cpp +++ b/specter/lib/FontCache.cpp @@ -307,13 +307,10 @@ FontAtlas::FontAtlas(FT_Face face, uint32_t dpi, bool subpixel, FCharFilter& fil charcode = FT_Get_Next_Char(face, charcode, &gindex); continue; } + FT_Load_Glyph(face, gindex, FT_LOAD_RENDER | baseFlags); FT_UInt width, height; GridFitGlyph(face->glyph, width, height); - m_glyphLookup[charcode] = m_glyphs.size(); - m_glyphs.emplace_back(); - Glyph& g = m_glyphs.back(); - if (curLineWidth + width + 1 > TEXMAP_DIM) { totalHeight += curLineHeight + 1; curLineHeight = 0; @@ -328,6 +325,8 @@ FontAtlas::FontAtlas(FT_Face face, uint32_t dpi, bool subpixel, FCharFilter& fil curLineWidth = 1; } + m_glyphLookup.insert_or_assign(charcode, m_glyphs.size()); + Glyph& g = m_glyphs.emplace_back(); g.m_unicodePoint = charcode; g.m_glyphIdx = gindex; g.m_layerIdx = m_fullTexmapLayers; @@ -369,13 +368,10 @@ FontAtlas::FontAtlas(FT_Face face, uint32_t dpi, bool subpixel, FCharFilter& fil charcode = FT_Get_Next_Char(face, charcode, &gindex); continue; } + FT_Load_Glyph(face, gindex, FT_LOAD_RENDER | baseFlags); FT_UInt width, height; GridFitGlyph(face->glyph, width, height); - m_glyphLookup[charcode] = m_glyphs.size(); - m_glyphs.emplace_back(); - Glyph& g = m_glyphs.back(); - if (curLineWidth + width + 1 > TEXMAP_DIM) { totalHeight += curLineHeight + 1; curLineHeight = 0; @@ -390,6 +386,8 @@ FontAtlas::FontAtlas(FT_Face face, uint32_t dpi, bool subpixel, FCharFilter& fil curLineWidth = 1; } + m_glyphLookup.insert_or_assign(charcode, m_glyphs.size()); + Glyph& g = m_glyphs.emplace_back(); g.m_unicodePoint = charcode; g.m_glyphIdx = gindex; g.m_layerIdx = m_fullTexmapLayers; @@ -468,13 +466,10 @@ FontAtlas::FontAtlas(FT_Face face, uint32_t dpi, bool subpixel, FCharFilter& fil charcode = FT_Get_Next_Char(face, charcode, &gindex); continue; } + FT_Load_Glyph(face, gindex, baseFlags); FT_UInt width, height; GridFitGlyph(face->glyph, width, height); - m_glyphLookup[charcode] = m_glyphs.size(); - m_glyphs.emplace_back(); - Glyph& g = m_glyphs.back(); - if (curLineWidth + width + 1 > TEXMAP_DIM) { totalHeight += curLineHeight + 1; curLineHeight = 0; @@ -489,6 +484,8 @@ FontAtlas::FontAtlas(FT_Face face, uint32_t dpi, bool subpixel, FCharFilter& fil curLineWidth = 1; } + m_glyphLookup.insert_or_assign(charcode, m_glyphs.size()); + Glyph& g = m_glyphs.emplace_back(); g.m_unicodePoint = charcode; g.m_glyphIdx = gindex; g.m_layerIdx = m_fullTexmapLayers; @@ -530,13 +527,10 @@ FontAtlas::FontAtlas(FT_Face face, uint32_t dpi, bool subpixel, FCharFilter& fil charcode = FT_Get_Next_Char(face, charcode, &gindex); continue; } + FT_Load_Glyph(face, gindex, baseFlags); FT_UInt width, height; GridFitGlyph(face->glyph, width, height); - m_glyphLookup[charcode] = m_glyphs.size(); - m_glyphs.emplace_back(); - Glyph& g = m_glyphs.back(); - if (curLineWidth + width + 1 > TEXMAP_DIM) { totalHeight += curLineHeight + 1; curLineHeight = 0; @@ -551,6 +545,8 @@ FontAtlas::FontAtlas(FT_Face face, uint32_t dpi, bool subpixel, FCharFilter& fil curLineWidth = 1; } + m_glyphLookup.insert_or_assign(charcode, m_glyphs.size()); + Glyph& g = m_glyphs.emplace_back(); g.m_unicodePoint = charcode; g.m_glyphIdx = gindex; g.m_layerIdx = m_fullTexmapLayers; diff --git a/specter/lib/Menu.cpp b/specter/lib/Menu.cpp index 6f75abcc1..9eb319817 100644 --- a/specter/lib/Menu.cpp +++ b/specter/lib/Menu.cpp @@ -55,9 +55,7 @@ void Menu::reset(IMenuNode* rootNode) { for (size_t i = 0; i < subCount; ++i) { IMenuNode* node = rootNode->subNode(i); const std::string* nodeText = node->text(); - - m_items.emplace_back(); - ViewChild>& item = m_items.back(); + ViewChild>& item = m_items.emplace_back(); if (nodeText) { item.m_view.reset(new ItemView(res, *this, *nodeText, i, node)); diff --git a/specter/lib/Toolbar.cpp b/specter/lib/Toolbar.cpp index 10d93d5aa..c585c3b57 100644 --- a/specter/lib/Toolbar.cpp +++ b/specter/lib/Toolbar.cpp @@ -115,11 +115,13 @@ void Toolbar::setVerticalVerts(int height) { } void Toolbar::push_back(View* v, unsigned unit) { - if (unit >= m_units) + if (unit >= m_units) { Log.report(logvisor::Fatal, fmt("unit {} out of range {}"), unit, m_units); - std::vector>& u = m_children[unit]; - u.emplace_back(); - u.back().m_view = v; + } + + std::vector>& children = m_children[unit]; + auto& child = children.emplace_back(); + child.m_view = v; } void Toolbar::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub) { From 4e71b955f601394d4b7e687a4c97baa570fc23c4 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 5 Sep 2019 19:54:14 -0400 Subject: [PATCH 16/23] General: Replace loop with resize where applicable Instead of default constructing in a loop for std::vector, we can just use resize or its size constructor to do the same thing. --- specter/lib/Table.cpp | 8 ++------ specter/lib/Toolbar.cpp | 4 +--- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/specter/lib/Table.cpp b/specter/lib/Table.cpp index a43a2aa1b..b97e9ca88 100644 --- a/specter/lib/Table.cpp +++ b/specter/lib/Table.cpp @@ -525,9 +525,7 @@ bool Table::CellView::reset(size_t c, size_t r) { std::vector& Table::ensureCellPools(size_t rows, size_t cols, ViewResources& res) { if (m_cellPools.size() < cols) { - m_cellPools.reserve(cols); - for (size_t i = m_cellPools.size(); i < cols; ++i) - m_cellPools.emplace_back(); + m_cellPools.resize(cols); m_ensuredRows = 0; } if (m_ensuredRows < rows) { @@ -569,9 +567,7 @@ void Table::_updateData() { if (newViewChildren) { m_headerViews.clear(); m_cellPools.clear(); - m_headerViews.reserve(m_columns); - for (size_t c = 0; c < m_columns; ++c) - m_headerViews.emplace_back(); + m_headerViews.resize(m_columns); m_ensuredRows = 0; } ensureCellPools(m_rows, m_columns, res); diff --git a/specter/lib/Toolbar.cpp b/specter/lib/Toolbar.cpp index c585c3b57..9300ab6fd 100644 --- a/specter/lib/Toolbar.cpp +++ b/specter/lib/Toolbar.cpp @@ -20,11 +20,9 @@ void Toolbar::Resources::init(boo::IGraphicsDataFactory::Context& ctx, const ITh Toolbar::Toolbar(ViewResources& res, View& parentView, Position tbPos, unsigned units) : View(res, parentView) , m_units(units) +, m_children(units) , m_nomGauge(res.pixelFactor() * SPECTER_TOOLBAR_GAUGE * units) , m_padding(res.pixelFactor() * TOOLBAR_PADDING) { - m_children.reserve(units); - for (unsigned u = 0; u < units; ++u) - m_children.emplace_back(); commitResources(res, [&](boo::IGraphicsDataFactory::Context& ctx) -> bool { buildResources(ctx, res); m_tbBlockBuf = res.m_viewRes.m_bufPool.allocateBlock(res.m_factory); From 909e7d69ee6cd20e52ec60d9baa7dcf66a259739 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 5 Sep 2019 20:16:03 -0400 Subject: [PATCH 17/23] General: Remove unused file-scope variables Removes unused logvisor modules. This also allows removing some inclusions. Silences a few unused variable warnings as well. --- specter/lib/FileBrowser.cpp | 3 --- specter/lib/RootView.cpp | 2 -- specter/lib/Space.cpp | 3 --- specter/lib/View.cpp | 3 --- 4 files changed, 11 deletions(-) diff --git a/specter/lib/FileBrowser.cpp b/specter/lib/FileBrowser.cpp index 3ae19a947..9901f283b 100644 --- a/specter/lib/FileBrowser.cpp +++ b/specter/lib/FileBrowser.cpp @@ -7,11 +7,8 @@ #include "specter/TextField.hpp" #include -#include namespace specter { -static logvisor::Module Log("specter::FileBrowser"); - #define BROWSER_MARGIN 8 #define BROWSER_MIN_WIDTH 600 #define BROWSER_MIN_HEIGHT 300 diff --git a/specter/lib/RootView.cpp b/specter/lib/RootView.cpp index 099cd84bf..3e8ceeb03 100644 --- a/specter/lib/RootView.cpp +++ b/specter/lib/RootView.cpp @@ -9,10 +9,8 @@ #include "specter/ViewResources.hpp" #include -#include namespace specter { -static logvisor::Module Log("specter::RootView"); RootView::RootView(IViewManager& viewMan, ViewResources& res, boo::IWindow* window) : View(res), m_window(window), m_viewMan(viewMan), m_viewRes(&res), m_events(*this) { diff --git a/specter/lib/Space.cpp b/specter/lib/Space.cpp index 140731362..963b0cd36 100644 --- a/specter/lib/Space.cpp +++ b/specter/lib/Space.cpp @@ -5,11 +5,8 @@ #include "specter/ViewResources.hpp" #include -#include namespace specter { -static logvisor::Module Log("specter::Space"); - #define TRIANGLE_DIM 12 #define TRIANGLE_DIM1 10 #define TRIANGLE_DIM2 8 diff --git a/specter/lib/View.cpp b/specter/lib/View.cpp index 4024394ea..ba535ade5 100644 --- a/specter/lib/View.cpp +++ b/specter/lib/View.cpp @@ -5,11 +5,8 @@ #include #include -#include namespace specter { -static logvisor::Module Log("specter::View"); - zeus::CMatrix4f g_PlatformMatrix; void View::Resources::init(boo::IGraphicsDataFactory::Context& ctx, const IThemeData& theme) { From 765c51776be8151ee89a04fb3de23e2ee4b11501 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 5 Sep 2019 18:16:21 -0400 Subject: [PATCH 18/23] General: Use std::make_unique where applicable No behavior change. --- specter/lib/Button.cpp | 22 ++++++----- specter/lib/FileBrowser.cpp | 61 +++++++++++++++---------------- specter/lib/Menu.cpp | 18 ++++----- specter/lib/MessageWindow.cpp | 16 ++++---- specter/lib/ModalWindow.cpp | 6 +-- specter/lib/MultiLineTextView.cpp | 14 +++---- specter/lib/PathButtons.cpp | 4 +- specter/lib/RootView.cpp | 14 +++---- specter/lib/ScrollView.cpp | 4 +- specter/lib/Space.cpp | 10 +++-- specter/lib/Table.cpp | 38 +++++++++++-------- specter/lib/TextField.cpp | 7 ++-- specter/lib/Tooltip.cpp | 8 ++-- specter/zeus | 2 +- 14 files changed, 118 insertions(+), 106 deletions(-) diff --git a/specter/lib/Button.cpp b/specter/lib/Button.cpp index 4af7183a3..01172d6f8 100644 --- a/specter/lib/Button.cpp +++ b/specter/lib/Button.cpp @@ -68,8 +68,8 @@ Button::Button(ViewResources& res, View& parentView, IButtonBinding* controlBind return true; }); - m_buttonTarget.m_view.reset(new ButtonTarget(res, *this)); - m_menuTarget.m_view.reset(new MenuTarget(res, *this)); + m_buttonTarget.m_view = std::make_unique(res, *this); + m_menuTarget.m_view = std::make_unique(res, *this); if (style == Style::Block) { zeus::CColor c1 = res.themeData().button1Inactive() * bgColor; @@ -97,13 +97,15 @@ Button::Button(ViewResources& res, View& parentView, IButtonBinding* controlBind m_verts[i].m_color = m_textColor; _loadVerts(); - if (controlBinding) + if (controlBinding != nullptr) { m_menuStyle = controlBinding->menuStyle(this); + } - if (icon) - m_icon.reset(new IconView(res, *this, *icon)); + if (icon != nullptr) { + m_icon = std::make_unique(res, *this, *icon); + } - m_text.reset(new TextView(res, *this, res.m_mainFont, TextView::Alignment::Center)); + m_text = std::make_unique(res, *this, res.m_mainFont, TextView::Alignment::Center); setText(m_textStr); } @@ -227,10 +229,12 @@ void Button::setText(std::string_view text, const zeus::CColor& textColor) { } void Button::setIcon(Icon* icon) { - if (icon) - m_icon.reset(new IconView(rootView().viewRes(), *this, *icon)); - else + if (icon != nullptr) { + m_icon = std::make_unique(rootView().viewRes(), *this, *icon); + } else { m_icon.reset(); + } + setText(m_textStr); updateSize(); } diff --git a/specter/lib/FileBrowser.cpp b/specter/lib/FileBrowser.cpp index 4bdad43ae..8bd40d402 100644 --- a/specter/lib/FileBrowser.cpp +++ b/specter/lib/FileBrowser.cpp @@ -60,23 +60,21 @@ FileBrowser::FileBrowser(ViewResources& res, View& parentView, std::string_view , m_systemBookmarkBind(*this) , m_projectBookmarkBind(*this) , m_recentBookmarkBind(*this) -, m_returnFunc(returnFunc) { +, m_returnFunc(std::move(returnFunc)) { setBackground({0, 0, 0, 0.5}); IViewManager& vm = rootView().viewManager(); - m_pathButtons.m_view.reset(new PathButtons(res, *this, *this)); - m_fileField.m_view.reset(new TextField(res, *this, &m_fileFieldBind)); - m_fileListing.m_view.reset(new Table(res, *this, &m_fileListingBind, &m_fileListingBind, 3)); - m_systemBookmarks.m_view.reset(new Table(res, *this, &m_systemBookmarkBind, &m_systemBookmarkBind, 1)); - m_systemBookmarksLabel.reset(new TextView(res, *this, res.m_mainFont)); - m_systemBookmarksLabel->typesetGlyphs(vm.translate(), - res.themeData().uiText()); - m_projectBookmarks.m_view.reset(new Table(res, *this, &m_projectBookmarkBind, &m_projectBookmarkBind, 1)); - m_projectBookmarksLabel.reset(new TextView(res, *this, res.m_mainFont)); - m_projectBookmarksLabel->typesetGlyphs(vm.translate(), - res.themeData().uiText()); - m_recentBookmarks.m_view.reset(new Table(res, *this, &m_recentBookmarkBind, &m_recentBookmarkBind, 1)); - m_recentBookmarksLabel.reset(new TextView(res, *this, res.m_mainFont)); + m_pathButtons.m_view = std::make_unique(res, *this, *this); + m_fileField.m_view = std::make_unique(res, *this, &m_fileFieldBind); + m_fileListing.m_view = std::make_unique(res, *this, &m_fileListingBind, &m_fileListingBind, 3); + m_systemBookmarks.m_view = std::make_unique
(res, *this, &m_systemBookmarkBind, &m_systemBookmarkBind, 1); + m_systemBookmarksLabel = std::make_unique(res, *this, res.m_mainFont); + m_systemBookmarksLabel->typesetGlyphs(vm.translate(), res.themeData().uiText()); + m_projectBookmarks.m_view = std::make_unique
(res, *this, &m_projectBookmarkBind, &m_projectBookmarkBind, 1); + m_projectBookmarksLabel = std::make_unique(res, *this, res.m_mainFont); + m_projectBookmarksLabel->typesetGlyphs(vm.translate(), res.themeData().uiText()); + m_recentBookmarks.m_view = std::make_unique
(res, *this, &m_recentBookmarkBind, &m_recentBookmarkBind, 1); + m_recentBookmarksLabel = std::make_unique(res, *this, res.m_mainFont); m_recentBookmarksLabel->typesetGlyphs(vm.translate(), res.themeData().uiText()); /* Populate system bookmarks */ @@ -99,8 +97,8 @@ FileBrowser::FileBrowser(ViewResources& res, View& parentView, std::string_view navigateToPath(initialPath); - m_split.m_view.reset(new SplitView(res, *this, nullptr, SplitView::Axis::Vertical, 0.2, 200 * res.pixelFactor(), - 400 * res.pixelFactor())); + m_split.m_view = std::make_unique(res, *this, nullptr, SplitView::Axis::Vertical, 0.2, + 200 * res.pixelFactor(), 400 * res.pixelFactor()); m_split.m_view->setContentView(0, &m_left); m_split.m_view->setContentView(1, &m_right); @@ -208,17 +206,16 @@ void FileBrowser::okActivated(bool viaButton) { return; } if (!err && !S_ISDIR(theStat.st_mode)) { - m_confirmWindow.reset( - new MessageWindow(rootView().viewRes(), *this, MessageWindow::Type::ConfirmOkCancel, - vm.translate(hecl::SystemUTF8Conv(path)), - [&, path](bool ok) { - if (ok) { - m_returnFunc(true, path); - m_confirmWindow->close(); - close(); - } else - m_confirmWindow->close(); - })); + m_confirmWindow = std::make_unique( + rootView().viewRes(), *this, MessageWindow::Type::ConfirmOkCancel, + vm.translate(hecl::SystemUTF8Conv(path)), [&, path](bool ok) { + if (ok) { + m_returnFunc(true, path); + m_confirmWindow->close(); + close(); + } else + m_confirmWindow->close(); + }); updateSize(); return; } @@ -587,16 +584,16 @@ void FileBrowser::RightSide::draw(boo::IGraphicsCommandQueue* gfxQ) { } FileBrowser::OKButton::OKButton(FileBrowser& fb, ViewResources& res, std::string_view text) : m_fb(fb), m_text(text) { - m_button.m_view.reset( - new Button(res, fb, this, text, nullptr, Button::Style::Block, zeus::skWhite, - RectangleConstraint(100 * res.pixelFactor(), -1, RectangleConstraint::Test::Minimum))); + m_button.m_view = + std::make_unique