Skip to content

Commit

Permalink
add version label & fix osc waveform visuals
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-german committed May 4, 2024
1 parent 724010c commit 54c5bd7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
4 changes: 4 additions & 0 deletions Source/MainComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,10 @@ bool MainComponent::keyPressed(const KeyPress& key, Component* originatingCompon

void MainComponent::sliderAdjusted(BlocksSlider* slider, float value) {
delegate->editorAdjustedParameter(slider->module_id_, slider->parameter_name_, value);

if (slider->module_id_.type == "osc" && slider->parameter_name_ == "wave") {
changeModulePainter((int)value);
}
}

void MainComponent::sliderGestureChanged(BlocksSlider* slider, bool started) {
Expand Down
23 changes: 18 additions & 5 deletions Source/gui/UILayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include "model/ModelConstants.h"
#include "BinaryData.h"
#include "module_new.h"
#include "version_config.h"
#include "gui/ThemeManager.h"

UILayer::UILayer(juce::MidiKeyboardState& keyboard_state, BlocksSlider::Listener* listener):
ComponentMovementWatcher(this),
Expand Down Expand Up @@ -40,6 +42,21 @@ UILayer::UILayer(juce::MidiKeyboardState& keyboard_state, BlocksSlider::Listener
update_button_.text.setText("update", dontSendNotification);
addChildComponent(update_button_);
update_button_.on_click_ = [this]() { juce::URL("https://www.soonth.com").launchInDefaultBrowser(); };
addAndMakeVisible(version_label_);
version_label_.setText(BLOCKS_VERSION, dontSendNotification);
version_label_.setFont(juce::Font(13));
version_label_.setAlpha(0.25);
ThemeManager::shared()->addListener(this);
}

UILayer::~UILayer() {
removeAllChildren();
keyboard.setLookAndFeel(nullptr);
ThemeManager::shared()->removeListener(this);
}

void UILayer::themeChanged(Theme theme) {
version_label_.setColour(Label::textColourId, theme.two.brighter(0.4));
}

void UILayer::addSVGButton(SVGButton& button, const char* rawData, size_t size) {
Expand Down Expand Up @@ -69,11 +86,6 @@ void UILayer::setupKeyboard() {
addAndMakeVisible(keyboard);
}

UILayer::~UILayer() {
removeAllChildren();
keyboard.setLookAndFeel(nullptr);
}

void UILayer::resized() {
int keyboardHeight = 55;
keyboard.setBounds(0, getHeight() - keyboardHeight, getWidth(), keyboardHeight);
Expand All @@ -96,6 +108,7 @@ void UILayer::resized() {
int themeButtonSize = 24;
int y = keyboard.getY() - themeButtonSize - edgeMargin;
theme_button_.setBounds(edgeMargin, y, themeButtonSize, themeButtonSize);
version_label_.setBounds(theme_button_.getRight() + 5, y, 100, themeButtonSize);
}

void UILayer::resizeSaveAndNewButtons() {
Expand Down
10 changes: 5 additions & 5 deletions Source/gui/UILayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
#include <juce_gui_basics/juce_gui_basics.h>
#include "gui/controls/SVGButton.h"
#include "connection.h"
#include "ThemeListener.h"

class UILayer: public juce::Component, ComponentMovementWatcher {
class UILayer: public juce::Component, ComponentMovementWatcher, ThemeListener {
public:
SideMenu connections_;
ModulatorsSideMenu modulators_;
Expand All @@ -38,6 +39,7 @@ class UILayer: public juce::Component, ComponentMovementWatcher {

std::unique_ptr<ModulatorsButton> modulatorsButton;
LabelButton update_button_;
juce::Label version_label_;

ModulationsListBoxModel connections_list_box_model_;

Expand All @@ -51,6 +53,7 @@ class UILayer: public juce::Component, ComponentMovementWatcher {
void componentPeerChanged() override {};
void componentVisibilityChanged() override {};
private:
int edgeMargin = 16;
void addSVGButton(SVGButton& button, const char* rawData, size_t size);
void resizePresetButton();
void setupSideMenus();
Expand All @@ -61,9 +64,6 @@ class UILayer: public juce::Component, ComponentMovementWatcher {
void showModulatorsSideMenu();
void resizeSettingsButton();
void resizeSaveAndNewButtons();

private:
int edgeMargin = 16;

void themeChanged(Theme theme) override;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(UILayer)
};

0 comments on commit 54c5bd7

Please sign in to comment.