Pencil2D Animation
Download Community News Docs Contribute
  • Overview
  • Articles
  • Code
  •  
  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • File List
Loading...
Searching...
No Matches
  • app
  • src
cameraoptionswidget.cpp
1/*
2
3Pencil2D - Traditional Animation Software
4Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
5Copyright (C) 2012-2020 Matthew Chiawen Chang
6
7This program is free software; you can redistribute it and/or
8modify it under the terms of the GNU General Public License
9as published by the Free Software Foundation; version 2 of the License.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16*/
17#include "cameraoptionswidget.h"
18#include "ui_cameraoptionswidget.h"
19
20#include "editor.h"
21#include "toolmanager.h"
22#include "layermanager.h"
23
24#include "cameratool.h"
25
26CameraOptionsWidget::CameraOptionsWidget(Editor* editor, QWidget *parent) :
27 BaseWidget(parent),
28 ui(new Ui::CameraOptionsWidget), mEditor(editor)
29{
30 ui->setupUi(this);
31
32 initUI();
33}
34
35CameraOptionsWidget::~CameraOptionsWidget()
36{
37 delete ui;
38}
39
40void CameraOptionsWidget::initUI()
41{
42 auto toolMan = mEditor->tools();
43 mCameraTool = static_cast<CameraTool*>(toolMan->getTool(CAMERA));
44
45 makeConnectionsFromUIToModel();
46 makeConnectionsFromModelToUI();
47}
48
49void CameraOptionsWidget::updateUI()
50{
51 Q_ASSERT(mCameraTool->type() == CAMERA);
52
53 const CameraToolProperties p = mCameraTool->settings();
54
55 setShowCameraPath(p.showPathEnabled());
56 setPathDotColorType(p.dotColorType());
57}
58
59void CameraOptionsWidget::makeConnectionsFromModelToUI()
60{
61 connect(mCameraTool, &CameraTool::cameraPathEnabledChanged, this, [=](bool enabled) {
62 setShowCameraPath(enabled);
63 });
64
65 connect(mCameraTool, &CameraTool::pathColorChanged, this, [=](DotColorType type) {
66 setPathDotColorType(type);
67 });
68}
69
70void CameraOptionsWidget::makeConnectionsFromUIToModel()
71{
72 connect(ui->showCameraPathCheckBox, &QCheckBox::clicked, [=](bool enabled) {
73 mCameraTool->setCameraPathEnabled(enabled);
74 });
75
76 connect(ui->pathColorComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [=](int value) {
77 mCameraTool->setPathDotColorType(static_cast<DotColorType>(value));
78 });
79
80 connect(ui->btnResetPath, &QPushButton::clicked, [=]() {
81 mCameraTool->performAction(CameraTool::RESET_PATH);
82 });
83
84 connect(ui->resetAllButton, &QPushButton::clicked, [=] {
85 mCameraTool->performAction(CameraTool::RESET_FIELD);
86 });
87 connect(ui->resetTranslationButton, &QPushButton::clicked, [=] {
88 mCameraTool->performAction(CameraTool::RESET_TRANSLATION);
89 });
90 connect(ui->resetRotationButton, &QPushButton::clicked, [=] {
91 mCameraTool->performAction(CameraTool::RESET_ROTATION);
92 });
93 connect(ui->resetScaleButton, &QPushButton::clicked, [=] {
94 mCameraTool->performAction(CameraTool::RESET_SCALING);
95 });
96}
97
98void CameraOptionsWidget::setShowCameraPath(bool showCameraPath)
99{
100 QSignalBlocker b(ui->showCameraPathCheckBox);
101 ui->showCameraPathCheckBox->setChecked(showCameraPath);
102}
103
104void CameraOptionsWidget::setPathDotColorType(DotColorType index)
105{
106 QSignalBlocker b(ui->pathColorComboBox);
107 ui->pathColorComboBox->setCurrentIndex(static_cast<int>(index));
108}
BaseWidget
Definition: basewidget.h:24
CameraOptionsWidget
Definition: cameraoptionswidget.h:33
CameraTool
Definition: cameratool.h:45
Editor
Definition: editor.h:71
QAbstractButton::clicked
void clicked(bool checked)
QComboBox
QComboBox::currentIndexChanged
void currentIndexChanged(int index)
QObject::connect
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QSignalBlocker
QWidget
QWidget::enabled
enabled
QWidget::setupUi
void setupUi(QWidget *widget)
CameraToolProperties
Definition: toolproperties.h:539
Generated on Wed Dec 24 2025 23:46:01 for Pencil2D by doxygen 1.9.6 based on revision 1be63043db1f7fc0545528fc3b6d5098a552755b