From a4a531a5581fd8fff2a1beb214aef4eea9d7fd24 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Fri, 1 Jan 2016 18:17:47 -1000 Subject: [PATCH] Win32 fixes --- specter/include/Specter/FileBrowser.hpp | 6 +++++- specter/include/Specter/Table.hpp | 1 + specter/include/Specter/TextView.hpp | 2 +- specter/lib/FileBrowser.cpp | 24 +++++++++++++++++++----- specter/lib/Table.cpp | 14 ++++++++++---- 5 files changed, 36 insertions(+), 11 deletions(-) diff --git a/specter/include/Specter/FileBrowser.hpp b/specter/include/Specter/FileBrowser.hpp index 8397bc485..480b4f161 100644 --- a/specter/include/Specter/FileBrowser.hpp +++ b/specter/include/Specter/FileBrowser.hpp @@ -167,7 +167,7 @@ private: return nullptr; } - float m_columnSplits[3] = {0.0, 0.7, 0.9}; + float m_columnSplits[3] = {0.0f, 0.7f, 0.9f}; bool columnSplitResizeAllowed() const {return true;} @@ -261,6 +261,10 @@ private: { HECL::SystemString m_path; std::string m_name; + + Entry(std::pair&& path) + : m_path(std::move(path.first)), m_name(std::move(path.second)) {} + Entry(const HECL::SystemString& path) : m_path(path) { diff --git a/specter/include/Specter/Table.hpp b/specter/include/Specter/Table.hpp index 00531f0de..2f05cad35 100644 --- a/specter/include/Specter/Table.hpp +++ b/specter/include/Specter/Table.hpp @@ -44,6 +44,7 @@ class Table : public View size_t m_rows = 0; size_t m_columns = 0; size_t m_selectedRow = -1; + size_t m_deferredActivation = -1; size_t m_clickFrames = 15; struct CellView : public View diff --git a/specter/include/Specter/TextView.hpp b/specter/include/Specter/TextView.hpp index 23d2c4afb..81db9377b 100644 --- a/specter/include/Specter/TextView.hpp +++ b/specter/include/Specter/TextView.hpp @@ -74,7 +74,7 @@ public: bool m_space = false; RenderGlyphInfo(uint32_t ch, int width, int height, int adv) - : m_char(ch), m_dims(width, height), m_adv(adv), m_space(iswspace(ch)) {} + : m_char(ch), m_dims(width, height), m_adv(adv), m_space(iswspace(ch) != 0) {} }; std::vector& accessGlyphs() {return m_glyphs;} const std::vector& accessGlyphs() const {return m_glyphs;} diff --git a/specter/lib/FileBrowser.cpp b/specter/lib/FileBrowser.cpp index 6d1b49316..f8500ad0b 100644 --- a/specter/lib/FileBrowser.cpp +++ b/specter/lib/FileBrowser.cpp @@ -76,9 +76,9 @@ FileBrowser::FileBrowser(ViewResources& res, View& parentView, const std::string m_recentBookmarksLabel->typesetGlyphs(vm.translateOr("recent_files", "Recent Files"), res.themeData().uiText()); /* Populate system bookmarks */ - std::vector systemLocs = HECL::GetSystemLocations(); - for (const HECL::SystemString& loc : systemLocs) - m_systemBookmarkBind.m_entries.emplace_back(loc); + std::vector> systemLocs = HECL::GetSystemLocations(); + for (auto& loc : systemLocs) + m_systemBookmarkBind.m_entries.emplace_back(std::move(loc)); m_systemBookmarks.m_view->updateData(); navigateToPath(initialPath); @@ -112,6 +112,13 @@ void FileBrowser::SyncBookmarkSelections(Table& table, BookmarkDataBind& binding void FileBrowser::navigateToPath(const HECL::SystemString& path) { HECL::Sstat theStat; +#if _WIN32 + if (path.size() == 2 && path[1] == L':') + { + if (HECL::Stat((path + L'/').c_str(), &theStat)) + return; + } else +#endif if (HECL::Stat(path.c_str(), &theStat)) return; @@ -192,7 +199,14 @@ void FileBrowser::okActivated(bool viaButton) } HECL::Sstat theStat; +#if _WIN32 + HECL::SystemString fixPath = path; + if (path.size() == 2 && path[1] == L':') + fixPath += L'/'; + if (HECL::Stat(fixPath.c_str(), &theStat) || !S_ISDIR(theStat.st_mode)) +#else if (HECL::Stat(path.c_str(), &theStat) || !S_ISDIR(theStat.st_mode)) +#endif { HECL::SystemUTF8View utf8(path); m_fileField.m_view->setErrorState( @@ -202,7 +216,7 @@ void FileBrowser::okActivated(bool viaButton) } path += _S('/'); - path += m_fileField.m_view->getText(); + path += HECL::SystemStringView(m_fileField.m_view->getText()).sys_str(); int err = HECL::Stat(path.c_str(), &theStat); if (m_type == Type::SaveFile) @@ -271,7 +285,7 @@ void FileBrowser::cancelActivated() } path += _S('/'); - path += m_fileField.m_view->getText(); + path += HECL::SystemStringView(m_fileField.m_view->getText()).sys_str(); m_returnFunc(false, path); close(); diff --git a/specter/lib/Table.cpp b/specter/lib/Table.cpp index 35a70466b..b021ad351 100644 --- a/specter/lib/Table.cpp +++ b/specter/lib/Table.cpp @@ -308,7 +308,7 @@ void Table::mouseDown(const boo::SWindowCoord& coord, } if (abs(coord.pixel[0] - rect.location[0]) < 4 && unsigned(coord.pixel[1] - subRect().location[1] - - subRect().size[1] + rect.size[1]) < rect.size[1]) + subRect().size[1] + rect.size[1]) < unsigned(rect.size[1])) { m_hDraggingIdx = cIdx; rootView().setActiveDragView(this); @@ -321,6 +321,12 @@ void Table::mouseDown(const boo::SWindowCoord& coord, m_scroll.mouseDown(coord, button, mod); if (m_headerNeedsUpdate) _setHeaderVerts(subRect()); + + if (m_deferredActivation != -1 && m_state) + { + m_state->rowActivated(m_deferredActivation); + m_deferredActivation = -1; + } } void Table::RowsView::mouseDown(const boo::SWindowCoord& coord, @@ -340,8 +346,8 @@ void Table::CellView::mouseDown(const boo::SWindowCoord& coord, if (m_r != -1) { m_t.selectRow(m_r); - if (m_t.m_clickFrames < 15 && m_t.m_state) - m_t.m_state->rowActivated(m_r); + if (m_t.m_clickFrames < 15) + m_t.m_deferredActivation = m_r; else m_t.m_clickFrames = 0; } @@ -415,7 +421,7 @@ void Table::mouseMove(const boo::SWindowCoord& coord) continue; if (abs(coord.pixel[0] - rect.location[0]) < 4 && unsigned(coord.pixel[1] - subRect().location[1] - - subRect().size[1] + rect.size[1]) < rect.size[1]) + subRect().size[1] + rect.size[1]) < unsigned(rect.size[1])) { hovering = true; break;