style: unify identifier naming per updated conventions

Automated with clang-tidy readability-identifier-naming (config added to
.clang-tidy) plus scripted passes, per the updated rules now documented
in CONTRIBUTING.md:

- types (class/struct/enum/alias/template params): PascalCase
- functions, variables, members: snake_case (incl. rational -> Rational)
- private/protected members: trailing underscore; static member
  variables likewise (instance_, available_themes_)
- constants and enum values: snake_case (kLinear -> k_linear,
  F32P -> f32p); ALL_CAPS reserved for macros
- macros: OAK_ prefix (OLIVE_ADD_TEST/OLIVE_ASSERT/OLIVE_CONFIG ->
  OAK_ADD_TEST/OAK_ASSERT/OAK_CONFIG, GL_PREAMBLE -> OAK_GL_PREAMBLE,
  include guards -> OAK_*)
- file names: all lowercase (Current/Plugin/OliveHost/OliveClip/
  OlivePluginInstance -> current/plugin/olivehost/oliveclip/
  oliveplugininstance)
- getters share the member name sans underscore, setters set_foo()
- Qt and third-party (OpenFX) virtual overrides and framework callbacks
  keep their original names (exempt in .clang-tidy)

Manual follow-ups required where automation could not reach:
- string-based QMetaObject/SIGNAL/SLOT references updated to renamed
  methods (AddTask, CreatedFile, DeleteSpecificFile, moveSelectionUp, ...)
- macro bodies referencing renamed methods (OLIVE_CONFIG,
  NODE_DEFAULT_DESTRUCTOR, MANAGEDDISPLAYWIDGET_*)
- self-shadowing locals renamed where signals/methods became same-named
  (size_changed, worker_count, selected_items, import param, filters)
- third_party OFX member/namespace usages restored (OFX::Host::*,
  _created, _clipPrefsDirty, createInstance, clearPersistentMessage)
- STL protocol aliases restored (const_iterator) with .clang-tidy
  ignore rules; qHash overloads restored

Full build and test suite pass: ctest 4/4, ~1960 gtest cases green.
This commit is contained in:
2026-07-19 16:10:54 +08:00
parent cb1718a103
commit bb40b4923e
1014 changed files with 44257 additions and 44220 deletions
+15 -15
View File
@@ -48,33 +48,33 @@ AudioWaveformView::AudioWaveformView(QWidget *parent)
setAlignment(Qt::AlignLeft | Qt::AlignTop);
}
void AudioWaveformView::SetViewer(ViewerOutput *playback)
void AudioWaveformView::set_viewer(ViewerOutput *playback)
{
if (playback_) {
pool_.clear();
pool_.waitForDone();
disconnect(playback_, &ViewerOutput::ConnectedWaveformChanged,
disconnect(playback_, &ViewerOutput::connected_waveform_changed,
viewport(),
static_cast<void (QWidget::*)()>(&QWidget::update));
SetTimebase(0);
set_timebase(0);
}
playback_ = playback;
if (playback_) {
connect(playback_, &ViewerOutput::ConnectedWaveformChanged, viewport(),
connect(playback_, &ViewerOutput::connected_waveform_changed, viewport(),
static_cast<void (QWidget::*)()>(&QWidget::update));
rational tb = playback_->GetVideoParams().frame_rate_as_time_base();
Rational tb = playback_->get_video_params().frame_rate_as_time_base();
if (tb.isNull()) {
tb = OLIVE_CONFIG("DefaultSequenceFrameRate")
.value<rational>()
tb = OAK_CONFIG("DefaultSequenceFrameRate")
.value<Rational>()
.flipped();
}
SetTimebase(tb);
UpdateSceneRect();
set_timebase(tb);
update_scene_rect();
}
}
@@ -86,28 +86,28 @@ void AudioWaveformView::drawForeground(QPainter *p, const QRectF &rect)
return;
}
const AudioWaveformCache *wave = playback_->GetConnectedWaveform();
const AudioWaveformCache *wave = playback_->get_connected_waveform();
if (!wave) {
return;
}
const AudioParams &params = wave->GetParameters();
const AudioParams &params = wave->get_parameters();
if (!params.is_valid()) {
return;
}
// Draw in/out points
DrawWorkArea(p);
DrawMarkers(p);
draw_work_area(p);
draw_markers(p);
// Draw waveform
p->setPen(QColor(64, 255, 160)); // FIXME: Hardcoded color
wave->Draw(p, rect.toRect(), GetScale(), SceneToTime(GetScroll()));
wave->Draw(p, rect.toRect(), get_scale(), scene_to_time(get_scroll()));
// Draw playhead
p->setPen(PLAYHEAD_COLOR);
int playhead_x = TimeToScene(GetViewerNode()->GetPlayhead());
int playhead_x = time_to_scene(get_viewer_node()->get_playhead());
p->drawLine(playhead_x, 0, playhead_x, height());
}
+4 -4
View File
@@ -19,8 +19,8 @@
***/
#ifndef AUDIOWAVEFORMVIEW_H
#define AUDIOWAVEFORMVIEW_H
#ifndef OAK_AUDIOWAVEFORMVIEW_H
#define OAK_AUDIOWAVEFORMVIEW_H
#include <QtConcurrent/QtConcurrent>
#include <QWidget>
@@ -36,7 +36,7 @@ class AudioWaveformView : public SeekableWidget {
public:
AudioWaveformView(QWidget *parent = nullptr);
void SetViewer(ViewerOutput *playback);
void set_viewer(ViewerOutput *playback);
protected:
virtual void drawForeground(QPainter *painter, const QRectF &rect) override;
@@ -49,4 +49,4 @@ private:
}
#endif // AUDIOWAVEFORMVIEW_H
#endif // OAK_AUDIOWAVEFORMVIEW_H
+34 -34
View File
@@ -35,41 +35,41 @@ namespace olive
FootageViewerWidget::FootageViewerWidget(QWidget *parent)
: super(parent)
{
connect(display_widget(), &ViewerDisplayWidget::DragStarted, this,
&FootageViewerWidget::StartFootageDrag);
connect(display_widget(), &ViewerDisplayWidget::drag_started, this,
&FootageViewerWidget::start_footage_drag);
controls_->SetAudioVideoDragButtonsVisible(true);
connect(controls_, &PlaybackControls::VideoClicked, this,
&FootageViewerWidget::VideoButtonClicked);
connect(controls_, &PlaybackControls::AudioClicked, this,
&FootageViewerWidget::AudioButtonClicked);
connect(controls_, &PlaybackControls::VideoDragged, this,
&FootageViewerWidget::StartVideoDrag);
connect(controls_, &PlaybackControls::AudioDragged, this,
&FootageViewerWidget::StartAudioDrag);
controls_->set_audio_video_drag_buttons_visible(true);
connect(controls_, &PlaybackControls::video_clicked, this,
&FootageViewerWidget::video_button_clicked);
connect(controls_, &PlaybackControls::audio_clicked, this,
&FootageViewerWidget::audio_button_clicked);
connect(controls_, &PlaybackControls::video_dragged, this,
&FootageViewerWidget::start_video_drag);
connect(controls_, &PlaybackControls::audio_dragged, this,
&FootageViewerWidget::start_audio_drag);
override_workarea_ = new TimelineWorkArea(this);
}
void FootageViewerWidget::OverrideWorkArea(const TimeRange &r)
void FootageViewerWidget::override_work_area(const TimeRange &r)
{
override_workarea_->set_enabled(true);
override_workarea_->set_range(r);
this->ConnectWorkArea(override_workarea_);
this->connect_work_area(override_workarea_);
}
void FootageViewerWidget::ResetWorkArea()
void FootageViewerWidget::reset_work_area()
{
if (GetConnectedWorkArea() == override_workarea_) {
this->ConnectWorkArea(
GetConnectedNode() ? GetConnectedNode()->GetWorkArea() : nullptr);
if (get_connected_work_area() == override_workarea_) {
this->connect_work_area(
get_connected_node() ? get_connected_node()->get_work_area() : nullptr);
}
}
void FootageViewerWidget::StartFootageDragInternal(bool enable_video,
void FootageViewerWidget::start_footage_drag_internal(bool enable_video,
bool enable_audio)
{
if (!GetConnectedNode()) {
if (!get_connected_node()) {
return;
}
@@ -80,15 +80,15 @@ void FootageViewerWidget::StartFootageDragInternal(bool enable_video,
QDataStream data_stream(&encoded_data, QIODevice::WriteOnly);
QVector<Track::Reference> streams =
GetConnectedNode()->GetEnabledStreamsAsReferences();
get_connected_node()->get_enabled_streams_as_references();
// Disable streams that have been disabled
if (!enable_video || !enable_audio) {
for (int i = 0; i < streams.size(); i++) {
const Track::Reference &ref = streams.at(i);
if ((ref.type() == Track::kVideo && !enable_video) ||
(ref.type() == Track::kAudio && !enable_audio)) {
if ((ref.type() == Track::k_video && !enable_video) ||
(ref.type() == Track::k_audio && !enable_audio)) {
streams.removeAt(i);
i--;
}
@@ -97,38 +97,38 @@ void FootageViewerWidget::StartFootageDragInternal(bool enable_video,
if (!streams.isEmpty()) {
data_stream << streams
<< reinterpret_cast<quintptr>(GetConnectedNode());
<< reinterpret_cast<quintptr>(get_connected_node());
mimedata->setData(Project::kItemMimeType, encoded_data);
mimedata->setData(Project::k_item_mime_type, encoded_data);
drag->setMimeData(mimedata);
drag->exec();
}
}
void FootageViewerWidget::StartFootageDrag()
void FootageViewerWidget::start_footage_drag()
{
StartFootageDragInternal(true, true);
start_footage_drag_internal(true, true);
}
void FootageViewerWidget::StartVideoDrag()
void FootageViewerWidget::start_video_drag()
{
StartFootageDragInternal(true, false);
start_footage_drag_internal(true, false);
}
void FootageViewerWidget::StartAudioDrag()
void FootageViewerWidget::start_audio_drag()
{
StartFootageDragInternal(false, true);
start_footage_drag_internal(false, true);
}
void FootageViewerWidget::VideoButtonClicked()
void FootageViewerWidget::video_button_clicked()
{
this->SetWaveformMode(kWFAutomatic);
this->set_waveform_mode(k_wf_automatic);
}
void FootageViewerWidget::AudioButtonClicked()
void FootageViewerWidget::audio_button_clicked()
{
this->SetWaveformMode(kWFWaveformOnly);
this->set_waveform_mode(k_wf_waveform_only);
}
}
+11 -11
View File
@@ -19,8 +19,8 @@
***/
#ifndef FOOTAGEVIEWERWIDGET_H
#define FOOTAGEVIEWERWIDGET_H
#ifndef OAK_FOOTAGEVIEWERWIDGET_H
#define OAK_FOOTAGEVIEWERWIDGET_H
#include "node/output/viewer/viewer.h"
#include "viewer.h"
@@ -33,26 +33,26 @@ class FootageViewerWidget : public ViewerWidget {
public:
FootageViewerWidget(QWidget *parent = nullptr);
void OverrideWorkArea(const TimeRange &r);
void ResetWorkArea();
void override_work_area(const TimeRange &r);
void reset_work_area();
private:
void StartFootageDragInternal(bool enable_video, bool enable_audio);
void start_footage_drag_internal(bool enable_video, bool enable_audio);
TimelineWorkArea *override_workarea_;
private slots:
void StartFootageDrag();
void start_footage_drag();
void StartVideoDrag();
void start_video_drag();
void StartAudioDrag();
void start_audio_drag();
void VideoButtonClicked();
void video_button_clicked();
void AudioButtonClicked();
void audio_button_clicked();
};
}
#endif // FOOTAGEVIEWERWIDGET_H
#endif // OAK_FOOTAGEVIEWERWIDGET_H
File diff suppressed because it is too large Load Diff
+118 -118
View File
@@ -19,8 +19,8 @@
***/
#ifndef VIEWER_WIDGET_H
#define VIEWER_WIDGET_H
#ifndef OAK_VIEWER_WIDGET_H
#define OAK_VIEWER_WIDGET_H
#include <QFile>
#include <QLabel>
@@ -53,10 +53,10 @@ class ViewerWidget : public TimeBasedWidget {
Q_OBJECT
public:
enum WaveformMode {
kWFAutomatic,
kWFViewerOnly,
kWFWaveformOnly,
kWFViewerAndWaveform
k_wf_automatic,
k_wf_viewer_only,
k_wf_waveform_only,
k_wf_viewer_and_waveform
};
ViewerWidget(QWidget *parent = nullptr)
@@ -66,13 +66,13 @@ public:
virtual ~ViewerWidget() override;
void SetPlaybackControlsEnabled(bool enabled);
void set_playback_controls_enabled(bool enabled);
void SetTimeRulerEnabled(bool enabled);
void set_time_ruler_enabled(bool enabled);
void TogglePlayPause();
void toggle_play_pause();
bool IsPlaying() const;
bool is_playing() const;
/**
* @brief Enable or disable the color management menu
@@ -80,122 +80,122 @@ public:
* While the Viewer is _always_ color managed, In some contexts, the color management may be controlled from an
* external UI making the menu unnecessary.
*/
void SetColorMenuEnabled(bool enabled);
void set_color_menu_enabled(bool enabled);
void SetMatrix(const QMatrix4x4 &mat);
void set_matrix(const QMatrix4x4 &mat);
/**
* @brief Creates a ViewerWindow widget and places it full screen on another screen
*
* If `screen` is nullptr, the screen will be automatically selected as whichever one contains the mouse cursor.
*/
void SetFullScreen(QScreen *screen = nullptr);
void set_full_screen(QScreen *screen = nullptr);
ColorManager *color_manager() const
{
return display_widget_->color_manager();
}
void SetGizmos(Node *node);
void set_gizmos(Node *node);
void StartCapture(TimelineWidget *source, const TimeRange &time,
void start_capture(TimelineWidget *source, const TimeRange &time,
const Track::Reference &track);
void SetAudioScrubbingEnabled(bool e)
void set_audio_scrubbing_enabled(bool e)
{
enable_audio_scrubbing_ = e;
}
void AddPlaybackDevice(ViewerDisplayWidget *vw)
void add_playback_device(ViewerDisplayWidget *vw)
{
playback_devices_.push_back(vw);
}
void SetTimelineSelectedBlocks(const QVector<Block *> &b)
void set_timeline_selected_blocks(const QVector<Block *> &b)
{
timeline_selected_blocks_ = b;
if (!IsPlaying()) {
if (!is_playing()) {
// If is playing, this will happen by the next frame automatically
DetectMulticamNodeNow();
UpdateTextureFromNode();
detect_multicam_node_now();
update_texture_from_node();
}
}
void SetNodeViewSelections(const QVector<Node *> &n)
void set_node_view_selections(const QVector<Node *> &n)
{
node_view_selected_ = n;
if (!IsPlaying()) {
if (!is_playing()) {
// If is playing, this will happen by the next frame automatically
DetectMulticamNodeNow();
UpdateTextureFromNode();
detect_multicam_node_now();
update_texture_from_node();
}
}
void ConnectMulticamWidget(MulticamWidget *p);
void connect_multicam_widget(MulticamWidget *p);
public slots:
void Play(bool in_to_out_only);
void play(bool in_to_out_only);
void Play();
void play();
void Pause();
void pause();
void ShuttleLeft();
void shuttle_left();
void ShuttleStop();
void shuttle_stop();
void ShuttleRight();
void shuttle_right();
void SetColorTransform(const ColorTransform &transform);
void set_color_transform(const ColorTransform &transform);
/**
* @brief Wrapper for ViewerGLWidget::SetSignalCursorColorEnabled()
*/
void SetSignalCursorColorEnabled(bool e);
void set_signal_cursor_color_enabled(bool e);
void CacheEntireSequence();
void cache_entire_sequence();
void CacheSequenceInOut();
void cache_sequence_in_out();
void SetViewerResolution(int width, int height);
void set_viewer_resolution(int width, int height);
void SetViewerPixelAspect(const rational &ratio);
void set_viewer_pixel_aspect(const Rational &ratio);
void UpdateTextureFromNode();
void update_texture_from_node();
void RequestStartEditingText()
void request_start_editing_text()
{
display_widget_->RequestStartEditingText();
display_widget_->request_start_editing_text();
}
signals:
/**
* @brief Wrapper for ViewerGLWidget::CursorColor()
*/
void CursorColor(const Color &reference, const Color &display);
void cursor_color(const Color &reference, const Color &display);
/**
* @brief Signal emitted when a new frame is loaded
*/
void TextureChanged(TexturePtr t);
void texture_changed(TexturePtr t);
/**
* @brief Wrapper for ViewerGLWidget::ColorProcessorChanged()
*/
void ColorProcessorChanged(ColorProcessorPtr processor);
void color_processor_changed(ColorProcessorPtr processor);
/**
* @brief Wrapper for ViewerGLWidget::ColorManagerChanged()
*/
void ColorManagerChanged(ColorManager *color_manager);
void color_manager_changed(ColorManager *color_manager);
protected:
ViewerWidget(ViewerDisplayWidget *display, QWidget *parent = nullptr);
virtual void TimebaseChangedEvent(const rational &) override;
virtual void TimeChangedEvent(const rational &time) override;
virtual void TimebaseChangedEvent(const Rational &) override;
virtual void TimeChangedEvent(const Rational &time) override;
virtual void ConnectNodeEvent(ViewerOutput *) override;
virtual void DisconnectNodeEvent(ViewerOutput *) override;
@@ -219,77 +219,77 @@ protected:
ignore_scrub_++;
}
RenderTicketPtr GetSingleFrame(const rational &t, bool dry = false);
RenderTicketPtr get_single_frame(const Rational &t, bool dry = false);
void SetWaveformMode(WaveformMode wf);
void set_waveform_mode(WaveformMode wf);
private:
int64_t GetTimestamp() const
int64_t get_timestamp() const
{
return Timecode::time_to_timestamp(GetConnectedNode()->GetPlayhead(),
timebase(), Timecode::kFloor);
return Timecode::time_to_timestamp(get_connected_node()->get_playhead(),
timebase(), Timecode::k_floor);
}
void UpdateTimeInternal(int64_t i);
void update_time_internal(int64_t i);
void PlayInternal(int speed, bool in_to_out_only);
void play_internal(int speed, bool in_to_out_only);
void PauseInternal();
void pause_internal();
void PushScrubbedAudio();
void push_scrubbed_audio();
void UpdateMinimumScale();
void update_minimum_scale();
void SetColorTransform(const ColorTransform &transform,
void set_color_transform(const ColorTransform &transform,
ViewerDisplayWidget *sender);
QString GetCachedFilenameFromTime(const rational &time);
QString get_cached_filename_from_time(const Rational &time);
bool FrameExistsAtTime(const rational &time);
bool frame_exists_at_time(const Rational &time);
bool ViewerMightBeAStill();
bool viewer_might_be_a_still();
void SetDisplayImage(RenderTicketPtr ticket);
void set_display_image(RenderTicketPtr ticket);
RenderTicketWatcher *RequestNextFrameForQueue(bool increment = true);
RenderTicketWatcher *request_next_frame_for_queue(bool increment = true);
RenderTicketPtr GetFrame(const rational &t);
RenderTicketPtr get_frame(const Rational &t);
void FinishPlayPreprocess();
void finish_play_preprocess();
int DeterminePlaybackQueueSize();
int determine_playback_queue_size();
static FramePtr DecodeCachedImage(const QString &cache_path,
static FramePtr decode_cached_image(const QString &cache_path,
const QUuid &cache_id,
const int64_t &time);
static void DecodeCachedImage(RenderTicketPtr ticket,
static void decode_cached_image(RenderTicketPtr ticket,
const QString &cache_path,
const QUuid &cache_id, const int64_t &time);
bool ShouldForceWaveform() const;
bool should_force_waveform() const;
void SetEmptyImage();
void set_empty_image();
void UpdateAutoCacher();
void update_auto_cacher();
void DecrementPrequeuedAudio();
void decrement_prequeued_audio();
void ArmForRecording();
void arm_for_recording();
void DisarmRecording();
void disarm_recording();
void CloseAudioProcessor();
void close_audio_processor();
void DetectMulticamNode(const rational &time);
void detect_multicam_node(const Rational &time);
bool IsVideoVisible() const;
bool is_video_visible() const;
ViewerSizer *sizer_;
int playback_speed_;
rational last_time_;
Rational last_time_;
bool color_menu_enabled_;
@@ -316,7 +316,7 @@ private:
QList<RenderTicketWatcher *> nonqueue_watchers_;
rational last_length_;
Rational last_length_;
int prequeue_length_;
int prequeue_count_;
@@ -324,12 +324,12 @@ private:
QVector<RenderTicketWatcher *> queue_watchers_;
std::list<RenderTicketWatcher *> audio_playback_queue_;
rational audio_playback_queue_time_;
Rational audio_playback_queue_time_;
AudioProcessor audio_processor_;
QByteArray prequeued_audio_;
static const rational kAudioPlaybackInterval;
static const Rational k_audio_playback_interval;
static QVector<ViewerWidget *> instances_;
static QVector<ViewerWidget *> instances;
std::list<RenderTicketWatcher *> audio_scrub_watchers_;
@@ -357,75 +357,75 @@ private:
MulticamWidget *multicam_panel_;
private slots:
void PlaybackTimerUpdate();
void playback_timer_update();
void LengthChangedSlot(const rational &length);
void length_changed_slot(const Rational &length);
void InterlacingChangedSlot(VideoParams::Interlacing interlacing);
void interlacing_changed_slot(VideoParams::Interlacing interlacing);
void UpdateRendererVideoParameters();
void update_renderer_video_parameters();
void UpdateRendererAudioParameters();
void update_renderer_audio_parameters();
void ShowContextMenu(const QPoint &pos);
void show_context_menu(const QPoint &pos);
void SetZoomFromMenu(QAction *action);
void set_zoom_from_menu(QAction *action);
void UpdateWaveformViewFromMode();
void update_waveform_view_from_mode();
void ContextMenuSetFullScreen(QAction *action);
void context_menu_set_full_screen(QAction *action);
void ContextMenuSetPlaybackRes(QAction *action);
void context_menu_set_playback_res(QAction *action);
void ContextMenuDisableSafeMargins();
void context_menu_disable_safe_margins();
void ContextMenuSetSafeMargins();
void context_menu_set_safe_margins();
void ContextMenuSetCustomSafeMargins();
void context_menu_set_custom_safe_margins();
void WindowAboutToClose();
void window_about_to_close();
void RendererGeneratedFrame();
void renderer_generated_frame();
void RendererGeneratedFrameForQueue();
void renderer_generated_frame_for_queue();
void ViewerInvalidatedVideoRange(const olive::TimeRange &range);
void viewer_invalidated_video_range(const olive::TimeRange &range);
void UpdateWaveformModeFromMenu(QAction *a);
void update_waveform_mode_from_menu(QAction *a);
void DragEntered(QDragEnterEvent *event);
void drag_entered(QDragEnterEvent *event);
void Dropped(QDropEvent *event);
void dropped(QDropEvent *event);
void QueueNextAudioBuffer();
void queue_next_audio_buffer();
void ReceivedAudioBufferForPlayback();
void received_audio_buffer_for_playback();
void ReceivedAudioBufferForScrubbing();
void received_audio_buffer_for_scrubbing();
void QueueStarved();
void QueueNoLongerStarved();
void queue_starved();
void queue_no_longer_starved();
void ForceRequeueFromCurrentTime();
void ForceRequeueFromCurrentTimeInternal();
void force_requeue_from_current_time();
void force_requeue_from_current_time_internal();
void UpdateAudioProcessor();
void update_audio_processor();
void CreateAddableAt(const QRectF &f);
void create_addable_at(const QRectF &f);
void HandleFirstRequeueDestroy();
void handle_first_requeue_destroy();
void ShowSubtitleProperties();
void show_subtitle_properties();
void DryRunFinished();
void dry_run_finished();
void RequestNextDryRun();
void request_next_dry_run();
void SaveFrameAsImage();
void save_frame_as_image();
void DetectMulticamNodeNow();
void detect_multicam_node_now();
};
}
#endif // VIEWER_WIDGET_H
#endif // OAK_VIEWER_WIDGET_H
File diff suppressed because it is too large Load Diff
+101 -101
View File
@@ -19,8 +19,8 @@
***/
#ifndef VIEWERGLWIDGET_H
#define VIEWERGLWIDGET_H
#ifndef OAK_VIEWERGLWIDGET_H
#define OAK_VIEWERGLWIDGET_H
#include <QImage>
#include <QMatrix4x4>
@@ -73,27 +73,27 @@ public:
virtual ~ViewerDisplayWidget() override;
const ViewerSafeMarginInfo &GetSafeMargin() const;
void SetSafeMargins(const ViewerSafeMarginInfo &safe_margin);
const ViewerSafeMarginInfo &get_safe_margin() const;
void set_safe_margins(const ViewerSafeMarginInfo &safe_margin);
void SetGizmos(Node *node);
void set_gizmos(Node *node);
const VideoParams &GetVideoParams() const
const VideoParams &get_video_params() const
{
return gizmo_params_;
}
void SetVideoParams(const VideoParams &params);
void set_video_params(const VideoParams &params);
const AudioParams &GetAudioParams() const
const AudioParams &get_audio_params() const
{
return gizmo_audio_params_;
}
void SetAudioParams(const AudioParams &p);
void set_audio_params(const AudioParams &p);
void SetTime(const rational &time);
void SetSubtitleTracks(Sequence *list);
void set_time(const Rational &time);
void set_subtitle_tracks(Sequence *list);
void SetShowWidgetBackground(bool e)
void set_show_widget_background(bool e)
{
show_widget_background_ = e;
update();
@@ -103,51 +103,51 @@ public:
* @brief Transform a point from viewer space to the buffer space.
* Multiplies by the inverted transform matrix to undo the scaling and translation.
*/
QPointF TransformViewerSpaceToBufferSpace(const QPointF &pos);
QPointF transform_viewer_space_to_buffer_space(const QPointF &pos);
bool IsDeinterlacing() const
bool is_deinterlacing() const
{
return deinterlace_;
}
void ResetFPSTimer();
void reset_fps_timer();
bool GetShowFPS() const
bool get_show_fps() const
{
return show_fps_;
}
bool GetShowSubtitles() const
bool get_show_subtitles() const
{
return show_subtitles_;
}
void SetShowSubtitles(bool e)
void set_show_subtitles(bool e)
{
show_subtitles_ = e;
update();
}
void IncrementSkippedFrames();
void increment_skipped_frames();
void IncrementFrameCount()
void increment_frame_count()
{
fps_timer_update_count_++;
}
TexturePtr GetCurrentTexture() const
TexturePtr get_current_texture() const
{
return texture_;
}
ColorProcessorPtr GetCurrentColorProcessor()
ColorProcessorPtr get_current_color_processor()
{
return color_service();
}
void Play(const int64_t &start_timestamp, const int &playback_speed,
const rational &timebase, bool start_updating);
void play(const int64_t &start_timestamp, const int &playback_speed,
const Rational &timebase, bool start_updating);
void Pause();
void pause();
ViewerQueue *queue()
{
@@ -159,7 +159,7 @@ public:
return &timer_;
}
QPointF ScreenToScenePoint(const QPoint &p);
QPointF screen_to_scene_point(const QPoint &p);
virtual bool eventFilter(QObject *o, QEvent *e) override;
@@ -169,14 +169,14 @@ public slots:
*
* Set this if you want the drawing to pass through some sort of transform (most of the time you won't want this).
*/
void SetMatrixTranslate(const QMatrix4x4 &mat);
void set_matrix_translate(const QMatrix4x4 &mat);
/**
* @brief Set the scale matrix.
*/
void SetMatrixZoom(const QMatrix4x4 &mat);
void set_matrix_zoom(const QMatrix4x4 &mat);
void SetMatrixCrop(const QMatrix4x4 &mat);
void set_matrix_crop(const QMatrix4x4 &mat);
/**
* @brief Enables or disables whether this color at the cursor should be emitted
@@ -185,91 +185,91 @@ public slots:
* have an option for it. Ideally, this should be connected to a PixelSamplerPanel::visibilityChanged signal so that
* it can automatically be enabled when the user is pixel sampling and disabled for optimization when they're not.
*/
void SetSignalCursorColorEnabled(bool e);
void set_signal_cursor_color_enabled(bool e);
void SetImage(const QVariant &buffer);
void set_image(const QVariant &buffer);
void SetBlank();
void set_blank();
/**
* @brief Changes the pointer type if the tool is changed to the hand tool. Otherwise resets the pointer to it's
* normal type.
*/
void UpdateCursor();
void update_cursor();
void ToolChanged();
void tool_changed();
/**
* @brief Enables/disables a basic deinterlace on the viewer
*/
void SetDeinterlacing(bool e);
void set_deinterlacing(bool e);
void SetShowFPS(bool e);
void set_show_fps(bool e);
void RequestStartEditingText();
void request_start_editing_text();
signals:
/**
* @brief Signal emitted when the user starts dragging from the viewer
*/
void DragStarted(const QPoint &p);
void drag_started(const QPoint &p);
/**
* @brief Signal emitted when a hand drag starts
*/
void HandDragStarted();
void hand_drag_started();
/**
* @brief Signal emitted when a hand drag moves
*/
void HandDragMoved(int x, int y);
void hand_drag_moved(int x, int y);
/**
* @brief Signal emitted when a hand drag ends
*/
void HandDragEnded();
void hand_drag_ended();
/**
* @brief Signal emitted when cursor color is enabled and the user's mouse position changes
*/
void CursorColor(const Color &reference, const Color &display);
void cursor_color(const Color &reference, const Color &display);
void DragEntered(QDragEnterEvent *event);
void drag_entered(QDragEnterEvent *event);
void DragLeft(QDragLeaveEvent *event);
void drag_left(QDragLeaveEvent *event);
void Dropped(QDropEvent *event);
void dropped(QDropEvent *event);
void TextureChanged(TexturePtr texture);
void texture_changed(TexturePtr texture);
void QueueStarved();
void queue_starved();
void QueueNoLongerStarved();
void queue_no_longer_starved();
void CreateAddableAt(const QRectF &rect);
void create_addable_at(const QRectF &rect);
protected:
QTransform GenerateWorldTransform();
QTransform generate_world_transform();
QTransform GenerateDisplayTransform();
QTransform generate_display_transform();
QTransform GenerateGizmoTransform(NodeTraverser &gt,
QTransform generate_gizmo_transform(NodeTraverser &gt,
const TimeRange &range);
QTransform GenerateGizmoTransform()
QTransform generate_gizmo_transform()
{
NodeTraverser t;
t.SetCacheVideoParams(gizmo_params_);
return GenerateGizmoTransform(t, GenerateGizmoTime());
t.set_cache_video_params(gizmo_params_);
return generate_gizmo_transform(t, generate_gizmo_time());
}
TimeRange GenerateGizmoTime()
TimeRange generate_gizmo_time()
{
rational node_time = GetGizmoTime();
Rational node_time = get_gizmo_time();
return TimeRange(node_time,
node_time + gizmo_params_.frame_rate_as_time_base());
}
virtual TexturePtr LoadCustomTextureFromFrame(const QVariant &v)
virtual TexturePtr load_custom_texture_from_frame(const QVariant &v)
{
return nullptr;
}
@@ -280,63 +280,63 @@ protected slots:
*
* Simple OpenGL drawing function for painting the texture on screen. Standardized around OpenGL ES 3.2 Core.
*/
virtual void OnPaint() override;
virtual void on_paint() override;
virtual void OnDestroy() override;
virtual void on_destroy() override;
private:
QPointF GetTexturePosition(const QPoint &screen_pos);
QPointF GetTexturePosition(const QSize &size);
QPointF GetTexturePosition(const double &x, const double &y);
QPointF get_texture_position(const QPoint &screen_pos);
QPointF get_texture_position(const QSize &size);
QPointF get_texture_position(const double &x, const double &y);
static void DrawTextWithCrudeShadow(QPainter *painter, const QRect &rect,
static void draw_text_with_crude_shadow(QPainter *painter, const QRect &rect,
const QString &text,
const QTextOption &opt = QTextOption());
rational GetGizmoTime();
Rational get_gizmo_time();
bool IsHandDrag(QMouseEvent *event) const;
bool is_hand_drag(QMouseEvent *event) const;
void UpdateMatrix();
void update_matrix();
NodeGizmo *TryGizmoPress(const NodeValueRow &row, const QPointF &p);
NodeGizmo *try_gizmo_press(const NodeValueRow &row, const QPointF &p);
void OpenTextGizmo(TextGizmo *text, QMouseEvent *event = nullptr);
void open_text_gizmo(TextGizmo *text, QMouseEvent *event = nullptr);
bool OnMousePress(QMouseEvent *e);
bool OnMouseMove(QMouseEvent *e);
bool OnMouseRelease(QMouseEvent *e);
bool OnMouseDoubleClick(QMouseEvent *e);
bool on_mouse_press(QMouseEvent *e);
bool on_mouse_move(QMouseEvent *e);
bool on_mouse_release(QMouseEvent *e);
bool on_mouse_double_click(QMouseEvent *e);
bool OnKeyPress(QKeyEvent *e);
bool OnKeyRelease(QKeyEvent *e);
bool on_key_press(QKeyEvent *e);
bool on_key_release(QKeyEvent *e);
void EmitColorAtCursor(QMouseEvent *e);
void emit_color_at_cursor(QMouseEvent *e);
void DrawSubtitleTracks();
void draw_subtitle_tracks();
QPointF GetVirtualPosForTextEdit(const QPointF &p)
QPointF get_virtual_pos_for_text_edit(const QPointF &p)
{
return text_transform_inverted_.map(p) - text_edit_pos_;
}
template <typename T> void ForwardDragEventToTextEdit(T *event);
template <typename T> void forward_drag_event_to_text_edit(T *event);
bool ForwardMouseEventToTextEdit(QMouseEvent *event,
bool forward_mouse_event_to_text_edit(QMouseEvent *event,
bool check_if_outside = false);
bool ForwardEventToTextEdit(QEvent *event);
bool forward_event_to_text_edit(QEvent *event);
QPointF AdjustPosByVAlign(QPointF p);
QPointF adjust_pos_by_v_align(QPointF p);
void CloseTextEditor();
void close_text_editor();
void GenerateGizmoTransforms();
void generate_gizmo_transforms();
void DrawBlank(const VideoParams &device_params);
void draw_blank(const VideoParams &device_params);
void DrawBackendNeutral(const ColorTransformJob &ctj, QPainter *painter);
bool DrawBackendNeutralFrame(const FramePtr &frame, QPainter *painter);
bool DrawBackendNeutralTexture(const TexturePtr &texture,
void draw_backend_neutral(const ColorTransformJob &ctj, QPainter *painter);
bool draw_backend_neutral_frame(const FramePtr &frame, QPainter *painter);
bool draw_backend_neutral_texture(const TexturePtr &texture,
QPainter *painter);
/**
@@ -417,7 +417,7 @@ private:
bool show_subtitles_;
Sequence *subtitle_tracks_;
rational time_;
Rational time_;
/**
* @brief Position of mouse to calculate delta from.
@@ -444,16 +444,16 @@ private:
enum PushMode {
/// New frame to push to internal texture
kPushFrame,
k_push_frame,
/// Internal texture reference is up to date, keep showing it
kPushUnnecessary,
k_push_unnecessary,
/// Draw blank/black screen
kPushBlank,
k_push_blank,
/// Draw nothing (not even a black frame)
kPushNull,
k_push_null,
};
PushMode push_mode_;
@@ -463,7 +463,7 @@ private:
ViewerPlaybackTimer timer_;
rational playback_timebase_;
Rational playback_timebase_;
bool add_band_;
QPoint add_band_start_;
@@ -479,18 +479,18 @@ private:
QTransform text_transform_inverted_;
private slots:
void UpdateFromQueue();
void update_from_queue();
void TextEditChanged();
void TextEditDestroyed();
void text_edit_changed();
void text_edit_destroyed();
void SubtitlesChanged(const TimeRange &r);
void subtitles_changed(const TimeRange &r);
void FocusChanged(QWidget *old, QWidget *now);
void focus_changed(QWidget *old, QWidget *now);
QRectF UpdateActiveTextGizmoSize();
QRectF update_active_text_gizmo_size();
};
}
#endif // VIEWERGLWIDGET_H
#endif // OAK_VIEWERGLWIDGET_H
+2 -2
View File
@@ -26,7 +26,7 @@
namespace olive
{
void ViewerPlaybackTimer::Start(const int64_t &start_timestamp,
void ViewerPlaybackTimer::start(const int64_t &start_timestamp,
const int &playback_speed,
const double &timebase)
{
@@ -36,7 +36,7 @@ void ViewerPlaybackTimer::Start(const int64_t &start_timestamp,
timebase_ = timebase * 1000;
}
int64_t ViewerPlaybackTimer::GetTimestampNow() const
int64_t ViewerPlaybackTimer::get_timestamp_now() const
{
int64_t real_time = timer_.elapsed();
+5 -5
View File
@@ -19,8 +19,8 @@
***/
#ifndef VIEWERPLAYBACKTIMER_H
#define VIEWERPLAYBACKTIMER_H
#ifndef OAK_VIEWERPLAYBACKTIMER_H
#define OAK_VIEWERPLAYBACKTIMER_H
#include <QtGlobal>
#include <QElapsedTimer>
@@ -32,10 +32,10 @@ namespace olive
class ViewerPlaybackTimer {
public:
void Start(const int64_t &start_timestamp, const int &playback_speed,
void start(const int64_t &start_timestamp, const int &playback_speed,
const double &timebase);
int64_t GetTimestampNow() const;
int64_t get_timestamp_now() const;
private:
QElapsedTimer timer_;
@@ -48,4 +48,4 @@ private:
}
#endif // VIEWERPLAYBACKTIMER_H
#endif // OAK_VIEWERPLAYBACKTIMER_H
+1 -1
View File
@@ -37,7 +37,7 @@ IOPMAssertionID assertionID = 0;
#endif
void PreventSleep(bool on)
void prevent_sleep(bool on)
{
#if defined(Q_OS_WINDOWS)
SetThreadExecutionState(on ? ES_DISPLAY_REQUIRED | ES_CONTINUOUS :
+4 -4
View File
@@ -16,14 +16,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef VIEWERPREVENTSLEEP_H
#define VIEWERPREVENTSLEEP_H
#ifndef OAK_VIEWERPREVENTSLEEP_H
#define OAK_VIEWERPREVENTSLEEP_H
namespace olive
{
void PreventSleep(bool on);
void prevent_sleep(bool on);
}
#endif // VIEWERPREVENTSLEEP_H
#endif // OAK_VIEWERPREVENTSLEEP_H
+6 -6
View File
@@ -19,8 +19,8 @@
***/
#ifndef VIEWERQUEUE_H
#define VIEWERQUEUE_H
#ifndef OAK_VIEWERQUEUE_H
#define OAK_VIEWERQUEUE_H
#include <QVariant>
#include <QMutex>
@@ -32,7 +32,7 @@ namespace olive
{
struct ViewerPlaybackFrame {
rational timestamp;
Rational timestamp;
QVariant frame;
};
@@ -57,7 +57,7 @@ public:
return *this;
}
void AppendTimewise(const ViewerPlaybackFrame &f, int playback_speed)
void append_timewise(const ViewerPlaybackFrame &f, int playback_speed)
{
QMutexLocker locker(mutex_);
if (this->empty() ||
@@ -73,7 +73,7 @@ public:
}
}
void PurgeBefore(const rational &time, int playback_speed)
void purge_before(const Rational &time, int playback_speed)
{
QMutexLocker locker(mutex_);
while (!this->empty() &&
@@ -91,4 +91,4 @@ private:
Q_DECLARE_METATYPE(olive::ViewerPlaybackFrame)
#endif // VIEWERQUEUE_H
#endif // OAK_VIEWERQUEUE_H
+3 -3
View File
@@ -19,8 +19,8 @@
***/
#ifndef VIEWERSAFEMARGININFO_H
#define VIEWERSAFEMARGININFO_H
#ifndef OAK_VIEWERSAFEMARGININFO_H
#define OAK_VIEWERSAFEMARGININFO_H
#include <QtMath>
@@ -76,4 +76,4 @@ private:
}
#endif // VIEWERSAFEMARGININFO_H
#endif // OAK_VIEWERSAFEMARGININFO_H
+37 -37
View File
@@ -43,17 +43,17 @@ ViewerSizer::ViewerSizer(QWidget *parent)
horiz_scrollbar_ = new QScrollBar(Qt::Horizontal, this);
horiz_scrollbar_->setVisible(false);
connect(horiz_scrollbar_, &QScrollBar::valueChanged, this,
&ViewerSizer::ScrollBarMoved);
&ViewerSizer::scroll_bar_moved);
vert_scrollbar_ = new QScrollBar(Qt::Vertical, this);
vert_scrollbar_->setVisible(false);
connect(vert_scrollbar_, &QScrollBar::valueChanged, this,
&ViewerSizer::ScrollBarMoved);
&ViewerSizer::scroll_bar_moved);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
}
void ViewerSizer::SetWidget(QWidget *widget)
void ViewerSizer::set_widget(QWidget *widget)
{
// Delete any previous widgets occupying this space
delete widget_;
@@ -64,50 +64,50 @@ void ViewerSizer::SetWidget(QWidget *widget)
widget_->setParent(this);
widget_->installEventFilter(this);
UpdateSize();
update_size();
}
}
QSize ViewerSizer::GetContainerSize() const
QSize ViewerSizer::get_container_size() const
{
double s = GetRealCurrentZoom();
double s = get_real_current_zoom();
return QSize(std::min(this->width(), int(width_ * s)) -
vert_scrollbar_->width(),
std::min(int(height_ * s), this->height()) -
horiz_scrollbar_->height());
}
void ViewerSizer::SetChildSize(int width, int height)
void ViewerSizer::set_child_size(int width, int height)
{
width_ = width;
height_ = height;
UpdateSize();
update_size();
}
void ViewerSizer::SetPixelAspectRatio(const rational &pixel_aspect)
void ViewerSizer::set_pixel_aspect_ratio(const Rational &pixel_aspect)
{
pixel_aspect_ = pixel_aspect;
UpdateSize();
update_size();
}
void ViewerSizer::SetZoom(double percent)
void ViewerSizer::set_zoom(double percent)
{
zoom_ = percent;
UpdateSize();
update_size();
}
void ViewerSizer::SetZoomAnchored(double next_scale, double cursor_x,
void ViewerSizer::set_zoom_anchored(double next_scale, double cursor_x,
double cursor_y)
{
if (next_scale > 0) {
double cur_scale = GetRealCurrentZoom();
double cur_scale = get_real_current_zoom();
// Clamp scale within safe values
next_scale = std::clamp(next_scale, kZoomLevels[0],
kZoomLevels[kZoomLevelCount - 1]);
next_scale = std::clamp(next_scale, k_zoom_levels[0],
k_zoom_levels[k_zoom_level_count - 1]);
int anchor_x = qRound(double(cursor_x + horiz_scrollbar_->value()) /
cur_scale * next_scale -
@@ -116,19 +116,19 @@ void ViewerSizer::SetZoomAnchored(double next_scale, double cursor_x,
cur_scale * next_scale -
cursor_y);
SetZoom(next_scale);
set_zoom(next_scale);
horiz_scrollbar_->setValue(anchor_x);
vert_scrollbar_->setValue(anchor_y);
} else {
SetZoom(-1);
set_zoom(-1);
horiz_scrollbar_->setValue(0);
vert_scrollbar_->setValue(0);
}
}
void ViewerSizer::HandDragMove(int x, int y)
void ViewerSizer::hand_drag_move(int x, int y)
{
if (horiz_scrollbar_->isVisible()) {
horiz_scrollbar_->setValue(horiz_scrollbar_->value() - x);
@@ -146,10 +146,10 @@ bool ViewerSizer::eventFilter(QObject *watched, QEvent *event)
QWheelEvent *w = static_cast<QWheelEvent *>(event);
if (HandMovableView::WheelEventIsAZoomEvent(w)) {
double next_scale = GetRealCurrentZoom() *
HandMovableView::GetScrollZoomMultiplier(w);
double next_scale = get_real_current_zoom() *
HandMovableView::get_scroll_zoom_multiplier(w);
QPointF cursor_pos = w->position();
SetZoomAnchored(next_scale, cursor_pos.x(), cursor_pos.y());
set_zoom_anchored(next_scale, cursor_pos.x(), cursor_pos.y());
} else {
// Pass scroll values to scrollbars
QPoint p = w->pixelDelta();
@@ -167,10 +167,10 @@ void ViewerSizer::resizeEvent(QResizeEvent *event)
{
QWidget::resizeEvent(event);
UpdateSize();
update_size();
}
void ViewerSizer::UpdateSize()
void ViewerSizer::update_size()
{
if (widget_ == nullptr) {
return;
@@ -189,9 +189,9 @@ void ViewerSizer::UpdateSize()
// Determine if we need scrollbars for the zoom we want
horiz_scrollbar_->setVisible(zoom_ > 0 &&
GetZoomedValue(width_) > available_width);
get_zoomed_value(width_) > available_width);
vert_scrollbar_->setVisible(zoom_ > 0 &&
GetZoomedValue(height_) > available_height);
get_zoomed_value(height_) > available_height);
// Horizontal scrollbar will reduce the available height
if (horiz_scrollbar_->isVisible()) {
@@ -209,7 +209,7 @@ void ViewerSizer::UpdateSize()
horiz_scrollbar_->sizeHint().height());
horiz_scrollbar_->move(0,
this->height() - horiz_scrollbar_->height() - 1);
horiz_scrollbar_->setMaximum(GetZoomedValue(width_) - available_width);
horiz_scrollbar_->setMaximum(get_zoomed_value(width_) - available_width);
horiz_scrollbar_->setPageStep(available_width);
}
@@ -218,7 +218,7 @@ void ViewerSizer::UpdateSize()
vert_scrollbar_->resize(vert_scrollbar_->sizeHint().width(),
available_height);
vert_scrollbar_->move(this->width() - vert_scrollbar_->width() - 1, 0);
vert_scrollbar_->setMaximum(GetZoomedValue(height_) - available_height);
vert_scrollbar_->setMaximum(get_zoomed_value(height_) - available_height);
vert_scrollbar_->setPageStep(available_height);
}
@@ -227,7 +227,7 @@ void ViewerSizer::UpdateSize()
// Adjust to aspect ratio
double sequence_aspect_ratio =
double(width_) / double(height_) * pixel_aspect_.toDouble();
double(width_) / double(height_) * pixel_aspect_.to_double();
double our_aspect_ratio =
double(available_width) / double(available_height);
@@ -253,17 +253,17 @@ void ViewerSizer::UpdateSize()
child_matrix.scale(zoom_diff, zoom_diff, 1.0);
}
emit RequestScale(child_matrix);
emit request_scale(child_matrix);
ScrollBarMoved();
scroll_bar_moved();
}
int ViewerSizer::GetZoomedValue(int value)
int ViewerSizer::get_zoomed_value(int value)
{
return qRound(value * zoom_);
}
double ViewerSizer::GetRealCurrentZoom() const
double ViewerSizer::get_real_current_zoom() const
{
if (zoom_ < 0) {
// Currently set to "fit"
@@ -274,14 +274,14 @@ double ViewerSizer::GetRealCurrentZoom() const
}
}
void ViewerSizer::ScrollBarMoved()
void ViewerSizer::scroll_bar_moved()
{
QMatrix4x4 mat;
float x_scroll, y_scroll;
if (horiz_scrollbar_->isVisible()) {
int zoomed_width = GetZoomedValue(width_);
int zoomed_width = get_zoomed_value(width_);
x_scroll = (zoomed_width / 2 - horiz_scrollbar_->value() -
widget_->width() / 2) *
(2.0 / zoomed_width);
@@ -290,7 +290,7 @@ void ViewerSizer::ScrollBarMoved()
}
if (vert_scrollbar_->isVisible()) {
int zoomed_height = GetZoomedValue(height_);
int zoomed_height = get_zoomed_value(height_);
y_scroll = (zoomed_height / 2 - vert_scrollbar_->value() -
widget_->height() / 2) *
(2.0 / zoomed_height);
@@ -301,7 +301,7 @@ void ViewerSizer::ScrollBarMoved()
// Zero translate is centered, so we need to determine how much "off center" we are
mat.translate(x_scroll, y_scroll);
emit RequestTranslate(mat);
emit request_translate(mat);
}
}
+19 -19
View File
@@ -19,8 +19,8 @@
***/
#ifndef VIEWERSIZER_H
#define VIEWERSIZER_H
#ifndef OAK_VIEWERSIZER_H
#define OAK_VIEWERSIZER_H
#include <olive/core/core.h>
#include <QScrollBar>
@@ -50,12 +50,12 @@ public:
*
* ViewerSizer takes ownership of this widget. If a widget was previously set, it is destroyed.
*/
void SetWidget(QWidget *widget);
void set_widget(QWidget *widget);
QSize GetContainerSize() const;
QSize get_container_size() const;
static constexpr int kZoomLevelCount = 10;
static constexpr double kZoomLevels[kZoomLevelCount] = {
static constexpr int k_zoom_level_count = 10;
static constexpr double k_zoom_levels[k_zoom_level_count] = {
0.05, 0.1, 0.25, 0.5, 0.75, 1.0, 1.5, 2.0, 4.0, 8.0
};
@@ -65,29 +65,29 @@ public slots:
*
* This is not the actual resolution of the viewer, it's used to calculate the aspect ratio
*/
void SetChildSize(int width, int height);
void set_child_size(int width, int height);
/**
* @brief Set pixel aspect ratio
*/
void SetPixelAspectRatio(const rational &pixel_aspect);
void set_pixel_aspect_ratio(const Rational &pixel_aspect);
/**
* @brief Set the zoom value of the child widget
*
* The number is an integer percentage (100 = 100%). Set to 0 to auto-fit.
*/
void SetZoom(double percent);
void SetZoomAnchored(double percent, double cursor_x, double cursor_y);
void set_zoom(double percent);
void set_zoom_anchored(double percent, double cursor_x, double cursor_y);
void HandDragMove(int x, int y);
void hand_drag_move(int x, int y);
virtual bool eventFilter(QObject *watched, QEvent *event) override;
signals:
void RequestScale(const QMatrix4x4 &matrix);
void request_scale(const QMatrix4x4 &matrix);
void RequestTranslate(const QMatrix4x4 &matrix);
void request_translate(const QMatrix4x4 &matrix);
protected:
/**
@@ -99,11 +99,11 @@ private:
/**
* @brief Main sizing function, resizes widget_ to fit aspect_ratio_ (or hides if aspect ratio is 0)
*/
void UpdateSize();
void update_size();
int GetZoomedValue(int value);
int get_zoomed_value(int value);
double GetRealCurrentZoom() const;
double get_real_current_zoom() const;
/**
* @brief Reference to widget
@@ -118,7 +118,7 @@ private:
int width_;
int height_;
rational pixel_aspect_;
Rational pixel_aspect_;
/**
* @brief Internal zoom value
@@ -130,9 +130,9 @@ private:
QScrollBar *vert_scrollbar_;
private slots:
void ScrollBarMoved();
void scroll_bar_moved();
};
}
#endif // VIEWERSIZER_H
#endif // OAK_VIEWERSIZER_H
+119 -119
View File
@@ -58,9 +58,9 @@ ViewerTextEditor::ViewerTextEditor(double scale, QWidget *parent)
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
connect(horizontalScrollBar(), &QScrollBar::rangeChanged, this,
&ViewerTextEditor::LockScrollBarMaximumToZero);
&ViewerTextEditor::lock_scroll_bar_maximum_to_zero);
connect(verticalScrollBar(), &QScrollBar::rangeChanged, this,
&ViewerTextEditor::LockScrollBarMaximumToZero);
&ViewerTextEditor::lock_scroll_bar_maximum_to_zero);
// Force DPI to the same one that we're using in the actual render
dpi_force_ = QImage(1, 1, QImage::Format_RGBA8888_Premultiplied);
@@ -71,51 +71,51 @@ ViewerTextEditor::ViewerTextEditor(double scale, QWidget *parent)
document()->documentLayout()->setPaintDevice(&dpi_force_);
connect(this, &QTextEdit::currentCharFormatChanged, this,
&ViewerTextEditor::FormatChanged);
&ViewerTextEditor::format_changed);
connect(document(), &QTextDocument::contentsChanged, this,
&ViewerTextEditor::DocumentChanged, Qt::QueuedConnection);
&ViewerTextEditor::document_changed, Qt::QueuedConnection);
setAcceptRichText(false);
}
void ViewerTextEditor::ConnectToolBar(ViewerTextEditorToolBar *toolbar)
void ViewerTextEditor::connect_tool_bar(ViewerTextEditorToolBar *toolbar)
{
connect(toolbar, &ViewerTextEditorToolBar::FamilyChanged, this,
&ViewerTextEditor::SetFamily);
connect(toolbar, &ViewerTextEditorToolBar::SizeChanged, this,
connect(toolbar, &ViewerTextEditorToolBar::family_changed, this,
&ViewerTextEditor::set_family);
connect(toolbar, &ViewerTextEditorToolBar::size_changed, this,
&ViewerTextEditor::setFontPointSize);
connect(toolbar, &ViewerTextEditorToolBar::StyleChanged, this,
&ViewerTextEditor::SetStyle);
connect(toolbar, &ViewerTextEditorToolBar::UnderlineChanged, this,
connect(toolbar, &ViewerTextEditorToolBar::style_changed, this,
&ViewerTextEditor::set_style);
connect(toolbar, &ViewerTextEditorToolBar::underline_changed, this,
&ViewerTextEditor::setFontUnderline);
connect(toolbar, &ViewerTextEditorToolBar::StrikethroughChanged, this,
&ViewerTextEditor::SetFontStrikethrough);
connect(toolbar, &ViewerTextEditorToolBar::ColorChanged, this,
connect(toolbar, &ViewerTextEditorToolBar::strikethrough_changed, this,
&ViewerTextEditor::set_font_strikethrough);
connect(toolbar, &ViewerTextEditorToolBar::color_changed, this,
&ViewerTextEditor::setTextColor);
connect(toolbar, &ViewerTextEditorToolBar::SmallCapsChanged, this,
&ViewerTextEditor::SetSmallCaps);
connect(toolbar, &ViewerTextEditorToolBar::StretchChanged, this,
&ViewerTextEditor::SetFontStretch);
connect(toolbar, &ViewerTextEditorToolBar::KerningChanged, this,
&ViewerTextEditor::SetFontKerning);
connect(toolbar, &ViewerTextEditorToolBar::LineHeightChanged, this,
&ViewerTextEditor::SetLineHeight);
connect(toolbar, &ViewerTextEditorToolBar::AlignmentChanged, this,
connect(toolbar, &ViewerTextEditorToolBar::small_caps_changed, this,
&ViewerTextEditor::set_small_caps);
connect(toolbar, &ViewerTextEditorToolBar::stretch_changed, this,
&ViewerTextEditor::set_font_stretch);
connect(toolbar, &ViewerTextEditorToolBar::kerning_changed, this,
&ViewerTextEditor::set_font_kerning);
connect(toolbar, &ViewerTextEditorToolBar::line_height_changed, this,
&ViewerTextEditor::set_line_height);
connect(toolbar, &ViewerTextEditorToolBar::alignment_changed, this,
[this](Qt::Alignment a) {
this->setAlignment(a);
// Ensure no buttons are checked that shouldn't be
static_cast<ViewerTextEditorToolBar *>(sender())->SetAlignment(
static_cast<ViewerTextEditorToolBar *>(sender())->set_alignment(
a);
});
UpdateToolBar(toolbar, this->currentCharFormat(),
update_tool_bar(toolbar, this->currentCharFormat(),
this->textCursor().blockFormat(), this->alignment());
toolbars_.append(toolbar);
}
void ViewerTextEditor::Paint(QPainter *p, Qt::Alignment valign)
void ViewerTextEditor::paint(QPainter *p, Qt::Alignment valign)
{
QAbstractTextDocumentLayout::PaintContext ctx;
@@ -171,7 +171,7 @@ void ViewerTextEditor::paintEvent(QPaintEvent *e)
// Disable painting
}
void ViewerTextEditor::UpdateToolBar(ViewerTextEditorToolBar *toolbar,
void ViewerTextEditor::update_tool_bar(ViewerTextEditorToolBar *toolbar,
const QTextCharFormat &f,
const QTextBlockFormat &b,
Qt::Alignment alignment)
@@ -201,25 +201,25 @@ void ViewerTextEditor::UpdateToolBar(ViewerTextEditorToolBar *toolbar,
}
}
toolbar->SetFontFamily(family);
toolbar->SetFontSize(f.fontPointSize());
toolbar->SetStyle(style);
toolbar->SetUnderline(f.fontUnderline());
toolbar->SetStrikethrough(f.fontStrikeOut());
toolbar->SetAlignment(alignment);
toolbar->SetColor(f.foreground().color());
toolbar->SetSmallCaps(f.fontCapitalization() == QFont::SmallCaps);
toolbar->SetStretch(f.fontStretch() == 0 ? 100 : f.fontStretch());
toolbar->SetKerning(f.fontLetterSpacing() == 0.0 ? 100 :
toolbar->set_font_family(family);
toolbar->set_font_size(f.fontPointSize());
toolbar->set_style(style);
toolbar->set_underline(f.fontUnderline());
toolbar->set_strikethrough(f.fontStrikeOut());
toolbar->set_alignment(alignment);
toolbar->set_color(f.foreground().color());
toolbar->set_small_caps(f.fontCapitalization() == QFont::SmallCaps);
toolbar->set_stretch(f.fontStretch() == 0 ? 100 : f.fontStretch());
toolbar->set_kerning(f.fontLetterSpacing() == 0.0 ? 100 :
f.fontLetterSpacing());
toolbar->SetLineHeight(b.lineHeight() == 0.0 ? 100 : b.lineHeight());
toolbar->set_line_height(b.lineHeight() == 0.0 ? 100 : b.lineHeight());
}
void ViewerTextEditor::FormatChanged(const QTextCharFormat &f)
void ViewerTextEditor::format_changed(const QTextCharFormat &f)
{
if (!block_update_toolbar_signal_) {
foreach (ViewerTextEditorToolBar *toolbar, toolbars_) {
UpdateToolBar(toolbar, f, textCursor().blockFormat(),
update_tool_bar(toolbar, f, textCursor().blockFormat(),
this->alignment());
}
}
@@ -230,7 +230,7 @@ void ViewerTextEditor::FormatChanged(const QTextCharFormat &f)
}
}
void ViewerTextEditor::SetFamily(const QString &s)
void ViewerTextEditor::set_family(const QString &s)
{
ViewerTextEditorToolBar *toolbar =
static_cast<ViewerTextEditorToolBar *>(sender());
@@ -238,52 +238,52 @@ void ViewerTextEditor::SetFamily(const QString &s)
QTextCharFormat f;
f.setFontFamilies({ s });
ApplyStyle(&f, s, toolbar->GetFontStyleName());
apply_style(&f, s, toolbar->get_font_style_name());
MergeCharFormat(f);
merge_char_format(f);
}
void ViewerTextEditor::SetStyle(const QString &s)
void ViewerTextEditor::set_style(const QString &s)
{
ViewerTextEditorToolBar *toolbar =
static_cast<ViewerTextEditorToolBar *>(sender());
QTextCharFormat f;
ApplyStyle(&f, toolbar->GetFontFamily(), s);
apply_style(&f, toolbar->get_font_family(), s);
MergeCharFormat(f);
merge_char_format(f);
}
void ViewerTextEditor::SetFontStrikethrough(bool e)
void ViewerTextEditor::set_font_strikethrough(bool e)
{
QTextCharFormat f;
f.setFontStrikeOut(e);
MergeCharFormat(f);
merge_char_format(f);
}
void ViewerTextEditor::SetSmallCaps(bool e)
void ViewerTextEditor::set_small_caps(bool e)
{
QTextCharFormat f;
f.setFontCapitalization(e ? QFont::SmallCaps : QFont::MixedCase);
MergeCharFormat(f);
merge_char_format(f);
}
void ViewerTextEditor::SetFontStretch(int i)
void ViewerTextEditor::set_font_stretch(int i)
{
QTextCharFormat f;
f.setFontStretch(i);
MergeCharFormat(f);
merge_char_format(f);
}
void ViewerTextEditor::SetFontKerning(qreal i)
void ViewerTextEditor::set_font_kerning(qreal i)
{
QTextCharFormat f;
f.setFontLetterSpacing(i);
MergeCharFormat(f);
merge_char_format(f);
}
void ViewerTextEditor::MergeCharFormat(const QTextCharFormat &fmt)
void ViewerTextEditor::merge_char_format(const QTextCharFormat &fmt)
{
// mergeCurrentCharFormat throws a currentCharFormatChanged signal that updates the toolbar,
// this can be undesirable if the user is currently typing a font
@@ -293,7 +293,7 @@ void ViewerTextEditor::MergeCharFormat(const QTextCharFormat &fmt)
block_update_toolbar_signal_ = false;
}
void ViewerTextEditor::ApplyStyle(QTextCharFormat *format,
void ViewerTextEditor::apply_style(QTextCharFormat *format,
const QString &family, const QString &style)
{
// NOTE: Windows appears to require setting weight and italic manually, while macOS and Linux are
@@ -304,19 +304,19 @@ void ViewerTextEditor::ApplyStyle(QTextCharFormat *format,
format->setFontStyleName(style);
}
void ViewerTextEditor::SetLineHeight(qreal i)
void ViewerTextEditor::set_line_height(qreal i)
{
QTextBlockFormat f = this->textCursor().blockFormat();
f.setLineHeight(i, QTextBlockFormat::ProportionalHeight);
this->textCursor().setBlockFormat(f);
}
void ViewerTextEditor::LockScrollBarMaximumToZero()
void ViewerTextEditor::lock_scroll_bar_maximum_to_zero()
{
static_cast<QScrollBar *>(sender())->setMaximum(0);
}
void ViewerTextEditor::DocumentChanged()
void ViewerTextEditor::document_changed()
{
if (document()->blockCount() == 1 &&
document()->firstBlock().text().isEmpty()) {
@@ -363,7 +363,7 @@ ViewerTextEditorToolBar::ViewerTextEditorToolBar(QWidget *parent)
QVBoxLayout *outer_layout = new QVBoxLayout(this);
const int advanced_slider_width =
QtUtils::QFontMetricsWidth(fontMetrics(), QStringLiteral("9999.9%"));
QtUtils::q_font_metrics_width(fontMetrics(), QStringLiteral("9999.9%"));
{
QHBoxLayout *row_layout = new QHBoxLayout();
@@ -373,40 +373,40 @@ ViewerTextEditorToolBar::ViewerTextEditorToolBar(QWidget *parent)
font_combo_ = new QFontComboBox();
connect(
font_combo_, &QFontComboBox::currentTextChanged, this,
&ViewerTextEditorToolBar::UpdateFontStyleListAndEmitFamilyChanged);
&ViewerTextEditorToolBar::update_font_style_list_and_emit_family_changed);
row_layout->addWidget(font_combo_);
font_sz_slider_ = new FloatSlider();
font_sz_slider_->SetMinimum(0.1);
font_sz_slider_->SetMaximum(9999.9);
font_sz_slider_->SetDecimalPlaces(1);
font_sz_slider_->SetAlignment(Qt::AlignCenter);
font_sz_slider_->set_minimum(0.1);
font_sz_slider_->set_maximum(9999.9);
font_sz_slider_->set_decimal_places(1);
font_sz_slider_->set_alignment(Qt::AlignCenter);
font_sz_slider_->setFixedWidth(advanced_slider_width);
connect(font_sz_slider_, &FloatSlider::ValueChanged, this,
&ViewerTextEditorToolBar::SizeChanged);
font_sz_slider_->SetLadderElementCount(2);
connect(font_sz_slider_, &FloatSlider::value_changed, this,
&ViewerTextEditorToolBar::size_changed);
font_sz_slider_->set_ladder_element_count(2);
row_layout->addWidget(font_sz_slider_);
style_combo_ = new QComboBox();
connect(style_combo_, &QComboBox::currentTextChanged, this,
&ViewerTextEditorToolBar::StyleChanged);
&ViewerTextEditorToolBar::style_changed);
row_layout->addWidget(style_combo_);
underline_btn_ = new QPushButton();
connect(underline_btn_, &QPushButton::clicked, this,
&ViewerTextEditorToolBar::UnderlineChanged);
&ViewerTextEditorToolBar::underline_changed);
underline_btn_->setCheckable(true);
underline_btn_->setIcon(icon::TextUnderline);
underline_btn_->setIcon(icon::text_underline);
row_layout->addWidget(underline_btn_);
strikethrough_btn_ = new QPushButton();
connect(strikethrough_btn_, &QPushButton::clicked, this,
&ViewerTextEditorToolBar::StrikethroughChanged);
&ViewerTextEditorToolBar::strikethrough_changed);
strikethrough_btn_->setCheckable(true);
strikethrough_btn_->setIcon(icon::TextStrikethrough);
strikethrough_btn_->setIcon(icon::text_strikethrough);
row_layout->addWidget(strikethrough_btn_);
AddSpacer(row_layout);
add_spacer(row_layout);
color_btn_ = new QPushButton();
color_btn_->setAutoFillBackground(true);
@@ -416,8 +416,8 @@ ViewerTextEditorToolBar::ViewerTextEditorToolBar(QWidget *parent)
QColorDialog cd(c, this);
if (cd.exec() == QDialog::Accepted) {
c = cd.selectedColor();
SetColor(c);
emit ColorChanged(c);
set_color(c);
emit color_changed(c);
}
});
row_layout->addWidget(color_btn_);
@@ -432,102 +432,102 @@ ViewerTextEditorToolBar::ViewerTextEditorToolBar(QWidget *parent)
align_left_btn_ = new QPushButton();
align_left_btn_->setCheckable(true);
align_left_btn_->setIcon(icon::TextAlignLeft);
align_left_btn_->setIcon(icon::text_align_left);
connect(align_left_btn_, &QPushButton::clicked, this,
[this] { emit AlignmentChanged(Qt::AlignLeft); });
[this] { emit alignment_changed(Qt::AlignLeft); });
row_layout->addWidget(align_left_btn_);
align_center_btn_ = new QPushButton();
align_center_btn_->setCheckable(true);
align_center_btn_->setIcon(icon::TextAlignCenter);
align_center_btn_->setIcon(icon::text_align_center);
connect(align_center_btn_, &QPushButton::clicked, this,
[this] { emit AlignmentChanged(Qt::AlignHCenter); });
[this] { emit alignment_changed(Qt::AlignHCenter); });
row_layout->addWidget(align_center_btn_);
align_right_btn_ = new QPushButton();
align_right_btn_->setCheckable(true);
align_right_btn_->setIcon(icon::TextAlignRight);
align_right_btn_->setIcon(icon::text_align_right);
connect(align_right_btn_, &QPushButton::clicked, this,
[this] { emit AlignmentChanged(Qt::AlignRight); });
[this] { emit alignment_changed(Qt::AlignRight); });
row_layout->addWidget(align_right_btn_);
align_justify_btn_ = new QPushButton();
align_justify_btn_->setCheckable(true);
align_justify_btn_->setIcon(icon::TextAlignJustify);
align_justify_btn_->setIcon(icon::text_align_justify);
connect(align_justify_btn_, &QPushButton::clicked, this,
[this] { emit AlignmentChanged(Qt::AlignJustify); });
[this] { emit alignment_changed(Qt::AlignJustify); });
row_layout->addWidget(align_justify_btn_);
AddSpacer(row_layout);
add_spacer(row_layout);
align_top_btn_ = new QPushButton();
align_top_btn_->setCheckable(true);
align_top_btn_->setIcon(icon::TextAlignTop);
align_top_btn_->setIcon(icon::text_align_top);
connect(align_top_btn_, &QPushButton::clicked, this,
[this] { emit VerticalAlignmentChanged(Qt::AlignTop); });
[this] { emit vertical_alignment_changed(Qt::AlignTop); });
row_layout->addWidget(align_top_btn_);
align_middle_btn_ = new QPushButton();
align_middle_btn_->setCheckable(true);
align_middle_btn_->setIcon(icon::TextAlignMiddle);
align_middle_btn_->setIcon(icon::text_align_middle);
connect(align_middle_btn_, &QPushButton::clicked, this,
[this] { emit VerticalAlignmentChanged(Qt::AlignVCenter); });
[this] { emit vertical_alignment_changed(Qt::AlignVCenter); });
row_layout->addWidget(align_middle_btn_);
align_bottom_btn_ = new QPushButton();
align_bottom_btn_->setCheckable(true);
align_bottom_btn_->setIcon(icon::TextAlignBottom);
align_bottom_btn_->setIcon(icon::text_align_bottom);
connect(align_bottom_btn_, &QPushButton::clicked, this,
[this] { emit VerticalAlignmentChanged(Qt::AlignBottom); });
[this] { emit vertical_alignment_changed(Qt::AlignBottom); });
row_layout->addWidget(align_bottom_btn_);
AddSpacer(row_layout);
add_spacer(row_layout);
small_caps_btn_ = new QPushButton();
small_caps_btn_->setIcon(icon::TextSmallCaps);
small_caps_btn_->setIcon(icon::text_small_caps);
small_caps_btn_->setCheckable(true);
connect(small_caps_btn_, &QPushButton::clicked, this,
&ViewerTextEditorToolBar::SmallCapsChanged);
&ViewerTextEditorToolBar::small_caps_changed);
row_layout->addWidget(small_caps_btn_);
AddSpacer(row_layout);
add_spacer(row_layout);
row_layout->addWidget(
new QLabel(tr("Stretch: "))); // FIXME: Procure icon
stretch_slider_ = new IntegerSlider();
stretch_slider_->SetMinimum(0);
stretch_slider_->set_minimum(0);
stretch_slider_->SetDefaultValue(100);
stretch_slider_->setFixedWidth(advanced_slider_width);
stretch_slider_->SetFormat(tr("%1%"));
connect(stretch_slider_, &IntegerSlider::ValueChanged, this,
&ViewerTextEditorToolBar::StretchChanged);
stretch_slider_->set_format(tr("%1%"));
connect(stretch_slider_, &IntegerSlider::value_changed, this,
&ViewerTextEditorToolBar::stretch_changed);
row_layout->addWidget(stretch_slider_);
row_layout->addWidget(
new QLabel(tr("Kerning: "))); // FIXME: Procure icon
kerning_slider_ = new FloatSlider();
kerning_slider_->SetMinimum(0);
kerning_slider_->set_minimum(0);
kerning_slider_->SetDefaultValue(100);
kerning_slider_->SetDecimalPlaces(1);
kerning_slider_->set_decimal_places(1);
kerning_slider_->setFixedWidth(advanced_slider_width);
kerning_slider_->SetFormat(tr("%1%"));
connect(kerning_slider_, &FloatSlider::ValueChanged, this,
&ViewerTextEditorToolBar::KerningChanged);
kerning_slider_->set_format(tr("%1%"));
connect(kerning_slider_, &FloatSlider::value_changed, this,
&ViewerTextEditorToolBar::kerning_changed);
row_layout->addWidget(kerning_slider_);
row_layout->addWidget(
new QLabel(tr("Line Height: "))); // FIXME: Procure icon
line_height_slider_ = new FloatSlider();
line_height_slider_->SetMinimum(0);
line_height_slider_->set_minimum(0);
line_height_slider_->SetDefaultValue(100);
line_height_slider_->SetDecimalPlaces(1);
line_height_slider_->set_decimal_places(1);
line_height_slider_->setFixedWidth(advanced_slider_width);
line_height_slider_->SetFormat(tr("%1%"));
connect(line_height_slider_, &FloatSlider::ValueChanged, this,
&ViewerTextEditorToolBar::LineHeightChanged);
line_height_slider_->set_format(tr("%1%"));
connect(line_height_slider_, &FloatSlider::value_changed, this,
&ViewerTextEditorToolBar::line_height_changed);
row_layout->addWidget(line_height_slider_);
row_layout->addStretch();
@@ -538,7 +538,7 @@ ViewerTextEditorToolBar::ViewerTextEditorToolBar(QWidget *parent)
resize(sizeHint());
}
void ViewerTextEditorToolBar::SetAlignment(Qt::Alignment a)
void ViewerTextEditorToolBar::set_alignment(Qt::Alignment a)
{
align_left_btn_->setChecked(a == Qt::AlignLeft);
align_center_btn_->setChecked(a == Qt::AlignHCenter);
@@ -546,14 +546,14 @@ void ViewerTextEditorToolBar::SetAlignment(Qt::Alignment a)
align_justify_btn_->setChecked(a == Qt::AlignJustify);
}
void ViewerTextEditorToolBar::SetVerticalAlignment(Qt::Alignment a)
void ViewerTextEditorToolBar::set_vertical_alignment(Qt::Alignment a)
{
align_top_btn_->setChecked(a == Qt::AlignTop);
align_middle_btn_->setChecked(a == Qt::AlignVCenter);
align_bottom_btn_->setChecked(a == Qt::AlignBottom);
}
void ViewerTextEditorToolBar::SetColor(const QColor &c)
void ViewerTextEditorToolBar::set_color(const QColor &c)
{
color_btn_->setProperty("color", c);
color_btn_->setStyleSheet(
@@ -568,27 +568,27 @@ void ViewerTextEditorToolBar::closeEvent(QCloseEvent *event)
void ViewerTextEditorToolBar::paintEvent(QPaintEvent *event)
{
if (!painted_) {
emit FirstPaint();
emit first_paint();
painted_ = true;
}
QWidget::paintEvent(event);
}
void ViewerTextEditorToolBar::AddSpacer(QLayout *l)
void ViewerTextEditorToolBar::add_spacer(QLayout *l)
{
const int spacing = this->fontMetrics().height() / 4;
QWidget *a = new QWidget();
a->setFixedSize(spacing, 1);
l->addWidget(a);
l->addWidget(QtUtils::CreateVerticalLine());
l->addWidget(QtUtils::create_vertical_line());
QWidget *b = new QWidget();
b->setFixedSize(spacing, 1);
l->addWidget(b);
}
void ViewerTextEditorToolBar::UpdateFontStyleList(const QString &family)
void ViewerTextEditorToolBar::update_font_style_list(const QString &family)
{
QString temp = style_combo_->currentText();
@@ -602,12 +602,12 @@ void ViewerTextEditorToolBar::UpdateFontStyleList(const QString &family)
style_combo_->blockSignals(false);
}
void ViewerTextEditorToolBar::UpdateFontStyleListAndEmitFamilyChanged(
void ViewerTextEditorToolBar::update_font_style_list_and_emit_family_changed(
const QString &family)
{
// Ensures correct ordering of commands
UpdateFontStyleList(family);
emit FamilyChanged(family);
update_font_style_list(family);
emit family_changed(family);
}
void ViewerTextEditorToolBar::mousePressEvent(QMouseEvent *event)
+53 -53
View File
@@ -19,8 +19,8 @@
***/
#ifndef VIEWERTEXTEDITOR_H
#define VIEWERTEXTEDITOR_H
#ifndef OAK_VIEWERTEXTEDITOR_H
#define OAK_VIEWERTEXTEDITOR_H
#include <QApplication>
#include <QDebug>
@@ -39,79 +39,79 @@ class ViewerTextEditorToolBar : public QWidget {
public:
ViewerTextEditorToolBar(QWidget *parent = nullptr);
QString GetFontFamily() const
QString get_font_family() const
{
return font_combo_->currentText();
}
QString GetFontStyleName() const
QString get_font_style_name() const
{
return style_combo_->currentText();
}
public slots:
void SetFontFamily(QString s)
void set_font_family(QString s)
{
font_combo_->blockSignals(true);
font_combo_->setCurrentFont(s);
UpdateFontStyleList(s);
update_font_style_list(s);
font_combo_->blockSignals(false);
}
void SetStyle(QString style)
void set_style(QString style)
{
style_combo_->blockSignals(true);
style_combo_->setCurrentText(style);
style_combo_->blockSignals(false);
}
void SetFontSize(double d)
void set_font_size(double d)
{
font_sz_slider_->SetValue(d);
font_sz_slider_->set_value(d);
}
void SetUnderline(bool e)
void set_underline(bool e)
{
underline_btn_->setChecked(e);
}
void SetStrikethrough(bool e)
void set_strikethrough(bool e)
{
strikethrough_btn_->setChecked(e);
}
void SetAlignment(Qt::Alignment a);
void SetVerticalAlignment(Qt::Alignment a);
void SetColor(const QColor &c);
void SetSmallCaps(bool e)
void set_alignment(Qt::Alignment a);
void set_vertical_alignment(Qt::Alignment a);
void set_color(const QColor &c);
void set_small_caps(bool e)
{
small_caps_btn_->setChecked(e);
}
void SetStretch(int i)
void set_stretch(int i)
{
stretch_slider_->SetValue(i);
stretch_slider_->set_value(i);
}
void SetKerning(qreal i)
void set_kerning(qreal i)
{
kerning_slider_->SetValue(i);
kerning_slider_->set_value(i);
}
void SetLineHeight(qreal i)
void set_line_height(qreal i)
{
line_height_slider_->SetValue(i);
line_height_slider_->set_value(i);
}
signals:
void FamilyChanged(const QString &s);
void SizeChanged(double d);
void StyleChanged(const QString &s);
void UnderlineChanged(bool e);
void StrikethroughChanged(bool e);
void AlignmentChanged(Qt::Alignment alignment);
void VerticalAlignmentChanged(Qt::Alignment alignment);
void ColorChanged(const QColor &c);
void SmallCapsChanged(bool e);
void StretchChanged(int i);
void KerningChanged(qreal i);
void LineHeightChanged(qreal i);
void family_changed(const QString &s);
void size_changed(double d);
void style_changed(const QString &s);
void underline_changed(bool e);
void strikethrough_changed(bool e);
void alignment_changed(Qt::Alignment alignment);
void vertical_alignment_changed(Qt::Alignment alignment);
void color_changed(const QColor &c);
void small_caps_changed(bool e);
void stretch_changed(int i);
void kerning_changed(qreal i);
void line_height_changed(qreal i);
void FirstPaint();
void first_paint();
protected:
virtual void mousePressEvent(QMouseEvent *event) override;
@@ -125,7 +125,7 @@ protected:
virtual void paintEvent(QPaintEvent *event) override;
private:
void AddSpacer(QLayout *l);
void add_spacer(QLayout *l);
QPoint drag_anchor_;
@@ -159,9 +159,9 @@ private:
bool drag_enabled_;
private slots:
void UpdateFontStyleList(const QString &family);
void update_font_style_list(const QString &family);
void UpdateFontStyleListAndEmitFamilyChanged(const QString &family);
void update_font_style_list_and_emit_family_changed(const QString &family);
};
class ViewerTextEditor : public QTextEdit {
@@ -169,9 +169,9 @@ class ViewerTextEditor : public QTextEdit {
public:
ViewerTextEditor(double scale, QWidget *parent = nullptr);
void ConnectToolBar(ViewerTextEditorToolBar *toolbar);
void connect_tool_bar(ViewerTextEditorToolBar *toolbar);
void Paint(QPainter *p, Qt::Alignment valign);
void paint(QPainter *p, Qt::Alignment valign);
virtual void dragEnterEvent(QDragEnterEvent *e) override
{
@@ -194,14 +194,14 @@ protected:
virtual void paintEvent(QPaintEvent *event) override;
private:
static void UpdateToolBar(ViewerTextEditorToolBar *toolbar,
static void update_tool_bar(ViewerTextEditorToolBar *toolbar,
const QTextCharFormat &f,
const QTextBlockFormat &b,
Qt::Alignment alignment);
void MergeCharFormat(const QTextCharFormat &fmt);
void merge_char_format(const QTextCharFormat &fmt);
void ApplyStyle(QTextCharFormat *format, const QString &family,
void apply_style(QTextCharFormat *format, const QString &family,
const QString &style);
QVector<ViewerTextEditorToolBar *> toolbars_;
@@ -216,27 +216,27 @@ private:
QTextCharFormat default_fmt_;
private slots:
void FormatChanged(const QTextCharFormat &f);
void format_changed(const QTextCharFormat &f);
void SetFamily(const QString &s);
void set_family(const QString &s);
void SetStyle(const QString &s);
void set_style(const QString &s);
void SetFontStrikethrough(bool e);
void set_font_strikethrough(bool e);
void SetSmallCaps(bool e);
void set_small_caps(bool e);
void SetFontStretch(int i);
void set_font_stretch(int i);
void SetFontKerning(qreal i);
void set_font_kerning(qreal i);
void SetLineHeight(qreal i);
void set_line_height(qreal i);
void LockScrollBarMaximumToZero();
void lock_scroll_bar_maximum_to_zero();
void DocumentChanged();
void document_changed();
};
}
#endif // VIEWERTEXTEDITOR_H
#endif // OAK_VIEWERTEXTEDITOR_H
+9 -9
View File
@@ -44,28 +44,28 @@ ViewerDisplayWidget *ViewerWindow::display_widget() const
return display_widget_;
}
void ViewerWindow::SetVideoParams(const VideoParams &params)
void ViewerWindow::set_video_params(const VideoParams &params)
{
width_ = params.width();
height_ = params.height();
pixel_aspect_ = params.pixel_aspect_ratio();
UpdateMatrix();
update_matrix();
}
void ViewerWindow::SetResolution(int width, int height)
void ViewerWindow::set_resolution(int width, int height)
{
width_ = width;
height_ = height;
UpdateMatrix();
update_matrix();
}
void ViewerWindow::SetPixelAspectRatio(const rational &pixel_aspect)
void ViewerWindow::set_pixel_aspect_ratio(const Rational &pixel_aspect)
{
pixel_aspect_ = pixel_aspect;
UpdateMatrix();
update_matrix();
}
void ViewerWindow::keyPressEvent(QKeyEvent *e)
@@ -84,13 +84,13 @@ void ViewerWindow::closeEvent(QCloseEvent *e)
deleteLater();
}
void ViewerWindow::UpdateMatrix()
void ViewerWindow::update_matrix()
{
// Set GL widget matrix to maintain this texture's aspect ratio
double window_ar = static_cast<double>(this->width()) /
static_cast<double>(this->height());
double image_ar = static_cast<double>(width_) /
static_cast<double>(height_) * pixel_aspect_.toDouble();
static_cast<double>(height_) * pixel_aspect_.to_double();
QMatrix4x4 mat;
@@ -102,7 +102,7 @@ void ViewerWindow::UpdateMatrix()
mat.scale(1.0f, window_ar / image_ar, 1.0f);
}
display_widget_->SetMatrixZoom(mat);
display_widget_->set_matrix_zoom(mat);
}
}
+8 -8
View File
@@ -19,8 +19,8 @@
***/
#ifndef VIEWERWINDOW_H
#define VIEWERWINDOW_H
#ifndef OAK_VIEWERWINDOW_H
#define OAK_VIEWERWINDOW_H
#include <QWidget>
@@ -41,17 +41,17 @@ public:
* Equivalent to calling SetResolution and SetPixelAspectRatio, just slightly faster since we
* only calculate the matrix once rather than twice.
*/
void SetVideoParams(const VideoParams &params);
void set_video_params(const VideoParams &params);
/**
* @brief Used to adjust resulting picture to be the right aspect ratio
*/
void SetResolution(int width, int height);
void set_resolution(int width, int height);
/**
* @brief Used to adjust resulting picture to be the right aspect ratio
*/
void SetPixelAspectRatio(const rational &pixel_aspect);
void set_pixel_aspect_ratio(const Rational &pixel_aspect);
protected:
virtual void keyPressEvent(QKeyEvent *e) override;
@@ -59,7 +59,7 @@ protected:
virtual void closeEvent(QCloseEvent *e) override;
private:
void UpdateMatrix();
void update_matrix();
int width_;
@@ -67,9 +67,9 @@ private:
ViewerDisplayWidget *display_widget_;
rational pixel_aspect_;
Rational pixel_aspect_;
};
}
#endif // VIEWERWINDOW_H
#endif // OAK_VIEWERWINDOW_H