mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-08-15 14:43:32 -07:00
Use dynamic events for Cinema Section
Replace static events with dynamic events and name delete path function more aptly. Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
This commit is contained in:
parent
7aa756f6a4
commit
a95f274faf
2 changed files with 18 additions and 32 deletions
|
|
@ -45,21 +45,15 @@
|
||||||
|
|
||||||
using AtlasMessage::Shareable;
|
using AtlasMessage::Shareable;
|
||||||
|
|
||||||
enum {
|
|
||||||
ID_PathsDrawing,
|
|
||||||
ID_PathsList,
|
|
||||||
ID_AddPath,
|
|
||||||
ID_DeletePath
|
|
||||||
};
|
|
||||||
|
|
||||||
CinemaSidebar::CinemaSidebar(ScenarioEditor& scenarioEditor, wxWindow* sidebarContainer, wxWindow* bottomBarContainer)
|
CinemaSidebar::CinemaSidebar(ScenarioEditor& scenarioEditor, wxWindow* sidebarContainer, wxWindow* bottomBarContainer)
|
||||||
: Sidebar(scenarioEditor, sidebarContainer, bottomBarContainer)
|
: Sidebar(scenarioEditor, sidebarContainer, bottomBarContainer)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
auto* sizer = new wxStaticBoxSizer(wxVERTICAL, this, _T("Common settings"));
|
auto* sizer = new wxStaticBoxSizer(wxVERTICAL, this, _T("Common settings"));
|
||||||
|
|
||||||
m_DrawPath = new wxCheckBox(sizer->GetStaticBox(), ID_PathsDrawing, _("Draw all paths"));
|
m_DrawPath = new wxCheckBox(sizer->GetStaticBox(), wxID_ANY, _("Draw all paths"));
|
||||||
m_DrawPath->SetToolTip(_("Display every cinematic path added to the map"));
|
m_DrawPath->SetToolTip(_("Display every cinematic path added to the map"));
|
||||||
|
m_DrawPath->Bind(wxEVT_CHECKBOX, [this](auto&){ SetPathsDrawing(m_DrawPath->IsChecked()); });
|
||||||
|
|
||||||
sizer->Add(m_DrawPath, wxSizerFlags().Expand().Border(wxALL, Atlas::Style::STATICBOX_PADDING));
|
sizer->Add(m_DrawPath, wxSizerFlags().Expand().Border(wxALL, Atlas::Style::STATICBOX_PADDING));
|
||||||
|
|
||||||
|
|
@ -70,20 +64,22 @@ CinemaSidebar::CinemaSidebar(ScenarioEditor& scenarioEditor, wxWindow* sidebarCo
|
||||||
auto* boxSizer = new wxStaticBoxSizer(wxVERTICAL, this, _T("Paths"));
|
auto* boxSizer = new wxStaticBoxSizer(wxVERTICAL, this, _T("Paths"));
|
||||||
auto* box = boxSizer->GetStaticBox();
|
auto* box = boxSizer->GetStaticBox();
|
||||||
|
|
||||||
m_PathList = new wxListBox(box, ID_PathsList, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_SINGLE | wxLB_SORT);
|
m_PathList = new wxListBox(box, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_SINGLE | wxLB_SORT);
|
||||||
|
|
||||||
auto* deleteButton = new wxButton(box, ID_DeletePath, _("Delete"));
|
auto* deleteButton = new wxButton(box, wxID_ANY, _("Delete"));
|
||||||
deleteButton->SetToolTip(_T("Delete selected path"));
|
deleteButton->SetToolTip(_T("Delete selected path"));
|
||||||
|
deleteButton->Bind(wxEVT_BUTTON, [this](auto&){ DeleteSelectedPath(); });
|
||||||
|
|
||||||
m_NewPathName = new wxTextCtrl(box, wxID_ANY);
|
auto* newPathName = new wxTextCtrl(box, wxID_ANY);
|
||||||
|
|
||||||
auto* addButton = new wxButton(box, ID_AddPath, _("Add"));
|
auto* addButton = new wxButton(box, wxID_ANY, _("Add"));
|
||||||
|
addButton->Bind(wxEVT_BUTTON, [this, newPathName](auto&){ AddPath(newPathName->GetValue()); newPathName->Clear(); });
|
||||||
|
|
||||||
wxFlexGridSizer* pathsSizer = new wxFlexGridSizer(1, 5, 5);
|
wxFlexGridSizer* pathsSizer = new wxFlexGridSizer(1, 5, 5);
|
||||||
pathsSizer->AddGrowableCol(0);
|
pathsSizer->AddGrowableCol(0);
|
||||||
pathsSizer->Add(m_PathList, wxSizerFlags().Proportion(1).Expand());
|
pathsSizer->Add(m_PathList, wxSizerFlags().Proportion(1).Expand());
|
||||||
pathsSizer->Add(deleteButton, wxSizerFlags().Expand());
|
pathsSizer->Add(deleteButton, wxSizerFlags().Expand());
|
||||||
pathsSizer->Add(m_NewPathName, wxSizerFlags().Expand());
|
pathsSizer->Add(newPathName, wxSizerFlags().Expand());
|
||||||
pathsSizer->Add(addButton, wxSizerFlags().Expand());
|
pathsSizer->Add(addButton, wxSizerFlags().Expand());
|
||||||
|
|
||||||
boxSizer->Add(pathsSizer, wxSizerFlags().Expand().Border(wxALL, Atlas::Style::STATICBOX_PADDING));
|
boxSizer->Add(pathsSizer, wxSizerFlags().Expand().Border(wxALL, Atlas::Style::STATICBOX_PADDING));
|
||||||
|
|
@ -106,22 +102,21 @@ void CinemaSidebar::OnMapReload()
|
||||||
ReloadPathList();
|
ReloadPathList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CinemaSidebar::OnTogglePathsDrawing(wxCommandEvent& evt)
|
void CinemaSidebar::SetPathsDrawing(const bool enable)
|
||||||
{
|
{
|
||||||
POST_COMMAND(SetCinemaPathsDrawing, (evt.IsChecked()));
|
POST_COMMAND(SetCinemaPathsDrawing, (enable));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CinemaSidebar::OnAddPath(wxCommandEvent&)
|
void CinemaSidebar::AddPath(wxString name)
|
||||||
{
|
{
|
||||||
if (m_NewPathName->GetValue().empty())
|
if (name.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
POST_COMMAND(AddCinemaPath, (m_NewPathName->GetValue().ToStdWstring()));
|
POST_COMMAND(AddCinemaPath, (name.ToStdWstring()));
|
||||||
m_NewPathName->Clear();
|
|
||||||
ReloadPathList();
|
ReloadPathList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CinemaSidebar::OnDeletePath(wxCommandEvent&)
|
void CinemaSidebar::DeleteSelectedPath()
|
||||||
{
|
{
|
||||||
int index = m_PathList->GetSelection();
|
int index = m_PathList->GetSelection();
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
|
|
@ -148,9 +143,3 @@ void CinemaSidebar::ReloadPathList()
|
||||||
|
|
||||||
m_PathList->SetStringSelection(selection);
|
m_PathList->SetStringSelection(selection);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBEGIN_EVENT_TABLE(CinemaSidebar, Sidebar)
|
|
||||||
EVT_CHECKBOX(ID_PathsDrawing, CinemaSidebar::OnTogglePathsDrawing)
|
|
||||||
EVT_BUTTON(ID_AddPath, CinemaSidebar::OnAddPath)
|
|
||||||
EVT_BUTTON(ID_DeletePath, CinemaSidebar::OnDeletePath)
|
|
||||||
wxEND_EVENT_TABLE();
|
|
||||||
|
|
|
||||||
|
|
@ -37,15 +37,12 @@ protected:
|
||||||
void OnFirstDisplay() override;
|
void OnFirstDisplay() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void OnTogglePathsDrawing(wxCommandEvent& evt);
|
void SetPathsDrawing(const bool enable);
|
||||||
void OnAddPath(wxCommandEvent& evt);
|
void AddPath(wxString name);
|
||||||
void OnDeletePath(wxCommandEvent& evt);
|
void DeleteSelectedPath();
|
||||||
|
|
||||||
void ReloadPathList();
|
void ReloadPathList();
|
||||||
|
|
||||||
wxCheckBox* m_DrawPath;
|
wxCheckBox* m_DrawPath;
|
||||||
wxListBox* m_PathList;
|
wxListBox* m_PathList;
|
||||||
wxTextCtrl* m_NewPathName;
|
|
||||||
|
|
||||||
wxDECLARE_EVENT_TABLE();
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue