From 1d7fdc6860f2c54f4d49b255dd0d1b565596a971 Mon Sep 17 00:00:00 2001 From: Alex Birch Date: Sun, 30 Jun 2019 11:39:39 +0100 Subject: [PATCH] put sliders next to table --- Source/PluginEditor.cpp | 10 +++++++--- Source/SlidersComponent.cpp | 12 ++++++++++++ Source/SlidersComponent.h | 2 ++ Source/TableComponent.cpp | 14 +++++++++----- Source/TablesComponent.cpp | 4 ++-- 5 files changed, 32 insertions(+), 10 deletions(-) diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 0124918..e5cf407 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -83,15 +83,19 @@ void JuicySFAudioProcessorEditor::resized() const int pianoHeight{70}; const int filePickerHeight{25}; const int slidersHeight{150}; - Rectangle r (getLocalBounds()); + Rectangle r{getLocalBounds()}; filePicker.setBounds(r.removeFromTop(filePickerHeight + padding).reduced(padding, 0).withTrimmedTop(padding)); - slidersComponent.setBounds(r.removeFromTop(slidersHeight + padding).reduced(padding, 0).withTrimmedTop(padding)); // Rectangle r2 (getLocalBounds()); // slidersComponent.setBounds(r2.removeFromLeft(filePickerWidth + padding).reduced(padding, 0).withTrimmedLeft(padding)); midiKeyboard.setBounds (r.removeFromBottom (pianoHeight).reduced(padding, 0)); - tablesComponent.setBounds(r.reduced(0, padding)); + + Rectangle rContent{r.reduced(0, padding)}; + slidersComponent.setBounds(rContent.removeFromRight(slidersComponent.getDesiredWidth() + padding).withTrimmedRight(padding)); + + tablesComponent.setBounds(rContent); + processor.lastUIWidth = getWidth(); processor.lastUIHeight = getHeight(); diff --git a/Source/SlidersComponent.cpp b/Source/SlidersComponent.cpp index bc85123..0bffe74 100644 --- a/Source/SlidersComponent.cpp +++ b/Source/SlidersComponent.cpp @@ -18,6 +18,18 @@ SlidersComponent::~SlidersComponent() { } +const int SlidersComponent::getDesiredWidth() { + const int envelopeSliders{4}; + const int filterSliders{2}; + const int groupXMargin{8}; + const int groupXPadding{8}; + const int sliderXMargin{3}; + const int sliderWidth{30}; + + return envelopeSliders * sliderWidth + (envelopeSliders-1) * sliderXMargin + 2 * groupXPadding + + filterSliders * sliderWidth + (filterSliders-1) * sliderXMargin + 2 * groupXPadding + groupXMargin; +} + void SlidersComponent::resized() { const int envelopeSliders{4}; const int filterSliders{2}; diff --git a/Source/SlidersComponent.h b/Source/SlidersComponent.h index 0d06e36..48ceee2 100644 --- a/Source/SlidersComponent.h +++ b/Source/SlidersComponent.h @@ -12,6 +12,8 @@ public: void resized() override; + const int getDesiredWidth(); + private: std::function makeSliderListener(Slider& slider); diff --git a/Source/TableComponent.cpp b/Source/TableComponent.cpp index 978ecb2..e57a201 100644 --- a/Source/TableComponent.cpp +++ b/Source/TableComponent.cpp @@ -40,11 +40,12 @@ TableComponent::TableComponent( // Add some columns to the table header, based on the column list in our database.. for (auto &column : columns) // access by reference to avoid copying { + const int colWidth{ columnIx == 1 ? 30 : 100 }; table.getHeader().addColumn ( String(column), columnIx++, - 100, // column width - 50, // min width + colWidth, // column width + 30, // min width 400, // max width TableHeaderComponent::defaultFlags ); @@ -147,9 +148,12 @@ void TableComponent::sortOrderChanged ( // This is overloaded from TableListBoxModel, and should choose the best width for the specified // column. int TableComponent::getColumnAutoSizeWidth (int columnId) { - if (columnId == 5) - return 100; // (this is the ratings column, containing a custom combobox component) +// if (columnId == 5) +// return 100; // (this is the ratings column, containing a custom combobox component) + if (columnId == 1) + return 30; // (this is the ratings column, containing a custom combobox component) + int widest = 32; // find the widest bit of text in this column.. @@ -202,4 +206,4 @@ void TableComponent::selectedRowsChanged (int row) { bool TableComponent::keyPressed(const KeyPress &key) { return table.keyPressed(key); -} \ No newline at end of file +} diff --git a/Source/TablesComponent.cpp b/Source/TablesComponent.cpp index 6df4632..67f40de 100644 --- a/Source/TablesComponent.cpp +++ b/Source/TablesComponent.cpp @@ -30,7 +30,7 @@ TablesComponent::TablesComponent( }; presetTable = new TableComponent( - {"Preset", "Name"}, + {"#", "Name"}, mapPresets( banksToPresets, selectedBank @@ -184,4 +184,4 @@ void TablesComponent::fontChanged(FluidSynthModel *, const String &) { mapBanks(banksToPresets), selectedBank ); -} \ No newline at end of file +}