AdjustButton::AdjustButton (QWidget* parent, float change_rate) : QLineEdit (parent), rate (change_rate), min (-std::numeric_limits<float>::max()), max (std::numeric_limits<float>::max()), is_min (false), is_max (false), deadzone_y (-1), deadzone_value (NAN) { setValidator (new QDoubleValidator (this)); setToolTip (tr ("Click & drag to adjust")); setAlignment (Qt::AlignRight); connect (this, SIGNAL (editingFinished()), SLOT (onSetValue())); installEventFilter (this); setStyleSheet (( "QLineEdit { " "padding: 0.1em 20px 0.2em 0.3ex; " "background: qlineargradient(x1:0, y1:0, x2:0, y2:0.2, stop:0 gray, stop:1 white) url(:/adjustbutton.svg); " "background-position: right; " "background-repeat: no-repeat; " "font-size: " + str(font().pointSize()) + "pt; " "border: 1px solid grey; " "border-color: black lightgray white gray; " "border-radius: 0.3em }").c_str()); }
UI_base* W_slider::OnLButtonUp(int x, int y) { if (pInterceptChild == this) if(onSetValue) onSetValue(this, value, false); pInterceptChild = 0; return 0; }
void W_slider::SetValue(float v) { value = v; if (value > to) value = to; if (value < from) value = from; SetLabel(); if(onSetValue) onSetValue(this, value, true); }
void W_slider::SetTo(float t) { to = t; if (value>to) { value = to; if(onSetValue) onSetValue(this, value, 0); } barSize = min(barSize,to-value); }
void W_slider::SetFrom(float f) { from = f; if (value<from) { value = from; if(onSetValue) onSetValue(this, value, 0); } barSize = min(barSize,to-value); }