Files
oak-editor/app/widget/manageddisplay/manageddisplay.h
T
Mike-Solar bb40b4923e 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.
2026-07-19 16:10:54 +08:00

356 lines
7.7 KiB
C++

/***
Olive - Non-Linear Video Editor
Copyright (C) 2022 Olive Team
Modifications Copyright (C) 2025 mikesolar
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/>.
***/
#ifndef OAK_MANAGEDDISPLAYOBJECT_H
#define OAK_MANAGEDDISPLAYOBJECT_H
//#define USE_QOPENGLWINDOW
#include <QMouseEvent>
#include <QOpenGLContext>
#ifdef USE_QOPENGLWINDOW
#include <QOpenGLWindow>
#else
#include <QOpenGLWidget>
#endif
#include "node/color/colormanager/colormanager.h"
#include "render/renderer.h"
#include "widget/menu/menu.h"
namespace olive
{
class ManagedDisplayWidgetOpenGL
#ifdef USE_QOPENGLWINDOW
: public QOpenGLWindow
#else
: public QOpenGLWidget
#endif
{
Q_OBJECT
public:
ManagedDisplayWidgetOpenGL() = default;
virtual ~ManagedDisplayWidgetOpenGL() override
{
if (context()) {
destroy_listener();
disconnect(context(), &QOpenGLContext::aboutToBeDestroyed, this,
&ManagedDisplayWidgetOpenGL::destroy_listener);
}
}
signals:
// Render signals
void on_init();
void on_paint();
void on_destroy();
protected:
virtual void initializeGL() override
{
connect(context(), &QOpenGLContext::aboutToBeDestroyed, this,
&ManagedDisplayWidgetOpenGL::destroy_listener,
Qt::DirectConnection);
emit on_init();
}
virtual void paintGL() override
{
emit on_paint();
}
private slots:
void destroy_listener()
{
makeCurrent();
emit on_destroy();
doneCurrent();
}
};
#define MANAGEDDISPLAYWIDGET_DEFAULT_DESTRUCTOR_INNER \
make_current(); \
on_destroy(); \
done_current()
#define MANAGEDDISPLAYWIDGET_DEFAULT_DESTRUCTOR(x) \
virtual ~x() override \
{ \
MANAGEDDISPLAYWIDGET_DEFAULT_DESTRUCTOR_INNER; \
}
/**
* @brief Inner widget for backend-neutral rendering paths (e.g. Vulkan).
*
* It does not own a GL context; instead it forwards Qt paint events to the
* ManagedDisplayWidget so that the viewer can render via QPainter.
*/
class ManagedDisplayWidgetBackendNeutral : public QWidget {
Q_OBJECT
public:
ManagedDisplayWidgetBackendNeutral(QWidget *parent = nullptr)
: QWidget(parent)
{
}
signals:
void on_paint();
protected:
virtual void paintEvent(QPaintEvent *event) override
{
QWidget::paintEvent(event);
emit on_paint();
}
};
class ManagedDisplayWidget : public QWidget {
Q_OBJECT
public:
ManagedDisplayWidget(QWidget *parent = nullptr);
virtual ~ManagedDisplayWidget() override;
/**
* @brief Disconnect a ColorManager (equivalent to ConnectColorManager(nullptr))
*/
void disconnect_color_manager();
/**
* @brief Access currently connected ColorManager (nullptr if none)
*/
ColorManager *color_manager() const;
/**
* @brief Get current color transform
*/
const ColorTransform &get_color_transform() const;
/**
* @brief Get menu that can be used to select the colorspace
*/
Menu *get_color_space_menu(QMenu *parent, bool auto_connect = true);
/**
* @brief Get menu that can be used to select the display transform
*/
Menu *get_display_menu(QMenu *parent, bool auto_connect = true);
/**
* @brief Get menu that can be used to select the view transform
*/
Menu *get_view_menu(QMenu *parent, bool auto_connect = true);
/**
* @brief Get menu that can be used to select the look transform
*/
Menu *get_look_menu(QMenu *parent, bool auto_connect = true);
/**
* @brief Passes update signal through to inner widget
*/
void update();
virtual bool eventFilter(QObject *o, QEvent *e) override;
public slots:
/**
* @brief Replaces the color transform with a new one
*/
void set_color_transform(const ColorTransform &transform);
/**
* @brief Connect a ColorManager (ColorManagers usually belong to the Project)
*/
void connect_color_manager(ColorManager *color_manager);
signals:
/**
* @brief Emitted when the color processor changes
*/
void color_processor_changed(ColorProcessorPtr processor);
/**
* @brief Emitted when a new color manager is connected
*/
void color_manager_changed(ColorManager *color_manager);
void frame_swapped();
protected:
/**
* @brief Provides access to the color processor (nullptr if none is set)
*/
ColorProcessorPtr color_service();
/**
* @brief Enables a context menu that allows simple access to the DVL pipeline
*/
void enable_default_context_menu();
/**
* @brief Function called whenever the processor changes
*
* Default functionality is just to call update()
*/
virtual void ColorProcessorChangedEvent();
Renderer *renderer() const
{
return attached_renderer_;
}
void make_current();
void done_current();
#ifdef USE_QOPENGLWINDOW
QWindow *
#else
QWidget *
#endif
inner_widget() const
{
return inner_widget_;
}
/**
* @brief Get inner widget as paint device for QPainter
*
* NOTE: This will be incompatible with QVulkanWindow so functions using it
* will need to be replaced soon.
*/
QPaintDevice *paint_device() const;
void set_inner_mouse_tracking(bool e);
bool is_backend_neutral() const
{
return is_backend_neutral_;
}
QRect get_inner_rect() const
{
return wrapper_ ? wrapper_->rect() : QRect();
}
VideoParams get_viewport_params() const;
protected slots:
/**
* @brief Called whenever the internal rendering context has been created
*/
virtual void on_init();
/**
* @brief Called while the internal rendering context is being rendered
*/
virtual void on_paint() = 0;
/**
* @brief Called just before the internal rendering context is destroyed
*/
virtual void on_destroy();
private:
/**
* @brief Call this if this user has selected a different display/view/look to recreate the processor
*/
void setup_color_processor();
/**
* @brief Cleanup function
*/
void clear_ocio_lut_texture();
/**
* @brief Main drawing surface abstraction
*/
#ifdef USE_QOPENGLWINDOW
QWindow *inner_widget_;
#else
QWidget *inner_widget_;
#endif
QWidget *wrapper_;
/**
* @brief Renderer abstraction
*/
Renderer *attached_renderer_;
/**
* @brief Connected color manager
*/
ColorManager *color_manager_;
/**
* @brief Color management service
*/
ColorProcessorPtr color_service_;
/**
* @brief Internal color transform storage
*/
ColorTransform color_transform_;
bool is_backend_neutral_ = false;
private slots:
/**
* @brief Sets all color settings to the defaults pertaining to this configuration
*/
void color_config_changed();
/**
* @brief The default context menu shown
*/
void show_default_context_menu();
/**
* @brief If GetDisplayMenu() is called with `auto_connect` set to true, it will be connected to this
*/
void menu_display_select(QAction *action);
/**
* @brief If GetViewMenu() is called with `auto_connect` set to true, it will be connected to this
*/
void menu_view_select(QAction *action);
/**
* @brief If GetLookMenu() is called with `auto_connect` set to true, it will be connected to this
*/
void menu_look_select(QAction *action);
/**
* @brief If GetColorSpaceMenu() is called with `auto_connect` set to true, it will be connected to this
*/
void menu_colorspace_select(QAction *action);
};
}
#endif // OAK_MANAGEDDISPLAYOBJECT_H