Skip to content

Commit

Permalink
#5532: Hide the grid and the toolbar button in the MaterialPreview
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Mar 5, 2021
1 parent 244ad4e commit f238d0b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
15 changes: 14 additions & 1 deletion libs/wxutil/preview/RenderPreview.cpp
Expand Up @@ -426,6 +426,14 @@ bool RenderPreview::drawPreview()
if (!_initialised)
{
initialisePreview();

// Since we shouldn't call the virtual canDrawGrid() in the constructor
// adjust the tool bar here.
if (!canDrawGrid())
{
auto* utilToolbar = findNamedObject<wxToolBar>(_mainPanel, "RenderPreviewUtilToolbar");
utilToolbar->DeleteTool(getToolBarToolByLabel(utilToolbar, "gridButton")->GetId());
}
}

util::ScopedBoolLock lock(_renderingInProgress);
Expand Down Expand Up @@ -476,7 +484,7 @@ bool RenderPreview::drawPreview()
glMatrixMode(GL_MODELVIEW);
glLoadMatrixd(_volumeTest.GetModelview());

if (_renderGrid)
if (_renderGrid && canDrawGrid())
{
drawGrid();
}
Expand Down Expand Up @@ -732,6 +740,11 @@ void RenderPreview::onSizeAllocate(wxSizeEvent& ev)
_previewHeight = ev.GetSize().GetHeight();
}

bool RenderPreview::canDrawGrid()
{
return true;
}

void RenderPreview::drawGrid()
{
static float GRID_MAX_DIM = 512.0f;
Expand Down
3 changes: 3 additions & 0 deletions libs/wxutil/preview/RenderPreview.h
Expand Up @@ -164,6 +164,9 @@ class RenderPreview :

void associateRenderSystem();

// Base method will return true, which will also make the corresponding button appear on the toolbar
virtual bool canDrawGrid();

// Can be overridden by subclasses to update their scene/models
virtual void onRenderModeChanged() {}

Expand Down
5 changes: 5 additions & 0 deletions radiant/ui/materials/MaterialPreview.cpp
Expand Up @@ -17,4 +17,9 @@ void MaterialPreview::setMaterial(const MaterialPtr& material)
_material = material;
}

bool MaterialPreview::canDrawGrid()
{
return false;
}

}
3 changes: 3 additions & 0 deletions radiant/ui/materials/MaterialPreview.h
Expand Up @@ -17,6 +17,9 @@ class MaterialPreview :

const MaterialPtr& getMaterial();
void setMaterial(const MaterialPtr& material);

protected:
bool canDrawGrid() override;
};

}

0 comments on commit f238d0b

Please sign in to comment.