mirror of
https://github.com/cookiengineer/audacity
synced 2025-09-17 08:40:27 +02:00
More constructor arguments for RulerPanel
This commit is contained in:
parent
8625df6814
commit
ab5ff9060b
@ -280,17 +280,16 @@ FreqWindow::FreqWindow(wxWindow * parent, wxWindowID id,
|
|||||||
|
|
||||||
S.StartVerticalLay(2);
|
S.StartVerticalLay(2);
|
||||||
{
|
{
|
||||||
vRuler = safenew RulerPanel(this, wxID_ANY);
|
vRuler = safenew RulerPanel(
|
||||||
vRuler->ruler.SetBounds(0, 0, 100, 100); // Ruler can't handle small sizes
|
this, wxID_ANY, wxVERTICAL,
|
||||||
vRuler->ruler.SetOrientation(wxVERTICAL);
|
wxSize{ 100, 100 }, // Ruler can't handle small sizes
|
||||||
vRuler->ruler.SetRange(0.0, -dBRange);
|
RulerPanel::Range{ 0.0, -dBRange },
|
||||||
vRuler->ruler.SetFormat(Ruler::LinearDBFormat);
|
Ruler::LinearDBFormat,
|
||||||
vRuler->ruler.SetUnits(_("dB"));
|
_("dB"),
|
||||||
vRuler->ruler.SetLabelEdges(true);
|
RulerPanel::Options{}
|
||||||
int w;
|
.LabelEdges(true)
|
||||||
vRuler->ruler.GetMaxSize(&w, NULL);
|
.TickColour( theTheme.Colour( clrGraphLabels ) )
|
||||||
vRuler->SetMinSize(wxSize(w, 150)); // height needed for wxGTK
|
);
|
||||||
vRuler->SetTickColour( theTheme.Colour( clrGraphLabels ));
|
|
||||||
|
|
||||||
S.AddSpace(wxDefaultCoord, 1);
|
S.AddSpace(wxDefaultCoord, 1);
|
||||||
S.Prop(1);
|
S.Prop(1);
|
||||||
@ -348,19 +347,18 @@ FreqWindow::FreqWindow(wxWindow * parent, wxWindowID id,
|
|||||||
|
|
||||||
S.StartHorizontalLay(wxEXPAND, 0);
|
S.StartHorizontalLay(wxEXPAND, 0);
|
||||||
{
|
{
|
||||||
hRuler = safenew RulerPanel(this, wxID_ANY);
|
hRuler = safenew RulerPanel(
|
||||||
hRuler->ruler.SetBounds(0, 0, 100, 100); // Ruler can't handle small sizes
|
this, wxID_ANY, wxHORIZONTAL,
|
||||||
hRuler->ruler.SetOrientation(wxHORIZONTAL);
|
wxSize{ 100, 100 }, // Ruler can't handle small sizes
|
||||||
hRuler->ruler.SetLog(true);
|
RulerPanel::Range{ 10, 20000 },
|
||||||
hRuler->ruler.SetRange(10, 20000);
|
Ruler::RealFormat,
|
||||||
hRuler->ruler.SetFormat(Ruler::RealFormat);
|
_("Hz"),
|
||||||
hRuler->ruler.SetUnits(_("Hz"));
|
RulerPanel::Options{}
|
||||||
hRuler->ruler.SetFlip(true);
|
.Log(true)
|
||||||
hRuler->ruler.SetLabelEdges(true);
|
.Flip(true)
|
||||||
int h;
|
.LabelEdges(true)
|
||||||
hRuler->ruler.GetMaxSize(NULL, &h);
|
.TickColour( theTheme.Colour( clrGraphLabels ) )
|
||||||
hRuler->SetMinSize(wxSize(wxDefaultCoord, h));
|
);
|
||||||
hRuler->SetTickColour( theTheme.Colour( clrGraphLabels ));
|
|
||||||
|
|
||||||
S.AddSpace(1, wxDefaultCoord);
|
S.AddSpace(1, wxDefaultCoord);
|
||||||
S.Prop(1);
|
S.Prop(1);
|
||||||
|
@ -623,18 +623,17 @@ void EffectEqualization::PopulateOrExchange(ShuttleGui & S)
|
|||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
S.StartVerticalLay();
|
S.StartVerticalLay();
|
||||||
{
|
{
|
||||||
mdBRuler = safenew RulerPanel(parent, wxID_ANY);
|
mdBRuler = safenew RulerPanel(
|
||||||
mdBRuler->ruler.SetBounds(0, 0, 100, 100); // Ruler can't handle small sizes
|
parent, wxID_ANY, wxVERTICAL,
|
||||||
mdBRuler->ruler.SetOrientation(wxVERTICAL);
|
wxSize{ 100, 100 }, // Ruler can't handle small sizes
|
||||||
mdBRuler->ruler.SetRange(60.0, -120.0);
|
RulerPanel::Range{ 60.0, -120.0 },
|
||||||
mdBRuler->ruler.SetFormat(Ruler::LinearDBFormat);
|
Ruler::LinearDBFormat,
|
||||||
mdBRuler->ruler.SetUnits(_("dB"));
|
_("dB"),
|
||||||
mdBRuler->ruler.SetLabelEdges(true);
|
RulerPanel::Options{}
|
||||||
mdBRuler->ruler.mbTicksAtExtremes = true;
|
.LabelEdges(true)
|
||||||
int w;
|
.TicksAtExtremes(true)
|
||||||
mdBRuler->ruler.GetMaxSize(&w, NULL);
|
.TickColour( { 0, 0, 0 } )
|
||||||
mdBRuler->SetMinSize(wxSize(w, 150)); // height needed for wxGTK
|
);
|
||||||
mdBRuler->ruler.SetTickColour( wxColour(0,0,0) );
|
|
||||||
|
|
||||||
S.Prop(1);
|
S.Prop(1);
|
||||||
S.AddSpace(0, 1);
|
S.AddSpace(0, 1);
|
||||||
@ -677,20 +676,19 @@ void EffectEqualization::PopulateOrExchange(ShuttleGui & S)
|
|||||||
// Column 1 is empty
|
// Column 1 is empty
|
||||||
S.AddSpace(1, 1);
|
S.AddSpace(1, 1);
|
||||||
|
|
||||||
mFreqRuler = safenew RulerPanel(parent, wxID_ANY);
|
mFreqRuler = safenew RulerPanel(
|
||||||
mFreqRuler->ruler.SetBounds(0, 0, 100, 100); // Ruler can't handle small sizes
|
parent, wxID_ANY, wxHORIZONTAL,
|
||||||
mFreqRuler->ruler.SetOrientation(wxHORIZONTAL);
|
wxSize{ 100, 100 }, // Ruler can't handle small sizes
|
||||||
mFreqRuler->ruler.SetLog(true);
|
RulerPanel::Range{ mLoFreq, mHiFreq },
|
||||||
mFreqRuler->ruler.SetRange(mLoFreq, mHiFreq);
|
Ruler::IntFormat,
|
||||||
mFreqRuler->ruler.SetFormat(Ruler::IntFormat);
|
_("Hz"),
|
||||||
mFreqRuler->ruler.SetUnits(_("Hz"));
|
RulerPanel::Options{}
|
||||||
mFreqRuler->ruler.SetFlip(true);
|
.Log(true)
|
||||||
mFreqRuler->ruler.SetLabelEdges(true);
|
.Flip(true)
|
||||||
mFreqRuler->ruler.mbTicksAtExtremes = true;
|
.LabelEdges(true)
|
||||||
int h;
|
.TicksAtExtremes(true)
|
||||||
mFreqRuler->ruler.GetMaxSize(NULL, &h);
|
.TickColour( { 0, 0, 0 } )
|
||||||
mFreqRuler->SetMinSize(wxSize(wxDefaultCoord, h));
|
);
|
||||||
mFreqRuler->ruler.SetTickColour( wxColour(0,0,0) );
|
|
||||||
|
|
||||||
|
|
||||||
S.Prop(1);
|
S.Prop(1);
|
||||||
|
@ -377,16 +377,15 @@ void EffectScienFilter::PopulateOrExchange(ShuttleGui & S)
|
|||||||
|
|
||||||
S.StartVerticalLay();
|
S.StartVerticalLay();
|
||||||
{
|
{
|
||||||
mdBRuler = safenew RulerPanel(parent, wxID_ANY);
|
mdBRuler = safenew RulerPanel(
|
||||||
mdBRuler->ruler.SetBounds(0, 0, 100, 100); // Ruler can't handle small sizes
|
parent, wxID_ANY, wxVERTICAL,
|
||||||
mdBRuler->ruler.SetOrientation(wxVERTICAL);
|
wxSize{ 100, 100 }, // Ruler can't handle small sizes
|
||||||
mdBRuler->ruler.SetRange(30.0, -120.0);
|
RulerPanel::Range{ 30.0, -120.0 },
|
||||||
mdBRuler->ruler.SetFormat(Ruler::LinearDBFormat);
|
Ruler::LinearDBFormat,
|
||||||
mdBRuler->ruler.SetUnits(_("dB"));
|
_("dB"),
|
||||||
mdBRuler->ruler.SetLabelEdges(true);
|
RulerPanel::Options{}
|
||||||
int w;
|
.LabelEdges(true)
|
||||||
mdBRuler->ruler.GetMaxSize(&w, NULL);
|
);
|
||||||
mdBRuler->SetSize(wxSize(w, 150)); // height needed for wxGTK
|
|
||||||
|
|
||||||
S.SetBorder(1);
|
S.SetBorder(1);
|
||||||
S.AddSpace(1, 1);
|
S.AddSpace(1, 1);
|
||||||
@ -430,18 +429,17 @@ void EffectScienFilter::PopulateOrExchange(ShuttleGui & S)
|
|||||||
|
|
||||||
S.AddSpace(1, 1);
|
S.AddSpace(1, 1);
|
||||||
|
|
||||||
mfreqRuler = safenew RulerPanel(parent, wxID_ANY);
|
mfreqRuler = safenew RulerPanel(
|
||||||
mfreqRuler->ruler.SetBounds(0, 0, 100, 100); // Ruler can't handle small sizes
|
parent, wxID_ANY, wxHORIZONTAL,
|
||||||
mfreqRuler->ruler.SetOrientation(wxHORIZONTAL);
|
wxSize{ 100, 100 }, // Ruler can't handle small sizes
|
||||||
mfreqRuler->ruler.SetLog(true);
|
RulerPanel::Range{ mLoFreq, mNyquist },
|
||||||
mfreqRuler->ruler.SetRange(mLoFreq, mNyquist);
|
Ruler::IntFormat,
|
||||||
mfreqRuler->ruler.SetFormat(Ruler::IntFormat);
|
wxT(""),
|
||||||
mfreqRuler->ruler.SetUnits(wxT(""));
|
RulerPanel::Options{}
|
||||||
mfreqRuler->ruler.SetFlip(true);
|
.Log(true)
|
||||||
mfreqRuler->ruler.SetLabelEdges(true);
|
.Flip(true)
|
||||||
int h;
|
.LabelEdges(true)
|
||||||
mfreqRuler->ruler.GetMaxSize(NULL, &h);
|
);
|
||||||
mfreqRuler->SetMinSize(wxSize(-1, h));
|
|
||||||
|
|
||||||
S.Prop(1);
|
S.Prop(1);
|
||||||
S.AddWindow(mfreqRuler, wxEXPAND | wxALIGN_LEFT | wxRIGHT);
|
S.AddWindow(mfreqRuler, wxEXPAND | wxALIGN_LEFT | wxRIGHT);
|
||||||
|
@ -1606,10 +1606,37 @@ END_EVENT_TABLE()
|
|||||||
IMPLEMENT_CLASS(RulerPanel, wxPanelWrapper)
|
IMPLEMENT_CLASS(RulerPanel, wxPanelWrapper)
|
||||||
|
|
||||||
RulerPanel::RulerPanel(wxWindow* parent, wxWindowID id,
|
RulerPanel::RulerPanel(wxWindow* parent, wxWindowID id,
|
||||||
|
wxOrientation orientation,
|
||||||
|
const wxSize &bounds,
|
||||||
|
const Range &range,
|
||||||
|
Ruler::RulerFormat format,
|
||||||
|
const wxString &units,
|
||||||
|
const Options &options,
|
||||||
const wxPoint& pos /*= wxDefaultPosition*/,
|
const wxPoint& pos /*= wxDefaultPosition*/,
|
||||||
const wxSize& size /*= wxDefaultSize*/):
|
const wxSize& size /*= wxDefaultSize*/):
|
||||||
wxPanelWrapper(parent, id, pos, size)
|
wxPanelWrapper(parent, id, pos, size)
|
||||||
{
|
{
|
||||||
|
ruler.SetBounds( 0, 0, bounds.x, bounds.y );
|
||||||
|
ruler.SetOrientation(orientation);
|
||||||
|
ruler.SetRange( range.first, range.second );
|
||||||
|
ruler.SetLog( options.log );
|
||||||
|
ruler.SetFormat(format);
|
||||||
|
ruler.SetUnits( units );
|
||||||
|
ruler.SetFlip( options.flip );
|
||||||
|
ruler.SetLabelEdges( options.labelEdges );
|
||||||
|
ruler.mbTicksAtExtremes = options.ticksAtExtremes;
|
||||||
|
if (orientation == wxVERTICAL) {
|
||||||
|
wxCoord w;
|
||||||
|
ruler.GetMaxSize(&w, NULL);
|
||||||
|
SetMinSize(wxSize(w, 150)); // height needed for wxGTK
|
||||||
|
}
|
||||||
|
else if (orientation == wxHORIZONTAL) {
|
||||||
|
wxCoord h;
|
||||||
|
ruler.GetMaxSize(NULL, &h);
|
||||||
|
SetMinSize(wxSize(wxDefaultCoord, h));
|
||||||
|
}
|
||||||
|
if (options.hasTickColour)
|
||||||
|
ruler.SetTickColour( options.tickColour );
|
||||||
}
|
}
|
||||||
|
|
||||||
RulerPanel::~RulerPanel()
|
RulerPanel::~RulerPanel()
|
||||||
|
@ -245,7 +245,41 @@ class AUDACITY_DLL_API RulerPanel final : public wxPanelWrapper {
|
|||||||
DECLARE_DYNAMIC_CLASS(RulerPanel)
|
DECLARE_DYNAMIC_CLASS(RulerPanel)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
using Range = std::pair<double, double>;
|
||||||
|
|
||||||
|
struct Options {
|
||||||
|
bool log { false };
|
||||||
|
bool flip { false };
|
||||||
|
bool labelEdges { false };
|
||||||
|
bool ticksAtExtremes { false };
|
||||||
|
bool hasTickColour{ false };
|
||||||
|
wxColour tickColour;
|
||||||
|
|
||||||
|
Options() {}
|
||||||
|
|
||||||
|
Options &Log( bool l )
|
||||||
|
{ log = l; return *this; }
|
||||||
|
|
||||||
|
Options &Flip( bool f )
|
||||||
|
{ flip = f; return *this; }
|
||||||
|
|
||||||
|
Options &LabelEdges( bool l )
|
||||||
|
{ labelEdges = l; return *this; }
|
||||||
|
|
||||||
|
Options &TicksAtExtremes( bool t )
|
||||||
|
{ ticksAtExtremes = t; return *this; }
|
||||||
|
|
||||||
|
Options &TickColour( const wxColour c )
|
||||||
|
{ tickColour = c; hasTickColour = true; return *this; }
|
||||||
|
};
|
||||||
|
|
||||||
RulerPanel(wxWindow* parent, wxWindowID id,
|
RulerPanel(wxWindow* parent, wxWindowID id,
|
||||||
|
wxOrientation orientation,
|
||||||
|
const wxSize &bounds,
|
||||||
|
const Range &range,
|
||||||
|
Ruler::RulerFormat format,
|
||||||
|
const wxString &units,
|
||||||
|
const Options &options = {},
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize);
|
const wxSize& size = wxDefaultSize);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user