reimplemented double and bool widgets separately

This commit is contained in:
itsmattkc
2019-03-13 00:12:15 +11:00
parent 5b03af5e5a
commit e3e45279b9
36 changed files with 327 additions and 312 deletions
+6 -3
View File
@@ -42,7 +42,7 @@ EffectUI::EffectUI(Effect* e) :
}
}
connect(enabled_check, SIGNAL(clicked(bool)), this, SLOT(field_changed()));
connect(enabled_check, SIGNAL(clicked(bool)), e, SLOT(FieldChanged()));
}
Effect *EffectUI::GetEffect()
@@ -64,8 +64,11 @@ void EffectUI::show_context_menu(const QPoint& pos) {
int index = c->IndexOfEffect(effect_);
menu.addAction(tr("Cu&t"), this, SIGNAL(CutRequested()));
menu.addAction(tr("&Copy"), this, SIGNAL(CopyRequested()));
QAction* cut_action = menu.addAction(tr("Cu&t"));
connect(cut_action, SIGNAL(triggered(bool)), this, SIGNAL(CutRequested()));
QAction* copy_action = menu.addAction(tr("&Copy"));
connect(copy_action, SIGNAL(triggered(bool)), this, SIGNAL(CopyRequested()));
olive::MenuHelper.create_effect_paste_action(&menu);
+4 -2
View File
@@ -73,7 +73,9 @@ void LabelSlider::set_value(double v, bool userSet) {
}
setText(valueToString());
if (userSet) emit valueChanged();
if (userSet) {
emit valueChanged(internal_value);
}
}
}
@@ -247,7 +249,7 @@ void LabelSlider::mouseReleaseEvent(QMouseEvent*) {
previous_value = drag_start_value;
emit valueChanged();
emit valueChanged(internal_value);
} else {
+124 -124
View File
@@ -1,20 +1,20 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
@@ -37,13 +37,13 @@ public:
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
*/
* @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);
enum DisplayType {
@@ -54,134 +54,134 @@ public:
};
/**
* @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.
*/
* @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.
*/
void set_display_type(const DisplayType& 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.
*/
* @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
*/
* @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
*/
* @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
*/
* @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.
*/
* @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.
*/
* @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.
*/
* @brief Returns whether the user is currently dragging
* @return **TRUE** if the user is dragging, **FALSE** if not.
*/
bool is_dragging();
/**
* @brief Convert the internal value to a displayed string according to `display_type`
* @return The internal value as a string
*/
* @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
*/
* @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.
*/
* @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();
/**
* @brief Set the display color
* @param c
*
* Color to set to
*/
* @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
*/
* @brief Set how many decimal places to show for a floating-point number
*
* Defaults to 1
*/
int decimal_places;
protected:
void mousePressEvent(QMouseEvent *ev);
@@ -210,13 +210,13 @@ private:
double frame_rate;
/**
* @brief Internal function to set the standard cursor (usually SizeHorCursor)
*/
* @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)
*/
* @brief Internal function to set the cursor while dragging (usually NoCursor aka invisible)
*/
void set_active_cursor();
private slots:
/**
@@ -243,17 +243,17 @@ private slots:
void prompt_for_value();
signals:
/**
* @brief valueChanged signal
*
* Emitted if the value changed at it was instigated by the user.
*/
void valueChanged();
* @brief valueChanged signal
*
* Emitted if the value changed at it was instigated by the user.
*/
void valueChanged(double d);
/**
* @brief clicked signal
*
* Emitted if the user clicks on the LabelSlider in any way
*/
* @brief clicked signal
*
* Emitted if the user clicks on the LabelSlider in any way
*/
void clicked();
};
+11 -13
View File
@@ -259,8 +259,7 @@ void TimelineWidget::dragEnterEvent(QDragEnterEvent *event) {
}
if (event->source() == panel_footage_viewer->viewer_widget) {
Sequence* proposed_seq = panel_footage_viewer->seq.get();
if (proposed_seq != olive::ActiveSequence) { // don't allow nesting the same sequence
if (panel_footage_viewer->seq != olive::ActiveSequence) { // don't allow nesting the same sequence
media_list.append(panel_footage_viewer->media);
import_init = true;
}
@@ -302,7 +301,7 @@ void TimelineWidget::dragEnterEvent(QDragEnterEvent *event) {
event->acceptProposedAction();
long entry_point;
Sequence* seq = olive::ActiveSequence;
Sequence* seq = olive::ActiveSequence.get();
if (seq == nullptr) {
// if no sequence, we're going to create a new one using the clips as a reference
@@ -486,13 +485,13 @@ void insert_clips(ComboAction* ca) {
long ripple_length = (latest_new_point - earliest_new_point);
ripple_clips(ca, olive::ActiveSequence, earliest_new_point, ripple_length, ignore_clips);
ripple_clips(ca, olive::ActiveSequence.get(), earliest_new_point, ripple_length, ignore_clips);
if (ripple_old_point) {
// works for moving later clips earlier but not earlier to later
long second_ripple_length = (earliest_old_point - latest_old_point);
ripple_clips(ca, olive::ActiveSequence, latest_old_point, second_ripple_length, ignore_clips);
ripple_clips(ca, olive::ActiveSequence.get(), latest_old_point, second_ripple_length, ignore_clips);
if (earliest_old_point < earliest_new_point) {
for (int i=0;i<panel_timeline->ghosts.size();i++) {
@@ -515,7 +514,7 @@ void TimelineWidget::dropEvent(QDropEvent* event) {
ComboAction* ca = new ComboAction();
Sequence* s = olive::ActiveSequence;
Sequence* s = olive::ActiveSequence.get();
// if we're dropping into nothing, create a new sequences based on the clip being dragged
if (s == nullptr) {
@@ -998,7 +997,7 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) {
panel_sequence_viewer->cue_recording(qMin(g.in, g.out), qMax(g.in, g.out), g.track);
panel_timeline->creating = false;
} else if (g.in != g.out) {
ClipPtr c = std::make_shared<Clip>(olive::ActiveSequence);
ClipPtr c = std::make_shared<Clip>(olive::ActiveSequence.get());
c->set_media(nullptr, 0);
c->set_timeline_in(qMin(g.in, g.out));
c->set_timeline_out(qMax(g.in, g.out));
@@ -1020,7 +1019,7 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) {
QVector<ClipPtr> add;
add.append(c);
ca->append(new AddClipCommand(olive::ActiveSequence, add));
ca->append(new AddClipCommand(olive::ActiveSequence.get(), add));
if (c->track() < 0 && olive::CurrentConfig.add_default_effects_to_clips) {
// default video effects (before custom effects)
@@ -1141,7 +1140,7 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) {
if (panel_timeline->trim_type == TRIM_OUT) ripple_length = -ripple_length;
// finally, ripple everything
ripple_clips(ca, olive::ActiveSequence, ripple_point, ripple_length, ignore_clips);
ripple_clips(ca, olive::ActiveSequence.get(), ripple_point, ripple_length, ignore_clips);
}
if (panel_timeline->tool == TIMELINE_TOOL_POINTER
@@ -1157,7 +1156,7 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) {
if (g.old_in != g.in || g.old_out != g.out || g.track != g.old_track || g.clip_in != g.old_clip_in) {
// create copy of clip
ClipPtr c(olive::ActiveSequence->clips.at(g.clip)->copy(olive::ActiveSequence));
ClipPtr c = olive::ActiveSequence->clips.at(g.clip)->copy(olive::ActiveSequence.get());
c->set_timeline_in(g.in);
c->set_timeline_out(g.out);
@@ -1184,7 +1183,7 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) {
panel_timeline->relink_clips_using_ids(old_clips, new_clips);
// add them
ca->append(new AddClipCommand(olive::ActiveSequence, new_clips));
ca->append(new AddClipCommand(olive::ActiveSequence.get(), new_clips));
}
@@ -2342,7 +2341,7 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) {
}
// store selections
selection_command = new SetSelectionsCommand(olive::ActiveSequence);
selection_command = new SetSelectionsCommand(olive::ActiveSequence.get());
selection_command->old_data = olive::ActiveSequence->selections;
// ready to start moving clips
@@ -2953,7 +2952,6 @@ void TimelineWidget::paintEvent(QPaintEvent*) {
if (clip->media() != nullptr && clip->media()->get_type() == MEDIA_TYPE_FOOTAGE) {
bool draw_checkerboard = false;
QRect checkerboard_rect(clip_rect);
Footage* m = clip->media()->to_footage();
FootageStream* ms = clip->media_stream();
if (ms == nullptr) {
draw_checkerboard = true;
+1 -1
View File
@@ -311,7 +311,7 @@ void ViewerWidget::move_gizmos(QMouseEvent *event, bool done) {
drag_start_x = event->pos().x();
drag_start_y = event->pos().y();
gizmos->field_changed();
gizmos->FieldChanged();
}
}