Skip to content

Commit

Permalink
#5532: Close button, empty preview widget
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Feb 12, 2021
1 parent 252ea44 commit 9ed0592
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
14 changes: 14 additions & 0 deletions radiant/ui/materials/MaterialEditor.cpp
Expand Up @@ -21,11 +21,20 @@ MaterialEditor::MaterialEditor() :
{
loadNamedPanel(this, "MaterialEditorMainPanel");

// Wire up the close button
findNamedObject<wxButton>(this, "MaterialEditorCloseButton")->Bind(wxEVT_BUTTON, &MaterialEditor::_onClose, this);

// Setup the splitter and preview
auto* splitter = findNamedObject<wxSplitterWindow>(this, "MaterialEditorSplitter");
splitter->SetSashPosition(GetSize().GetWidth() * 0.6f);
splitter->SetMinimumPaneSize(10); // disallow unsplitting

// Set up the preview
wxPanel* previewPanel = findNamedObject<wxPanel>(this, "MaterialEditorPreviewPanel");
_preview.reset(new wxutil::ModelPreview(previewPanel));

previewPanel->GetSizer()->Add(_preview->getWidget(), 1, wxEXPAND);

// Set the default size of the window
FitToScreen(0.8f, 0.6f);

Expand Down Expand Up @@ -56,6 +65,11 @@ int MaterialEditor::ShowModal()
return returnCode;
}

void MaterialEditor::_onClose(wxCommandEvent& ev)
{
EndModal(wxID_CLOSE);
}

void MaterialEditor::ShowDialog(const cmd::ArgumentList& args)
{
MaterialEditor* editor = new MaterialEditor;
Expand Down
5 changes: 5 additions & 0 deletions radiant/ui/materials/MaterialEditor.h
Expand Up @@ -6,6 +6,7 @@
#include "wxutil/WindowPosition.h"
#include "wxutil/PanedPosition.h"
#include "wxutil/XmlResourceBasedWidget.h"
#include "wxutil/preview/ModelPreview.h"

namespace ui
{
Expand All @@ -18,13 +19,17 @@ class MaterialEditor :
wxutil::WindowPosition _windowPosition;
wxutil::PanedPosition _panedPosition;

std::shared_ptr<wxutil::ModelPreview> _preview;

private:
MaterialEditor();

int ShowModal() override;

public:
static void ShowDialog(const cmd::ArgumentList& args);

void _onClose(wxCommandEvent& ev);
};

}

0 comments on commit 9ed0592

Please sign in to comment.