Skip to content

Commit 806155b

Browse files
author
larspalo
committed
Implemented duplication of a panel by right-click in the organ tree. Don't write sharp key width if not necessary. Also check tremulants for switch usage/references.
1 parent cae4bce commit 806155b

32 files changed

+157
-3
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Added
1111

1212
- Option to create new panel from selection on existing panel display. (TODO)
13-
- Option to duplicate an existing panel. (TODO)
13+
14+
## [0.15.0] - 2024-07-27
15+
16+
### Added
17+
18+
- Option to duplicate an existing panel by right-clicking on it in the organ tree.
1419
- Setter element CrescendoOverride.
1520

1621
### Fixed
@@ -24,6 +29,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2429
- Issue/Bug on the msw port in the PipeDialog that would cause forcing selection of IsPercussive=Y when navigating with "Next" button to the last pipe
2530
- Direct right-click on a pipe in rank pipe tree that previously didn't create a true selection of a pipe in the msw port.
2631
- Restore focus to main window after opening an .organ file on the msw port (make sure it's raised).
32+
- Not writing Key999Width for sharps when not necessary (could potentially mess up the layout of keys).
33+
- Take tremulants into accound when checking if a switch is referenced anywhere.
2734

2835
## [0.14.0] - 2024-07-02
2936

src/GOODFFrame.cpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,6 +1402,56 @@ void GOODFFrame::OnOrganTreeRightClicked(wxTreeEvent& event) {
14021402
event.Skip();
14031403
return;
14041404
}
1405+
1406+
if (parentId == tree_panels) {
1407+
// A panel was right clicked, should it be duplicated?
1408+
if (m_organ->getNumberOfPanels() < 1000) {
1409+
wxMessageDialog dlg(this, wxT("Do you want to duplicate the right-clicked panel?"), wxT("Duplicate panel?"), wxYES_NO|wxCENTRE);
1410+
if (dlg.ShowModal() == wxID_YES) {
1411+
int selectedPanelIndex = 0;
1412+
int numPanels = m_organTreeCtrl->GetChildrenCount(tree_panels, false);
1413+
wxTreeItemIdValue cookie;
1414+
for (int i = 0; i < numPanels; i++) {
1415+
wxTreeItemId currentId;
1416+
if (i == 0)
1417+
currentId = m_organTreeCtrl->GetFirstChild(tree_panels, cookie);
1418+
else
1419+
currentId = m_organTreeCtrl->GetNextChild(tree_panels, cookie);
1420+
if (clickedId == currentId)
1421+
selectedPanelIndex = i;
1422+
}
1423+
1424+
GoPanel p = *(m_organ->getOrganPanelAt(selectedPanelIndex));
1425+
m_organ->addPanel(p);
1426+
wxTreeItemId thisPanel = m_organTreeCtrl->AppendItem(tree_panels, p.getName());
1427+
// create the subitems for Displaymetrics, Images and GUIElements
1428+
m_organTreeCtrl->AppendItem(thisPanel, wxT("Displaymetrics"));
1429+
wxTreeItemId panelImages = m_organTreeCtrl->AppendItem(thisPanel, wxT("Images"));
1430+
for (unsigned i = 0; i < p.getNumberOfImages(); i++) {
1431+
wxString displayName = p.getImageAt(i)->getImageNameOnly();
1432+
if (displayName == wxEmptyString)
1433+
displayName = wxT("New Image");
1434+
m_organTreeCtrl->AppendItem(panelImages, displayName);
1435+
}
1436+
wxTreeItemId panelGuiElements = m_organTreeCtrl->AppendItem(thisPanel, wxT("GUI Elements"));
1437+
for (int i = 0; i < p.getNumberOfGuiElements(); i++) {
1438+
m_organTreeCtrl->AppendItem(panelGuiElements, p.getGuiElementAt(i)->getDisplayName());
1439+
}
1440+
m_organ->setModified(true);
1441+
m_organTreeCtrl->SelectItem(thisPanel);
1442+
1443+
} else {
1444+
event.Skip();
1445+
return;
1446+
}
1447+
} else {
1448+
wxMessageDialog msg(this, wxT("Organ cannot have more than 1000 panels!"), wxT("Too many panels"), wxOK|wxCENTRE|wxICON_EXCLAMATION);
1449+
msg.ShowModal();
1450+
event.Skip();
1451+
return;
1452+
}
1453+
}
1454+
14051455
wxTreeItemId grandParentId = m_organTreeCtrl->GetItemParent(parentId);
14061456
if (grandParentId != tree_organ && m_organTreeCtrl->GetItemParent(grandParentId) == tree_panels) {
14071457
int selectedIndex = 0;

src/GUIButton.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,11 @@ void GUIButton::read(wxFileConfig *cfg, bool isPiston, Organ *readOrgan) {
311311
setTextBreakWidth(0);
312312
}
313313

314+
315+
GUIButton* GUIButton::clone() {
316+
return new GUIButton(*this);
317+
}
318+
314319
void GUIButton::updateDisplayName() {
315320

316321
}

src/GUIButton.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class GUIButton : public GUIElement {
3737
virtual void write(wxTextFile *outFile);
3838
virtual void read(wxFileConfig *cfg, bool isPiston, Organ *readOrgan);
3939

40+
virtual GUIButton* clone();
4041
virtual void updateDisplayName();
4142
virtual wxBitmap getBitmap();
4243
virtual wxString getElementName();

src/GUICoupler.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ void GUICoupler::write(wxTextFile *outFile) {
4545
GUIButton::write(outFile);
4646
}
4747

48+
GUICoupler* GUICoupler::clone() {
49+
return new GUICoupler(*this);
50+
}
51+
4852
bool GUICoupler::isReferencing(Coupler *cplr) {
4953
return m_coupler == cplr ? true : false;
5054
}

src/GUICoupler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class GUICoupler : public GUIButton {
3232
~GUICoupler();
3333

3434
void write(wxTextFile *outFile);
35+
virtual GUICoupler* clone();
3536
bool isReferencing(Coupler *cplr);
3637
void updateDisplayName();
3738
wxString getElementName();

src/GUIDivisional.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ void GUIDivisional::write(wxTextFile *outFile) {
4848
GUIButton::write(outFile);
4949
}
5050

51+
GUIDivisional* GUIDivisional::clone() {
52+
return new GUIDivisional(*this);
53+
}
54+
5155
bool GUIDivisional::isReferencing(Divisional *divisional) {
5256
return m_divisional == divisional ? true : false;
5357
}

src/GUIDivisional.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class GUIDivisional : public GUIButton {
3232
~GUIDivisional();
3333

3434
void write(wxTextFile *outFile);
35+
virtual GUIDivisional* clone();
3536
bool isReferencing(Divisional *divisional);
3637
void updateDisplayName();
3738
wxString getElementName();

src/GUIDivisionalCoupler.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ void GUIDivisionalCoupler::write(wxTextFile *outFile) {
4242
GUIButton::write(outFile);
4343
}
4444

45+
GUIDivisionalCoupler* GUIDivisionalCoupler::clone() {
46+
return new GUIDivisionalCoupler(*this);
47+
}
48+
4549
bool GUIDivisionalCoupler::isReferencing(DivisionalCoupler *divCplr) {
4650
return m_divCoupler == divCplr ? true : false;
4751
}

src/GUIDivisionalCoupler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class GUIDivisionalCoupler : public GUIButton {
3232
~GUIDivisionalCoupler();
3333

3434
void write(wxTextFile *outFile);
35+
virtual GUIDivisionalCoupler* clone();
3536
bool isReferencing(DivisionalCoupler *divisional);
3637
void updateDisplayName();
3738
wxString getElementName();

0 commit comments

Comments
 (0)