Win32 fixes

This commit is contained in:
Jack Andersen 2016-01-01 18:17:47 -10:00
parent 8959431a2b
commit a4a531a558
5 changed files with 36 additions and 11 deletions

View File

@ -167,7 +167,7 @@ private:
return nullptr; 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;} bool columnSplitResizeAllowed() const {return true;}
@ -261,6 +261,10 @@ private:
{ {
HECL::SystemString m_path; HECL::SystemString m_path;
std::string m_name; std::string m_name;
Entry(std::pair<HECL::SystemString, std::string>&& path)
: m_path(std::move(path.first)), m_name(std::move(path.second)) {}
Entry(const HECL::SystemString& path) Entry(const HECL::SystemString& path)
: m_path(path) : m_path(path)
{ {

View File

@ -44,6 +44,7 @@ class Table : public View
size_t m_rows = 0; size_t m_rows = 0;
size_t m_columns = 0; size_t m_columns = 0;
size_t m_selectedRow = -1; size_t m_selectedRow = -1;
size_t m_deferredActivation = -1;
size_t m_clickFrames = 15; size_t m_clickFrames = 15;
struct CellView : public View struct CellView : public View

View File

@ -74,7 +74,7 @@ public:
bool m_space = false; bool m_space = false;
RenderGlyphInfo(uint32_t ch, int width, int height, int adv) 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<RenderGlyph>& accessGlyphs() {return m_glyphs;} std::vector<RenderGlyph>& accessGlyphs() {return m_glyphs;}
const std::vector<RenderGlyph>& accessGlyphs() const {return m_glyphs;} const std::vector<RenderGlyph>& accessGlyphs() const {return m_glyphs;}

View File

@ -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()); m_recentBookmarksLabel->typesetGlyphs(vm.translateOr("recent_files", "Recent Files"), res.themeData().uiText());
/* Populate system bookmarks */ /* Populate system bookmarks */
std::vector<HECL::SystemString> systemLocs = HECL::GetSystemLocations(); std::vector<std::pair<HECL::SystemString, std::string>> systemLocs = HECL::GetSystemLocations();
for (const HECL::SystemString& loc : systemLocs) for (auto& loc : systemLocs)
m_systemBookmarkBind.m_entries.emplace_back(loc); m_systemBookmarkBind.m_entries.emplace_back(std::move(loc));
m_systemBookmarks.m_view->updateData(); m_systemBookmarks.m_view->updateData();
navigateToPath(initialPath); navigateToPath(initialPath);
@ -112,6 +112,13 @@ void FileBrowser::SyncBookmarkSelections(Table& table, BookmarkDataBind& binding
void FileBrowser::navigateToPath(const HECL::SystemString& path) void FileBrowser::navigateToPath(const HECL::SystemString& path)
{ {
HECL::Sstat theStat; 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)) if (HECL::Stat(path.c_str(), &theStat))
return; return;
@ -192,7 +199,14 @@ void FileBrowser::okActivated(bool viaButton)
} }
HECL::Sstat theStat; 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)) if (HECL::Stat(path.c_str(), &theStat) || !S_ISDIR(theStat.st_mode))
#endif
{ {
HECL::SystemUTF8View utf8(path); HECL::SystemUTF8View utf8(path);
m_fileField.m_view->setErrorState( m_fileField.m_view->setErrorState(
@ -202,7 +216,7 @@ void FileBrowser::okActivated(bool viaButton)
} }
path += _S('/'); 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); int err = HECL::Stat(path.c_str(), &theStat);
if (m_type == Type::SaveFile) if (m_type == Type::SaveFile)
@ -271,7 +285,7 @@ void FileBrowser::cancelActivated()
} }
path += _S('/'); path += _S('/');
path += m_fileField.m_view->getText(); path += HECL::SystemStringView(m_fileField.m_view->getText()).sys_str();
m_returnFunc(false, path); m_returnFunc(false, path);
close(); close();

View File

@ -308,7 +308,7 @@ void Table::mouseDown(const boo::SWindowCoord& coord,
} }
if (abs(coord.pixel[0] - rect.location[0]) < 4 && if (abs(coord.pixel[0] - rect.location[0]) < 4 &&
unsigned(coord.pixel[1] - subRect().location[1] - 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; m_hDraggingIdx = cIdx;
rootView().setActiveDragView(this); rootView().setActiveDragView(this);
@ -321,6 +321,12 @@ void Table::mouseDown(const boo::SWindowCoord& coord,
m_scroll.mouseDown(coord, button, mod); m_scroll.mouseDown(coord, button, mod);
if (m_headerNeedsUpdate) if (m_headerNeedsUpdate)
_setHeaderVerts(subRect()); _setHeaderVerts(subRect());
if (m_deferredActivation != -1 && m_state)
{
m_state->rowActivated(m_deferredActivation);
m_deferredActivation = -1;
}
} }
void Table::RowsView::mouseDown(const boo::SWindowCoord& coord, void Table::RowsView::mouseDown(const boo::SWindowCoord& coord,
@ -340,8 +346,8 @@ void Table::CellView::mouseDown(const boo::SWindowCoord& coord,
if (m_r != -1) if (m_r != -1)
{ {
m_t.selectRow(m_r); m_t.selectRow(m_r);
if (m_t.m_clickFrames < 15 && m_t.m_state) if (m_t.m_clickFrames < 15)
m_t.m_state->rowActivated(m_r); m_t.m_deferredActivation = m_r;
else else
m_t.m_clickFrames = 0; m_t.m_clickFrames = 0;
} }
@ -415,7 +421,7 @@ void Table::mouseMove(const boo::SWindowCoord& coord)
continue; continue;
if (abs(coord.pixel[0] - rect.location[0]) < 4 && if (abs(coord.pixel[0] - rect.location[0]) < 4 &&
unsigned(coord.pixel[1] - subRect().location[1] - 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; hovering = true;
break; break;