Skip to content

Commit

Permalink
VOXELCOLLECTION: UI: updated the voxelcollection panel to fix an erro…
Browse files Browse the repository at this point in the history
…r when thumbnails are activated
  • Loading branch information
mgerhardy committed Jun 19, 2024
1 parent f74d1df commit fb447c1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
21 changes: 11 additions & 10 deletions src/modules/voxelcollection/ui/CollectionPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,14 @@ bool CollectionPanel::isFilterActive() const {
}

void CollectionPanel::updateFilters() {
const ImVec2 itemWidth = ImGui::CalcTextSize("#########");
{
const ImVec2 itemWidth = ImGui::CalcTextSize("#########");
ImGui::PushItemWidth(itemWidth.x);
ImGui::InputText(_("Name"), &_currentFilterName);
ImGui::PopItemWidth();
ImGui::SameLine();
}
{
const ImVec2 itemWidth = ImGui::CalcTextSize("#########");
ImGui::PushItemWidth(itemWidth.x);
ImGui::InputText(_("License"), &_currentFilterLicense);
ImGui::PopItemWidth();
Expand All @@ -67,6 +66,7 @@ void CollectionPanel::updateFilters() {
io::createGroupPatterns(voxelformat::voxelLoad(), _filterEntries);
// must be the first entry - see applyFilter()
_filterEntries.insert(_filterEntries.begin(), io::ALL_SUPPORTED());
_filterFormatTextWidth = core_min(itemWidth.x * 2, _filterFormatTextWidth);
}

const char *formatFilterLabel = _("Format");
Expand Down Expand Up @@ -188,19 +188,20 @@ int CollectionPanel::buildVoxelTree(const VoxelFiles &voxelFiles,
}
core::String id = core::string::format("%i", row);
if (ImGui::ImageButton(id.c_str(), handle, ImVec2(64, 64))) {
_selected = *voxelFile;
_newSelected = true;
}

ImGui::TableNextColumn();
ImGui::TextUnformatted(voxelFile->name.c_str());
} else {
if (ImGui::Selectable(voxelFile->name.c_str(), selected, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowDoubleClick)) {
if (ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) {
_selected = *voxelFile;
_newSelected = true;
}
}
ImGui::TableNextColumn();
}
if (ImGui::Selectable(voxelFile->name.c_str(), selected, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowDoubleClick)) {
if (ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) {
_selected = *voxelFile;
_newSelected = true;
}
}
if (!_thumbnails) {
if (const video::TexturePtr &texture = thumbnailLookup(*voxelFile)) {
if (ImGui::BeginItemTooltip()) {
const video::Id handle = texture->handle();
Expand Down
2 changes: 1 addition & 1 deletion src/tools/voxedit/modules/voxedit-ui/AssetPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ AssetPanel::AssetPanel(ui::IMGUIApp *app, const SceneManagerPtr &sceneMgr,
const video::TexturePoolPtr &texturePool, const io::FilesystemPtr &filesystem)
: Super(app, "asset"), _texturePool(texturePool), _filesystem(filesystem), _sceneMgr(sceneMgr), _collectionMgr(collectionMgr),
_collectionPanel(app, texturePool) {
_collectionPanel.setThumbnails(false);
}

void AssetPanel::shutdown() {
Expand All @@ -52,7 +53,6 @@ bool AssetPanel::init() {
}
});

_collectionPanel.setThumbnails(false);
_collectionMgr->online();
return true;
}
Expand Down

0 comments on commit fb447c1

Please sign in to comment.