Skip to content

Commit

Permalink
Fixed Building PerfTests GrandOrgue#868
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg Samarin committed Mar 7, 2022
1 parent a0f63eb commit 424c784
Show file tree
Hide file tree
Showing 14 changed files with 152 additions and 115 deletions.
4 changes: 2 additions & 2 deletions src/grandorgue/GODefinitionFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ GODefinitionFile::GODefinitionFile(GODocument *doc, GOConfig &settings)
m_GeneralTemplate(this),
m_PitchLabel(this),
m_TemperamentLabel(this),
m_MainWindowData(this) {
m_MainWindowData(this, wxT("MainWindow")) {
m_pool.SetMemoryLimit(m_config.MemoryLimit() * 1024 * 1024);
}

Expand Down Expand Up @@ -252,7 +252,7 @@ void GODefinitionFile::ReadOrganFile(GOConfigReader &cfg) {
m_PitchLabel.Load(cfg, wxT("SetterMasterPitch"), _("organ pitch"));
m_TemperamentLabel.Load(
cfg, wxT("SetterMasterTemperament"), _("temperament"));
m_MainWindowData.Load(cfg, wxT("MainWindow"));
m_MainWindowData.Load(cfg);

m_panels.resize(0);
m_panels.push_back(new GOGUIPanel(this));
Expand Down
22 changes: 11 additions & 11 deletions src/grandorgue/GODocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@
#include "GOFrame.h"
#include "GOOrgan.h"
#include "GOPanelView.h"
#include "GOResizable.h"
#include "go_ids.h"

GODocument::GODocument(GOSound *sound)
: m_OrganFileReady(false),
m_organfile(NULL),
GODocument::GODocument(GOResizable *pMainWindow, GOSound *sound)
: p_MainWindow(pMainWindow),
m_sound(*sound),
m_OrganFileReady(false),
m_organfile(NULL),
m_listener(),
m_modified(false) {
m_listener.Register(&m_sound.GetMidi());
Expand Down Expand Up @@ -81,13 +83,11 @@ bool GODocument::Import(
for (unsigned i = 0; i < m_organfile->GetPanelCount(); i++)
if (m_organfile->GetPanel(i)->InitialOpenWindow())
ShowPanel(i);
if (!m_organfile->GetMainWindowData()->GetWindowSize().IsEmpty()) {
GOFrame *const frame = dynamic_cast<GOFrame *>(wxTheApp->GetTopWindow());

if (frame)
frame->ApplyRectFromSettings(
m_organfile->GetMainWindowData()->GetWindowSize());
}
const GOLogicalRect &mRect(m_organfile->GetMainWindowData()->GetWindowRect());

if (!mRect.IsEmpty() && p_MainWindow)
p_MainWindow->SetPosSize(mRect);

m_sound.AssignOrganFile(m_organfile);
m_OrganFileReady = true;
Expand Down Expand Up @@ -128,8 +128,8 @@ void GODocument::ShowPanel(unsigned id) {

void GODocument::SyncState() {
m_organfile->SetVolume(m_sound.GetEngine().GetVolume());
m_organfile->GetMainWindowData()->SetWindowSize(
wxTheApp->GetTopWindow()->GetRect());
if (p_MainWindow)
p_MainWindow->SetPosSize(p_MainWindow->GetPosSize());
for (unsigned i = 0; i < m_organfile->GetPanelCount(); i++)
m_organfile->GetPanel(i)->SetInitialOpenWindow(false);
GODocumentBase::SyncState();
Expand Down
10 changes: 7 additions & 3 deletions src/grandorgue/GODocument.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,25 @@
#include "midi/GOMidiListener.h"
#include "threading/GOMutex.h"

class GODefinitionFile;
class GOKeyReceiver;
class GOMidiEvent;
class GOMidiReceiverBase;
class GOMidiSender;
class GOOrgan;
class GOProgressDialog;
class GOResizable;
class GOSound;
class GODefinitionFile;

class GODocument : public GODocumentBase, protected GOMidiCallback {
private:
GOResizable *p_MainWindow;
GOSound &m_sound;

GOMutex m_lock;
bool m_OrganFileReady;
GODefinitionFile *m_organfile;
GOSound &m_sound;

GOMidiListener m_listener;
bool m_modified;

Expand All @@ -39,7 +43,7 @@ class GODocument : public GODocumentBase, protected GOMidiCallback {
void CloseOrgan();

public:
GODocument(GOSound *sound);
GODocument(GOResizable *pMainWindow, GOSound *sound);
~GODocument();

bool IsModified();
Expand Down
27 changes: 20 additions & 7 deletions src/grandorgue/GOFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "GODefinitionFile.h"
#include "GODocument.h"
#include "GOEvent.h"
#include "GOLogicalRect.h"
#include "GOOrgan.h"
#include "GOPath.h"
#include "GOProperties.h"
Expand Down Expand Up @@ -369,7 +370,7 @@ GOFrame::GOFrame(

UpdateSize();

ApplyRectFromSettings(m_config.GetMainWindowRect());
SetPosSize(m_config.GetMainWindowRect());

m_listener.Register(&m_Sound.GetMidi());
m_isMeterReady = true;
Expand Down Expand Up @@ -432,10 +433,22 @@ void GOFrame::UpdateSize() {
SetMaxSize(wxSize(frameSize.GetWidth() * 4, frameSize.GetHeight()));
}

void GOFrame::ApplyRectFromSettings(wxRect rect) {
if (rect.width && rect.height) { // settings are valid
wxRect minSize(GetMinSize());
wxRect maxSize(GetMaxSize());
GOLogicalRect GOFrame::GetPosSize() const {
GOLogicalRect lRect;
const wxRect gRect(GetRect());

lRect.x = gRect.x;
lRect.y = gRect.y;
lRect.width = gRect.width;
lRect.height = gRect.height;
return lRect;
}

void GOFrame::SetPosSize(const GOLogicalRect &lRect) {
if (lRect.width && lRect.height) { // settings are valid
wxRect rect(lRect.x, lRect.y, lRect.width, lRect.height);
const wxRect minSize(GetMinSize());
const wxRect maxSize(GetMaxSize());

if (rect.width < minSize.width)
rect.width = minSize.width;
Expand Down Expand Up @@ -595,7 +608,7 @@ void GOFrame::Open(const GOOrgan &organ) {
if (!m_locker.IsLocked())
return;
GOProgressDialog dlg;
m_doc = new GODocument(&m_Sound);
m_doc = new GODocument(this, &m_Sound);
m_doc->Load(&dlg, organ);
UpdatePanelMenu();
}
Expand Down Expand Up @@ -1072,7 +1085,7 @@ void GOFrame::OnSettings(wxCommandEvent &event) {
manager.RegisterPackageDirectory(m_config.OrganPackagePath());

UpdateVolumeControlWithSettings();
m_config.SetMainWindowRect(GetRect());
m_config.SetMainWindowRect(GetPosSize());

// because the sound settings might be changed, close sound.
// It will reopened later
Expand Down
9 changes: 6 additions & 3 deletions src/grandorgue/GOFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@

#include <vector>

#include "GOEvent.h"
#include "midi/GOMidiCallback.h"
#include "midi/GOMidiListener.h"
#include "threading/GOMutex.h"

#include "GOEvent.h"
#include "GOResizable.h"

class GOApp;
class GODocument;
class GOMidiEvent;
Expand All @@ -43,7 +45,7 @@ class GOAudioGauge;
class wxHtmlHelpController;
class wxSpinCtrl;

class GOFrame : public wxFrame, protected GOMidiCallback {
class GOFrame : public wxFrame, public GOResizable, protected GOMidiCallback {
private:
GOApp &m_App;
GOMutex m_mutex;
Expand Down Expand Up @@ -180,7 +182,8 @@ class GOFrame : public wxFrame, protected GOMidiCallback {

void SendLoadFile(wxString filename);

void ApplyRectFromSettings(wxRect rect);
virtual GOLogicalRect GetPosSize() const override;
virtual void SetPosSize(const GOLogicalRect &rect) override;

DECLARE_EVENT_TABLE()
};
Expand Down
24 changes: 24 additions & 0 deletions src/grandorgue/GOLogicalRect.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright 2006 Milan Digital Audio LLC
* Copyright 2009-2021 GrandOrgue contributors (see AUTHORS)
* License GPL-2.0 or later
* (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html).
*/

#ifndef GOLOGICALRECT_H
#define GOLOGICALRECT_H

struct GOLogicalRect {
int x;
int y;
unsigned width;
unsigned height;

GOLogicalRect(int xx, int yy, unsigned ww, unsigned hh)
: x(xx), y(yy), width(ww), height(hh) {}
GOLogicalRect() : x(0), y(0), width(0), height(0) {}

bool IsEmpty() const { return width <= 0 || height <= 0; }
};

#endif /* GOLOGICALRECT_H */
38 changes: 11 additions & 27 deletions src/grandorgue/GOMainWindowData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,26 @@

#include "GOMainWindowData.h"

#include "GODefinitionFile.h"
#include "config/GOConfigReader.h"
#include "config/GOConfigWriter.h"

GOMainWindowData::GOMainWindowData(GODefinitionFile *organfile)
: m_organfile(organfile) {}

GOMainWindowData::~GOMainWindowData() {}
#include "GODefinitionFile.h"

void GOMainWindowData::Load(GOConfigReader &cfg, wxString group) {
m_organfile->RegisterSaveableObject(this);
int x = cfg.ReadInteger(
void GOMainWindowData::Load(GOConfigReader &cfg) {
p_organFile->RegisterSaveableObject(this);
m_rect.x = cfg.ReadInteger(
CMBSetting, m_group, wxT("WindowX"), -20, 10000, false, 0);
int y = cfg.ReadInteger(
m_rect.y = cfg.ReadInteger(
CMBSetting, m_group, wxT("WindowY"), -20, 10000, false, 0);
int w = cfg.ReadInteger(
m_rect.width = cfg.ReadInteger(
CMBSetting, m_group, wxT("WindowWidth"), 0, 10000, false, 0);
int h = cfg.ReadInteger(
m_rect.height = cfg.ReadInteger(
CMBSetting, m_group, wxT("WindowHeight"), 0, 10000, false, 0);
m_size = wxRect(x, y, w, h);
}

void GOMainWindowData::Save(GOConfigWriter &cfg) {
wxRect size = m_size;
int x = size.GetLeft();
int y = size.GetTop();
if (x < -20)
x = -20;
if (y < -20)
y = -20;
cfg.WriteInteger(m_group, wxT("WindowX"), x);
cfg.WriteInteger(m_group, wxT("WindowY"), y);
cfg.WriteInteger(m_group, wxT("WindowWidth"), size.GetWidth());
cfg.WriteInteger(m_group, wxT("WindowHeight"), size.GetHeight());
cfg.WriteInteger(m_group, wxT("WindowX"), std::max(m_rect.x, -20));
cfg.WriteInteger(m_group, wxT("WindowY"), std::max(m_rect.y, -20));
cfg.WriteInteger(m_group, wxT("WindowWidth"), m_rect.width);
cfg.WriteInteger(m_group, wxT("WindowHeight"), m_rect.height);
}

wxRect GOMainWindowData::GetWindowSize() { return m_size; }

void GOMainWindowData::SetWindowSize(wxRect rect) { m_size = rect; }
23 changes: 13 additions & 10 deletions src/grandorgue/GOMainWindowData.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,27 @@

#include <wx/gdicmn.h>

#include "GOLogicalRect.h"
#include "GOSaveableObject.h"

class GODefinitionFile;

class GOMainWindowData : private GOSaveableObject {
protected:
GODefinitionFile *m_organfile;
wxRect m_size;

void Save(GOConfigWriter &cfg);
GODefinitionFile *p_organFile;
GOLogicalRect m_rect;

public:
GOMainWindowData(GODefinitionFile *m_organfile);
virtual ~GOMainWindowData();
void Load(GOConfigReader &cfg, wxString group);

wxRect GetWindowSize();
void SetWindowSize(wxRect rect);
GOMainWindowData(GODefinitionFile *pOrganFile, const wxString &group)
: p_organFile(pOrganFile) {
m_group = group;
}
virtual ~GOMainWindowData() {}

void Load(GOConfigReader &cfg);
const GOLogicalRect &GetWindowRect() const { return m_rect; }
void SetWindowRect(const GOLogicalRect &rect) { m_rect = rect; }
void Save(GOConfigWriter &cfg);
};

#endif
4 changes: 2 additions & 2 deletions src/grandorgue/GOReleaseAlignTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ void GOReleaseAlignTable::ComputeTable(
= (PHASE_ALIGN_AMPLITUDES * f_mod) / (2 * m_PhaseAlignMaxAmplitude);

/* Store this release point if it was not already found */
assert((derivIndex >= 0) && (derivIndex < PHASE_ALIGN_DERIVATIVES));
assert((ampIndex >= 0) && (ampIndex < PHASE_ALIGN_AMPLITUDES));
derivIndex = (derivIndex < 0)
? 0
: (
Expand All @@ -118,6 +116,8 @@ void GOReleaseAlignTable::ComputeTable(
: (
(ampIndex >= PHASE_ALIGN_AMPLITUDES) ? PHASE_ALIGN_AMPLITUDES - 1
: ampIndex);
assert((derivIndex >= 0) && (derivIndex < PHASE_ALIGN_DERIVATIVES));
assert((ampIndex >= 0) && (ampIndex < PHASE_ALIGN_AMPLITUDES));
if (!found[derivIndex][ampIndex]) {
m_PositionEntries[derivIndex][ampIndex] = i + 1 + start_position;
found[derivIndex][ampIndex] = true;
Expand Down
19 changes: 19 additions & 0 deletions src/grandorgue/GOResizable.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright 2006 Milan Digital Audio LLC
* Copyright 2009-2021 GrandOrgue contributors (see AUTHORS)
* License GPL-2.0 or later
* (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html).
*/

#ifndef GORESIZABLE_H
#define GORESIZABLE_H

#include "GOLogicalRect.h"

class GOResizable {
public:
virtual GOLogicalRect GetPosSize() const = 0;
virtual void SetPosSize(const GOLogicalRect &rect) = 0;
};

#endif /* GORESIZABLE_H */
Loading

0 comments on commit 424c784

Please sign in to comment.