2016-01-07 00:40:27 +00:00
|
|
|
#include "ResourceBrowser.hpp"
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2016-01-07 00:40:27 +00:00
|
|
|
#define BROWSER_MARGIN 8
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
bool ResourceBrowser::navigateToPath(const hecl::ProjectPath& pathIn) {
|
|
|
|
if (pathIn.isFile())
|
|
|
|
m_path = pathIn.getParentPath();
|
|
|
|
else
|
|
|
|
m_path = pathIn;
|
2016-01-07 00:40:27 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
m_comps = m_path.getPathComponents();
|
2016-01-07 00:40:27 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
hecl::DirectoryEnumerator dEnum(
|
|
|
|
m_path.getAbsolutePath(), hecl::DirectoryEnumerator::Mode::DirsThenFilesSorted,
|
|
|
|
m_state.sortColumn == State::SortColumn::Size,
|
|
|
|
m_state.sortDir == specter::SortDirection::Descending &&
|
|
|
|
(m_state.sortColumn == State::SortColumn::Name || m_state.sortColumn == State::SortColumn::Size),
|
|
|
|
true);
|
|
|
|
m_resListingBind.updateListing(dEnum);
|
|
|
|
if (m_pathButtons)
|
|
|
|
m_pathButtons->setButtons(m_comps);
|
2016-01-07 00:40:27 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (m_view) {
|
|
|
|
m_view->m_resListing.m_view->selectRow(-1);
|
|
|
|
m_view->m_resListing.m_view->updateData();
|
|
|
|
m_view->updateSize();
|
|
|
|
}
|
2016-01-07 00:40:27 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
return true;
|
2016-01-07 00:40:27 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void ResourceBrowser::pathButtonActivated(size_t idx) {
|
|
|
|
if (idx >= m_comps.size())
|
|
|
|
return;
|
2016-01-07 00:40:27 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
hecl::SystemString dir;
|
|
|
|
bool needSlash = false;
|
|
|
|
size_t i = 0;
|
|
|
|
for (const hecl::SystemString& d : m_comps) {
|
|
|
|
if (needSlash)
|
|
|
|
dir += _SYS_STR('/');
|
2019-10-01 07:38:03 +00:00
|
|
|
if (d != _SYS_STR("/"))
|
2018-12-08 05:30:43 +00:00
|
|
|
needSlash = true;
|
|
|
|
dir += d;
|
|
|
|
if (++i > idx)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
navigateToPath(hecl::ProjectPath(*m_vm.project(), dir));
|
2016-01-07 00:40:27 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void ResourceBrowser::View::mouseDown(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod) {
|
|
|
|
m_resListing.mouseDown(coord, button, mod);
|
2016-01-27 00:44:22 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void ResourceBrowser::View::mouseUp(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod) {
|
|
|
|
m_resListing.mouseUp(coord, button, mod);
|
2016-01-27 00:44:22 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void ResourceBrowser::View::mouseMove(const boo::SWindowCoord& coord) { m_resListing.mouseMove(coord); }
|
2016-01-07 00:40:27 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void ResourceBrowser::View::mouseLeave(const boo::SWindowCoord& coord) { m_resListing.mouseLeave(coord); }
|
2016-01-27 00:44:22 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void ResourceBrowser::View::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub) {
|
|
|
|
specter::View::resized(root, sub);
|
|
|
|
m_resListing.m_view->resized(root, sub);
|
2016-01-07 00:40:27 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
void ResourceBrowser::View::draw(boo::IGraphicsCommandQueue* gfxQ) { m_resListing.m_view->draw(gfxQ); }
|
2016-01-07 00:40:27 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|