looper/backends/ui/gtk/my_slider.hpp

54 lines
No EOL
1.5 KiB
C++

#pragma once
#include <gtkmm.h>
#include <glibmm.h>
#include "theme.hpp"
class MySlider : public Gtk::Box {
double value;
double max_value;
double min_value;
struct {
double xmin;
double xmax;
double x0;
double x1;
double a;
double b;
} log_data;
bool logarithmic = false;
bool text_valid = true;
bool text_editing;
Gtk::Button edit_btn;
Gtk::Entry text_entry;
Gtk::Scale slider;
Gtk::Label prefix_label;
Gtk::Label value_label;
Gtk::Label suffix_label;
bool update_occurring = false;
void update(bool force = false);
void update_text_entry(std::string text);
void update_slider(double value);
Glib::ustring prefix;
Glib::ustring suffix;
unsigned digits_after_decimal;
void update_log_data();
double scale_log(double input);
double unscale_log(double input);
public:
double get_value();
void set_value(double value, bool force = false);
sigc::signal<void(double)> value_changed;
bool get_logarithmic();
void set_logarithmic(bool value = true);
double get_max_value();
void set_max_value(double value);
double get_min_value();
void set_min_value(double value);
Glib::ustring get_prefix();
void set_prefix(Glib::ustring value);
Glib::ustring get_suffix();
void set_suffix(Glib::ustring value);
unsigned get_digits_after_decimal();
void set_digits_after_decimal(unsigned value);
MySlider();
};