2016-01-07 00:40:27 +00:00
|
|
|
#include "ResourceBrowser.hpp"
|
|
|
|
|
|
|
|
namespace URDE
|
|
|
|
{
|
|
|
|
#define BROWSER_MARGIN 8
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
bool ResourceBrowser::navigateToPath(const hecl::ProjectPath& pathIn)
|
2016-01-07 00:40:27 +00:00
|
|
|
{
|
2016-03-04 23:04:53 +00:00
|
|
|
if (pathIn.getPathType() == hecl::ProjectPath::Type::File)
|
2016-01-07 00:40:27 +00:00
|
|
|
m_path = pathIn.getParentPath();
|
|
|
|
else
|
|
|
|
m_path = pathIn;
|
|
|
|
|
|
|
|
m_comps = m_path.getPathComponents();
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
hecl::DirectoryEnumerator dEnum(m_path.getAbsolutePath(),
|
|
|
|
hecl::DirectoryEnumerator::Mode::DirsThenFilesSorted,
|
2016-01-07 00:40:27 +00:00
|
|
|
m_state.sortColumn==State::SortColumn::Size,
|
2016-03-04 23:04:53 +00:00
|
|
|
m_state.sortDir==specter::SortDirection::Descending,
|
2016-01-07 00:40:27 +00:00
|
|
|
true);
|
|
|
|
m_fileListingBind.updateListing(dEnum);
|
2016-01-27 00:44:22 +00:00
|
|
|
if (m_pathButtons)
|
|
|
|
m_pathButtons->setButtons(m_comps);
|
2016-01-07 00:40:27 +00:00
|
|
|
|
2016-01-08 05:54:00 +00:00
|
|
|
if (m_view)
|
|
|
|
{
|
|
|
|
m_view->m_fileListing.m_view->selectRow(-1);
|
|
|
|
m_view->m_fileListing.m_view->updateData();
|
|
|
|
m_view->updateSize();
|
|
|
|
}
|
2016-01-07 00:40:27 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ResourceBrowser::pathButtonActivated(size_t idx)
|
|
|
|
{
|
|
|
|
if (idx >= m_comps.size())
|
|
|
|
return;
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
hecl::SystemString dir;
|
2016-01-07 00:40:27 +00:00
|
|
|
bool needSlash = false;
|
|
|
|
size_t i = 0;
|
2016-03-04 23:04:53 +00:00
|
|
|
for (const hecl::SystemString& d : m_comps)
|
2016-01-07 00:40:27 +00:00
|
|
|
{
|
|
|
|
if (needSlash)
|
|
|
|
dir += _S('/');
|
|
|
|
if (d.compare(_S("/")))
|
|
|
|
needSlash = true;
|
|
|
|
dir += d;
|
|
|
|
if (++i > idx)
|
|
|
|
break;
|
|
|
|
}
|
2016-03-04 23:04:53 +00:00
|
|
|
navigateToPath(hecl::ProjectPath(*m_vm.project(), dir));
|
2016-01-07 00:40:27 +00:00
|
|
|
}
|
|
|
|
|
2016-01-27 00:44:22 +00:00
|
|
|
void ResourceBrowser::View::mouseDown(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
|
|
|
|
{
|
|
|
|
m_fileListing.mouseDown(coord, button, mod);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ResourceBrowser::View::mouseUp(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
|
|
|
|
{
|
|
|
|
m_fileListing.mouseUp(coord, button, mod);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ResourceBrowser::View::mouseMove(const boo::SWindowCoord& coord)
|
2016-01-07 00:40:27 +00:00
|
|
|
{
|
2016-01-27 00:44:22 +00:00
|
|
|
m_fileListing.mouseMove(coord);
|
|
|
|
}
|
2016-01-07 00:40:27 +00:00
|
|
|
|
2016-01-27 00:44:22 +00:00
|
|
|
void ResourceBrowser::View::mouseLeave(const boo::SWindowCoord& coord)
|
|
|
|
{
|
|
|
|
m_fileListing.mouseLeave(coord);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ResourceBrowser::View::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub)
|
|
|
|
{
|
2016-03-04 23:04:53 +00:00
|
|
|
specter::View::resized(root, sub);
|
2016-01-27 00:44:22 +00:00
|
|
|
m_fileListing.m_view->resized(root, sub);
|
2016-01-07 00:40:27 +00:00
|
|
|
}
|
|
|
|
void ResourceBrowser::View::draw(boo::IGraphicsCommandQueue* gfxQ)
|
|
|
|
{
|
|
|
|
m_fileListing.m_view->draw(gfxQ);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|