documented labelslider

This commit is contained in:
itsmattkc
2019-02-15 02:07:28 -08:00
parent 46c365c388
commit 671000836e
6 changed files with 2743 additions and 8 deletions
+1
View File
@@ -3,3 +3,4 @@ Makefile
.qmake.stash
effects/frei0r
ts/*.qm
docs
+2565
View File
File diff suppressed because it is too large Load Diff
+16
View File
@@ -237,6 +237,22 @@ public slots:
void open_preferences();
private:
/**
* @brief Internal function to handle loading a project from file
*
* Start loading a project. Doesn't check if the current project can be closed, doesn't check if the project exists.
* In most cases, you'll want open_project() to be end-user friendly.
*
* @param fn
*
* The URL to the project to load.
*
* @param autorecovery
*
* Whether this file is an autorecovery file. If it is, after the load Olive will set the project URL to a new file
* beside the original project file so that it does not overwrite the original and so that the user is not working
* on the autorecovery project in Olive's application data directory.
*/
void open_project_worker(const QString& fn, bool autorecovery);
/**
+2 -1
View File
@@ -483,7 +483,8 @@ void Viewer::set_marker() {
set_marker_internal(seq);
}
void Viewer::resizeEvent(QResizeEvent *) {
void Viewer::resizeEvent(QResizeEvent *e) {
QDockWidget::resizeEvent(e);
if (seq != nullptr) {
set_sb_max();
viewer_widget->update();
+5 -4
View File
@@ -34,7 +34,7 @@ void LabelSlider::set_frame_rate(double d) {
void LabelSlider::set_display_type(int type) {
display_type = type;
setText(valueToString(internal_value));
setText(valueToString());
}
void LabelSlider::set_value(double v, bool userSet) {
@@ -48,7 +48,7 @@ void LabelSlider::set_value(double v, bool userSet) {
internal_value = v;
}
setText(valueToString(internal_value));
setText(valueToString());
if (userSet) emit valueChanged();
}
}
@@ -61,7 +61,8 @@ bool LabelSlider::is_dragging() {
return drag_proc;
}
QString LabelSlider::valueToString(double v) {
QString LabelSlider::valueToString() {
double v = internal_value;
if (qIsNaN(v)) {
return "---";
} else {
@@ -248,7 +249,7 @@ void LabelSlider::mouseReleaseEvent(QMouseEvent*) {
tr("Set Value"),
tr("New value:"),
QLineEdit::Normal,
valueToString(internal_value)
valueToString()
);
if (s.isEmpty()) return;
+154 -3
View File
@@ -11,24 +11,157 @@ enum LabelSliderDisplayType {
LABELSLIDER_DECIBEL
};
/**
* @brief The LabelSlider class
*
* A UI element that shows a number and can be dragged to increase/decrease its value or clicked to enter a specific
* one.
*/
class LabelSlider : public QLabel
{
Q_OBJECT
public:
LabelSlider(QWidget* parent = 0);
LabelSlider(QWidget* parent = nullptr);
/**
* @brief Set the display frame rate
*
* If the `display_type` is set to LABELSLIDER_FRAMENUMBER, this function sets how many frames per second the
* timecode will be in.
*
* @param d
*/
void set_frame_rate(double d);
/**
* @brief Sets the way to display the value
*
* * `LABELSLIDER_NORMAL` - Shows the value as a normal number
* * `LABELSLIDER_FRAMENUMBER` - Shows the number as a timecode according to `config.timecode_view`. By default,
* will render hh:mm:ss:ff
* * `LABELSLIDER_PERCENT` - Shows the number as a percentage. 1.0 becomes "100%", 0.5 becomes 50%, etc.
* * `LABELSLIDER_DECIBLE` - Shows the number as a decibel. 1.0 becomes "0 dB", 2.0 becames roughly "6 dB", 0.5
* becomes roughly "-6 dB", etc.
*
* @param type
*
* The display type to set to. Should be a member of `enum LabelSliderDisplayType`.
*/
void set_display_type(int type);
/**
* @brief Set the value
* @param v
*
* Value to set to.
*
* @param userSet
*
* **TRUE** if this was called through a user action, **FALSE** if this was called through some other way. The
* only difference is **TRUE** will emit a signal (valueChanged()) indicating that the value has changed, and
* **FALSE** will not.
*/
void set_value(double v, bool userSet);
/**
* @brief Set the default value
*
* If a default value is set, alt+clicking the LabelSlider will return to the default value.
*
* @param v
*
* Value to set as default
*/
void set_default_value(double v);
/**
* @brief Set the minimum value
*
* If a minimum value is set, the value will never go below it. If the user manually sets a value lower than
* the minimum, it will automatically snap to the minimum.
*
* @param v
*
* Value to set as minimum
*/
void set_minimum_value(double v);
/**
* @brief Set the maximum value
*
* If a maximum value is set, the value will never go above it. If the user manually sets a value higher than
* the maximum, it will automatically snap to the maximum.
*
* @param v
*
* Value to set as maximum
*/
void set_maximum_value(double v);
/**
* @brief Returns the internal value as a double
* @return The internal value. This will not respect the `display_type`, i.e. 100% will return as 1.0, 12dB will
* return as 400%, and a timecode will return as a frame number.
*/
double value();
/**
* @brief Returns whether a value has been set or not
*
* If a value has been entered by any means (i.e. if set_value() was called), this will be **TRUE**. If set_value()
* has not been called and is_set() is **FALSE**, calling set_default_value() will automatically set the value
* to the default value WITHOUT changing the is_set() state (i.e. it will still be **FALSE** and calling
* set_default_value() again will change the current value again unless it's been changed through some other means
* in that time).
*
* @return **TRUE** if a value has been set, **FALSE** if not.
*/
bool is_set();
/**
* @brief Returns whether the user is currently dragging
* @return **TRUE** if the user is dragging, **FALSE** if not.
*/
bool is_dragging();
QString valueToString(double v);
/**
* @brief Convert the internal value to a displayed string according to `display_type`
* @return The internal value as a string
*/
QString valueToString();
/**
* @brief Returns whatever value was set before the last set_value()
*
* For various reasons (largely undo capabilities) it is helpful to retrieve whatever the value was before the
* current one. If the user dragged the current value, this will return the value just before the user started
* dragging.
*
* @return The previous value
*/
double getPreviousValue();
/**
* @brief Updates previous value
*
* Called internally to store the current value as the previous value in anticipation of an upcoming value change.
* Can also be called externally (mainly for dragged EffectGizmos) in anticipation of an external change.
*/
void set_previous_value();
void set_color(QString c = 0);
/**
* @brief Set the display color
* @param c
*
* Color to set to
*/
void set_color(QString c = nullptr);
/**
* @brief Set how many decimal places to show for a floating-point number
*
* Defaults to 1
*/
int decimal_places;
protected:
void mousePressEvent(QMouseEvent *ev);
@@ -56,10 +189,28 @@ private:
double frame_rate;
/**
* @brief Internal function to set the standard cursor (usually SizeHorCursor)
*/
void set_default_cursor();
/**
* @brief Internal function to set the cursor while dragging (usually NoCursor aka invisible)
*/
void set_active_cursor();
signals:
/**
* @brief valueChanged signal
*
* Emitted if the value changed at it was instigated by the user.
*/
void valueChanged();
/**
* @brief clicked signal
*
* Emitted if the user clicks on the LabelSlider in any way
*/
void clicked();
};