-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#6302: Add "Show definition" button for the "inherit" spawnarg
- Loading branch information
1 parent
8bf85d7
commit 5d0d366
Showing
8 changed files
with
98 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#include "InheritPropertyEditor.h" | ||
#include "PropertyEditorFactory.h" | ||
|
||
#include "i18n.h" | ||
#include "ientity.h" | ||
#include "ieclass.h" | ||
|
||
#include <wx/panel.h> | ||
#include <wx/button.h> | ||
#include <wx/sizer.h> | ||
#include "wxutil/sourceview/DeclarationSourceView.h" | ||
|
||
#include "wxutil/Bitmap.h" | ||
|
||
namespace ui | ||
{ | ||
|
||
// Main constructor | ||
InheritPropertyEditor::InheritPropertyEditor(wxWindow* parent, IEntitySelection& entities, const ITargetKey::Ptr& key) | ||
: PropertyEditor(entities), | ||
_key(key) | ||
{ | ||
auto mainVBox = new wxPanel(parent, wxID_ANY); | ||
mainVBox->SetSizer(new wxBoxSizer(wxHORIZONTAL)); | ||
|
||
// Register the main widget in the base class | ||
setMainWidget(mainVBox); | ||
|
||
auto showDefinition = new wxButton(mainVBox, wxID_ANY, _("Show Definition...")); | ||
showDefinition->SetBitmap(wxutil::GetLocalBitmap("decl.png")); | ||
showDefinition->Bind(wxEVT_BUTTON, &InheritPropertyEditor::_onShowDefinition, this); | ||
|
||
mainVBox->GetSizer()->Add(showDefinition, 0, wxALIGN_CENTER_VERTICAL | wxALL, 6); | ||
} | ||
|
||
void InheritPropertyEditor::_onShowDefinition(wxCommandEvent& ev) | ||
{ | ||
auto parentClass = _entities.getSharedKeyValue(_key->getFullKey(), true); | ||
auto eclass = GlobalEntityClassManager().findClass(parentClass); | ||
|
||
if (eclass) | ||
{ | ||
auto view = new wxutil::DeclarationSourceView(getWidget()); | ||
view->setDeclaration(eclass); | ||
|
||
view->ShowModal(); | ||
view->Destroy(); | ||
} | ||
} | ||
|
||
} // namespace ui |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#pragma once | ||
|
||
#include "PropertyEditor.h" | ||
|
||
#include <wx/event.h> | ||
#include <string> | ||
|
||
namespace ui | ||
{ | ||
|
||
/** | ||
* PropertyEditor displaying a single "Show Definition". | ||
*/ | ||
class InheritPropertyEditor : | ||
public PropertyEditor | ||
{ | ||
private: | ||
// Keyvalue to set | ||
ITargetKey::Ptr _key; | ||
|
||
private: | ||
|
||
void _onShowDefinition(wxCommandEvent& ev); | ||
|
||
public: | ||
InheritPropertyEditor(wxWindow* parent, IEntitySelection& entities, const ITargetKey::Ptr& key); | ||
|
||
static Ptr CreateNew(wxWindow* parent, IEntitySelection& entities, const ITargetKey::Ptr& key) | ||
{ | ||
return std::make_shared<InheritPropertyEditor>(parent, entities, key); | ||
} | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters