Skip to content

Commit

Permalink
#5568: Place the selection dialog window over the left area of the ed…
Browse files Browse the repository at this point in the history
…itor such that the preview is visible
  • Loading branch information
codereader committed Mar 23, 2021
1 parent ffe0f0a commit 5c58e0f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion install/ui/materialeditor.fbp
Expand Up @@ -583,7 +583,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_notebook3</property>
<property name="name">MaterialEditorBasicAdvancedNotebook</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
Expand Down
2 changes: 1 addition & 1 deletion install/ui/materialeditor.xrc
Expand Up @@ -100,7 +100,7 @@
<option>2</option>
<flag>wxALL|wxBOTTOM|wxEXPAND|wxLEFT|wxTOP</flag>
<border>6</border>
<object class="wxNotebook" name="m_notebook3">
<object class="wxNotebook" name="MaterialEditorBasicAdvancedNotebook">
<object class="notebookpage">
<label>Basic</label>
<selected>0</selected>
Expand Down
15 changes: 13 additions & 2 deletions radiant/ui/materials/MapExpressionEntry.h
Expand Up @@ -17,10 +17,14 @@ class MapExpressionEntry :
private:
wxTextCtrl* _textEntry;
wxButton* _browseButton;
wxWindow* _windowToPlaceDialogsOn;

public:
MapExpressionEntry(wxWindow* parent) :
wxPanel(parent, wxID_ANY)
// Create a map expression entry box featuring a browse/select button
// The windowToPlaceDialogsOn argument will be used to position the modal dialog (if set)
MapExpressionEntry(wxWindow* parent, wxWindow* windowToPlaceDialogsOn = nullptr) :
wxPanel(parent, wxID_ANY),
_windowToPlaceDialogsOn(windowToPlaceDialogsOn)
{
SetSizer(new wxBoxSizer(wxHORIZONTAL));

Expand Down Expand Up @@ -49,6 +53,13 @@ class MapExpressionEntry :
void onBrowseButtonClick(wxCommandEvent& ev)
{
auto selector = new ImageFileSelector(this, _textEntry);

if (_windowToPlaceDialogsOn != nullptr)
{
selector->SetPosition(_windowToPlaceDialogsOn->GetScreenPosition());
selector->SetSize(_windowToPlaceDialogsOn->GetSize());
}

selector->ShowModal();
selector->Destroy();
}
Expand Down
4 changes: 3 additions & 1 deletion radiant/ui/materials/MaterialEditor.cpp
Expand Up @@ -1944,8 +1944,10 @@ void MaterialEditor::onMaterialChanged()

void MaterialEditor::convertTextCtrlToMapExpressionEntry(const std::string& ctrlName)
{
auto windowToPlaceDialogsOn = getControl<wxWindow>("MaterialEditorLeftArea");

auto oldCtrl = findNamedObject<wxTextCtrl>(this, ctrlName);
replaceControl(oldCtrl, new MapExpressionEntry(oldCtrl->GetParent()));
replaceControl(oldCtrl, new MapExpressionEntry(oldCtrl->GetParent(), windowToPlaceDialogsOn));
}

}

0 comments on commit 5c58e0f

Please sign in to comment.