Skip to content

Commit

Permalink
Fixed displaying long file paths in the Paths and Reverb tabs of the …
Browse files Browse the repository at this point in the history
…settings dialog GrandOrgue#1663
  • Loading branch information
oleg68 committed Mar 2, 2024
1 parent 5a8256d commit 2dabf50
Show file tree
Hide file tree
Showing 7 changed files with 137 additions and 21 deletions.
1 change: 1 addition & 0 deletions src/grandorgue/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ sound/GOSoundStateHandler.cpp
sound/GOSound.cpp
yaml/GOSaveableToYaml.cpp
yaml/go-wx-yaml.cpp
wxcontrols/GORightVisiblePicker.cpp
GOAudioGauge.cpp
GOAudioRecorder.cpp
GOBitmapCache.cpp
Expand Down
30 changes: 11 additions & 19 deletions src/grandorgue/dialogs/settings/GOSettingsPaths.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright 2006 Milan Digital Audio LLC
* Copyright 2009-2023 GrandOrgue contributors (see AUTHORS)
* Copyright 2009-2024 GrandOrgue contributors (see AUTHORS)
* License GPL-2.0 or later
* (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html).
*/
Expand All @@ -14,6 +14,7 @@
#include <wx/string.h>

#include "config/GOConfig.h"
#include "wxcontrols/GODirPickerCtrl.h"

GOSettingsPaths::GOSettingsPaths(GOConfig &settings, wxWindow *parent)
: wxPanel(parent, wxID_ANY), m_config(settings) {
Expand All @@ -27,10 +28,9 @@ GOSettingsPaths::GOSettingsPaths(GOConfig &settings, wxWindow *parent)
0,
wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT);
grid->Add(
m_Samplesets = new wxDirPickerCtrl(
m_Samplesets = new GODirPickerCtrl(
this,
wxID_ANY,
wxEmptyString,
_("Select directory for open new organs at"),
wxDefaultPosition,
wxDefaultSize,
Expand All @@ -43,10 +43,9 @@ GOSettingsPaths::GOSettingsPaths(GOConfig &settings, wxWindow *parent)
0,
wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT);
grid->Add(
m_OrganPackages = new wxDirPickerCtrl(
m_OrganPackages = new GODirPickerCtrl(
this,
wxID_ANY,
wxEmptyString,
_("Select directory for load new organ packages from"),
wxDefaultPosition,
wxDefaultSize,
Expand All @@ -59,10 +58,9 @@ GOSettingsPaths::GOSettingsPaths(GOConfig &settings, wxWindow *parent)
0,
wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT);
grid->Add(
m_OrganCache = new wxDirPickerCtrl(
m_OrganCache = new GODirPickerCtrl(
this,
wxID_ANY,
wxEmptyString,
_("Select directory for storing organ cache"),
wxDefaultPosition,
wxDefaultSize,
Expand All @@ -74,10 +72,9 @@ GOSettingsPaths::GOSettingsPaths(GOConfig &settings, wxWindow *parent)
0,
wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT);
grid->Add(
m_OrganSettings = new wxDirPickerCtrl(
m_OrganSettings = new GODirPickerCtrl(
this,
wxID_ANY,
wxEmptyString,
_("Select directory for storing organ settings"),
wxDefaultPosition,
wxDefaultSize,
Expand All @@ -90,10 +87,9 @@ GOSettingsPaths::GOSettingsPaths(GOConfig &settings, wxWindow *parent)
0,
wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT);
grid->Add(
m_OrganCombinations = new wxDirPickerCtrl(
m_OrganCombinations = new GODirPickerCtrl(
this,
wxID_ANY,
wxEmptyString,
_("Select directory for export/import organ combinations"),
wxDefaultPosition,
wxDefaultSize,
Expand All @@ -106,10 +102,9 @@ GOSettingsPaths::GOSettingsPaths(GOConfig &settings, wxWindow *parent)
0,
wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT);
grid->Add(
m_ExportImport = new wxDirPickerCtrl(
m_ExportImport = new GODirPickerCtrl(
this,
wxID_ANY,
wxEmptyString,
_("Select directory for export/import organ settings"),
wxDefaultPosition,
wxDefaultSize,
Expand All @@ -122,10 +117,9 @@ GOSettingsPaths::GOSettingsPaths(GOConfig &settings, wxWindow *parent)
0,
wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT);
grid->Add(
m_AudioRecorder = new wxDirPickerCtrl(
m_AudioRecorder = new GODirPickerCtrl(
this,
wxID_ANY,
wxEmptyString,
_("Select directory for your audio recordings"),
wxDefaultPosition,
wxDefaultSize,
Expand All @@ -138,10 +132,9 @@ GOSettingsPaths::GOSettingsPaths(GOConfig &settings, wxWindow *parent)
0,
wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT);
grid->Add(
m_MidiRecorder = new wxDirPickerCtrl(
m_MidiRecorder = new GODirPickerCtrl(
this,
wxID_ANY,
wxEmptyString,
_("Select directory for your MIDI recording"),
wxDefaultPosition,
wxDefaultSize,
Expand All @@ -154,10 +147,9 @@ GOSettingsPaths::GOSettingsPaths(GOConfig &settings, wxWindow *parent)
0,
wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT);
grid->Add(
m_MidiPlayer = new wxDirPickerCtrl(
m_MidiPlayer = new GODirPickerCtrl(
this,
wxID_ANY,
wxEmptyString,
_("Select directory for the MIDI player"),
wxDefaultPosition,
wxDefaultSize,
Expand Down
4 changes: 2 additions & 2 deletions src/grandorgue/dialogs/settings/GOSettingsReverb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "config/GOConfig.h"
#include "files/GOStandardFile.h"
#include "wxcontrols/GOFilePickerCtrl.h"

#include "GOWave.h"

Expand Down Expand Up @@ -53,10 +54,9 @@ GOSettingsReverb::GOSettingsReverb(GOConfig &settings, wxWindow *parent)
new wxStaticText(this, wxID_ANY, _("Impulse response:")),
0,
wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT);
m_File = new wxFilePickerCtrl(
m_File = new GOFilePickerCtrl(
this,
ID_FILE,
wxEmptyString,
_("Select an impulse file"),
_("*.wav"),
wxDefaultPosition,
Expand Down
30 changes: 30 additions & 0 deletions src/grandorgue/wxcontrols/GODirPickerCtrl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright 2006 Milan Digital Audio LLC
* Copyright 2009-2024 GrandOrgue contributors (see AUTHORS)
* License GPL-2.0 or later
* (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html).
*/

#ifndef GODIRPICKERCTRL_H
#define GODIRPICKERCTRL_H

#include <wx/filepicker.h>

#include "GORightVisiblePicker.h"

class GODirPickerCtrl : public wxDirPickerCtrl, private GORightVisiblePicker {
public:
GODirPickerCtrl(
wxWindow *parent,
wxWindowID id,
const wxString &title,
const wxPoint &pos = wxDefaultPosition,
const wxSize &size = wxDefaultSize,
long style = 0)
: wxDirPickerCtrl(parent, id, wxEmptyString, title, pos, size, style),
GORightVisiblePicker(this) {}

OVERRIDE_UPDATE_TEXTCTRL(wxDirPickerCtrl)
};

#endif /* GODIRPICKERCTRL_H */
32 changes: 32 additions & 0 deletions src/grandorgue/wxcontrols/GOFilePickerCtrl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright 2006 Milan Digital Audio LLC
* Copyright 2009-2024 GrandOrgue contributors (see AUTHORS)
* License GPL-2.0 or later
* (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html).
*/

#ifndef GOFILEPICKERCTRL_H
#define GOFILEPICKERCTRL_H

#include <wx/filepicker.h>

#include "GORightVisiblePicker.h"

class GOFilePickerCtrl : public wxFilePickerCtrl, private GORightVisiblePicker {
public:
GOFilePickerCtrl(
wxWindow *parent,
wxWindowID id,
const wxString &title,
const wxString &wildcard,
const wxPoint &pos = wxDefaultPosition,
const wxSize &size = wxDefaultSize,
long style = 0)
: wxFilePickerCtrl(
parent, id, wxEmptyString, title, wildcard, pos, size, style),
GORightVisiblePicker(this) {}

OVERRIDE_UPDATE_TEXTCTRL(wxFilePickerCtrl)
};

#endif /* GOFILEPICKERCTRL_H */
19 changes: 19 additions & 0 deletions src/grandorgue/wxcontrols/GORightVisiblePicker.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright 2006 Milan Digital Audio LLC
* Copyright 2009-2024 GrandOrgue contributors (see AUTHORS)
* License GPL-2.0 or later
* (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html).
*/

#include "GORightVisiblePicker.h"

#include <wx/pickerbase.h>
#include <wx/textctrl.h>

void GORightVisiblePicker::EnsureRigtIsVisible() {
wxTextCtrl *pTxt = p_picker->GetTextCtrl();

if (pTxt) {
pTxt->ShowPosition(pTxt->GetValue().length());
}
}
42 changes: 42 additions & 0 deletions src/grandorgue/wxcontrols/GORightVisiblePicker.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright 2006 Milan Digital Audio LLC
* Copyright 2009-2024 GrandOrgue contributors (see AUTHORS)
* License GPL-2.0 or later
* (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html).
*/

#ifndef GORIGHTVISIBLEPICKER_H
#define GORIGHTVISIBLEPICKER_H

class wxPickerBase;

/**
* This class is designed for enchancing the standard wx*PickerCtrl classes
* If the file name is too long to fit in the text control, it makes visible
* the rightmost part of the filename
*
* Usage:
* 1. make a subclass of wx*PickerCtrl and GORightVisiblePicker
* 2. use the OVERRIDE_UPDATE_TEXTCTRL macro
*/

class GORightVisiblePicker {
private:
wxPickerBase *p_picker;

protected:
GORightVisiblePicker(wxPickerBase *pPicker) : p_picker(pPicker) {}

// Scrolls the text in the text control of the p_picker to right
void EnsureRigtIsVisible();
};

// This macro must be used in the class declaration for overriding the standard
// UpdatePickerFromTextCtrl() method
#define OVERRIDE_UPDATE_TEXTCTRL(baseClass) \
void UpdateTextCtrlFromPicker() override { \
baseClass::UpdateTextCtrlFromPicker(); \
EnsureRigtIsVisible(); \
}

#endif /* GORIGHTVISIBLEPICKER_H */

0 comments on commit 2dabf50

Please sign in to comment.