move timecode display to common header

This commit is contained in:
itsmattkc
2019-07-25 13:11:18 -07:00
parent 90bb6734f7
commit 3bdbb4a26a
5 changed files with 40 additions and 6 deletions
+1
View File
@@ -22,6 +22,7 @@ set(OLIVE_SOURCES
)
add_subdirectory(common)
add_subdirectory(config)
add_subdirectory(decoder)
add_subdirectory(dialog)
add_subdirectory(node)
+21
View File
@@ -0,0 +1,21 @@
# 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 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/>.
set(OLIVE_SOURCES
${OLIVE_SOURCES}
config/config.h
PARENT_SCOPE
)
+12
View File
@@ -0,0 +1,12 @@
#ifndef CONFIG_H
#define CONFIG_H
#include "common/timecodefunctions.h"
/**
* @brief Temporary variables that will definitely be configurable but aren't yet
*/
const olive::TimecodeDisplay kTimecodeDisplay = olive::kTimecodeFrames;
#endif // CONFIG_H
@@ -24,6 +24,7 @@
#include <QPushButton>
#include "common/timecodefunctions.h"
#include "config/config.h"
#include "ui/icons/icons.h"
PlaybackControls::PlaybackControls(QWidget *parent) :
@@ -124,5 +125,5 @@ void PlaybackControls::SetTime(const int64_t &r)
{
Q_ASSERT(time_base_.denominator() != 0);
cur_tc_lbl_->setText(olive::timestamp_to_timecode(r, time_base_, olive::kMilliseconds));
cur_tc_lbl_->setText(olive::timestamp_to_timecode(r, time_base_, kTimecodeDisplay));
}
+4 -5
View File
@@ -7,12 +7,13 @@
#include "common/timecodefunctions.h"
#include "common/qtversionabstraction.h"
#include "config/config.h"
TimeRuler::TimeRuler(bool text_visible, QWidget* parent) :
QWidget(parent),
scroll_(0),
centered_text_(true),
scale_(16.0),
scale_(16.0), // FIXME: Temporary value
time_(0)
{
QFontMetrics fm = fontMetrics();
@@ -109,8 +110,6 @@ void TimeRuler::paintEvent(QPaintEvent *e)
int loop_start = - playhead_width_;
int loop_end = width() + playhead_width_;
olive::TimecodeDisplay display_type = olive::kTimecodeSeconds;
// Determine where it can draw text
int text_skip = 1;
int half_average_text_width = 0;
@@ -118,7 +117,7 @@ void TimeRuler::paintEvent(QPaintEvent *e)
if (text_visible_) {
QFontMetrics fm = p.fontMetrics();
double width_of_second = time_base_.flipped().ToDouble() * scale_;
int average_text_width = QFontMetricsWidth(&fm, olive::timestamp_to_timecode(0, time_base_, display_type));
int average_text_width = QFontMetricsWidth(&fm, olive::timestamp_to_timecode(0, time_base_, kTimecodeDisplay));
half_average_text_width = average_text_width/2;
while (width_of_second * text_skip < average_text_width) {
text_skip++;
@@ -171,7 +170,7 @@ void TimeRuler::paintEvent(QPaintEvent *e)
// Try to draw text here
if (text_visible_ && sec%text_skip == 0) {
QString timecode_string = olive::timestamp_to_timecode(sec, time_base_, display_type);
QString timecode_string = olive::timestamp_to_timecode(sec, time_base_, kTimecodeDisplay);
int text_x = i;