#pragma once #include #include #include #include #include #include #include #include class _looperSlider : public QSlider { Q_OBJECT; protected: inline void mousePressEvent(QMouseEvent *e) override { QSlider::mousePressEvent(e); emit(mousePressed()); } inline void mouseReleaseEvent(QMouseEvent *e) override { QSlider::mouseReleaseEvent(e); emit(mouseReleased()); } public: inline _looperSlider(Qt::Orientation orientation, QWidget *parent = nullptr) : QSlider(orientation, parent) { } Q_SIGNALS: void mousePressed(); void mouseReleased(); }; class LooperSlider : public QWidget { Q_OBJECT; _looperSlider *slider; QPushButton *btn; QLineEdit *text; bool show_button_text; bool show_button_icon; QLabel *text_label; QLabel *min_label_view; QLabel *max_label_view; QBoxLayout *limits_view; QBoxLayout *root_layout; bool slider_value_updating = false; bool limits_visible = false; bool settings_changed = false; QBoxLayout *text_layout_view; bool pressed = false; LooperLogScaler *scaler; void UpdateLogScaler(); void UpdateSlider(bool update_value = false); bool textChanged = false; bool text_editor_visible = false; bool slider_visible = false; bool slider_value_changed_after_release = true; bool text_label_visible = false; bool limits_actually_visible = false; double value; double tick; double min; double max; bool text_edit_mode = false; bool logarithmic; const char *label = NULL; const char *min_label = NULL; const char *max_label = NULL; void set_min(double min); void set_max(double max); void set_tick(double value); void set_logarithmic(bool logarithmic); void set_value(double value); public: bool IsPressed(); void SetMin(double min); double Min(); void SetMax(double max); double Max(); void SetLimits(double min, double max); void SetMinLabel(const char *label); void SetMaxLabel(const char *label); const char *MinLabel(); const char *MaxLabel(); void SetLimitLabels(const char *min, const char *max); void SetValue(double value); double Value(); void SetLogarithmic(bool logarithmic); bool IsLogarithmic(); void SetLabel(const char *label); const char *Label(); double Tick(); bool ShowButtonText(); bool ShowButtonIcon(); void SetShowButtonText(bool enable); void SetShowButtonIcon(bool enable); void SetTick(double value); void EnableModeButton(bool enabled = true); inline void DisableModeButton() { EnableModeButton(false); } void SetMode(bool use_text_editor); inline void UseTextEditor() { SetMode(true); } inline void UseSlider() { SetMode(false); } inline bool UsingTextEditor() { return text_edit_mode; } inline bool UsingSlider() { return !UsingTextEditor(); } inline void SwitchModes() { SetMode(!text_edit_mode); } explicit LooperSlider(const char *name, const char *label, double min, double max, double tick = 0.0001, bool logarithmic = false); ~LooperSlider(); void changeEvent(QEvent *event) override; Q_SIGNALS: void changed(double value); void mousePressed(); void mouseReleased(); };