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 QWidget(parent),
28 ui(new Ui::CameraOptionsWidget), mEditor(editor)
29{
30 ui->setupUi(this);
31
32 auto toolMan = mEditor->tools();
33 connect(ui->showCameraPathCheckBox, &QCheckBox::clicked, toolMan, &ToolManager::setShowCameraPath);
34 connect(ui->pathColorComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), toolMan, &ToolManager::setCameraPathDotColor);
35 connect(ui->btnResetPath, &QPushButton::clicked, toolMan, &ToolManager::resetCameraPath);
36
37 connect(ui->resetAllButton, &QPushButton::clicked, toolMan, [=] {
38 toolMan->resetCameraTransform(CameraFieldOption::RESET_FIELD);
39 });
40 connect(ui->resetTranslationButton, &QPushButton::clicked, toolMan, [=] {
41 toolMan->resetCameraTransform(CameraFieldOption::RESET_TRANSLATION);
42 });
43 connect(ui->resetRotationButton, &QPushButton::clicked, toolMan, [=] {
44 toolMan->resetCameraTransform(CameraFieldOption::RESET_ROTATION);
45 });
46 connect(ui->resetScaleButton, &QPushButton::clicked, toolMan, [=] {
47 toolMan->resetCameraTransform(CameraFieldOption::RESET_SCALING);
48 });
49
50 connect(toolMan, &ToolManager::toolPropertyChanged, this, &CameraOptionsWidget::onToolPropertyChanged);
51
52 connect(mEditor->layers(), &LayerManager::currentLayerChanged, this, &CameraOptionsWidget::updateUI);
53 connect(mEditor->tools(), &ToolManager::toolChanged, this, &CameraOptionsWidget::updateUI);
54
55 mCameraTool = static_cast<CameraTool*>(mEditor->tools()->getTool(CAMERA));
56}
57
58CameraOptionsWidget::~CameraOptionsWidget()
59{
60 delete ui;
61}
62
63void CameraOptionsWidget::updateUI()
64{
65
66 Q_ASSERT(mCameraTool->type() == CAMERA);
67
68 Properties p = mCameraTool->properties;
69
70 setShowCameraPath(p.cameraShowPath);
71 setPathDotColorType(p.cameraPathDotColorType);
72}
73
74void CameraOptionsWidget::onToolPropertyChanged(ToolType, ToolPropertyType ePropertyType)
75{
76 const Properties& p = mCameraTool->properties;
77
78 switch (ePropertyType)
79 {
80 case CAMERAPATH: { setShowCameraPath(p.cameraShowPath); break; }
81 default:
82 break;
83 }
84}
85
86void CameraOptionsWidget::setShowCameraPath(bool showCameraPath)
87{
88 QSignalBlocker b(ui->showCameraPathCheckBox);
89 ui->showCameraPathCheckBox->setChecked(showCameraPath);
90}
91
92void CameraOptionsWidget::setPathDotColorType(DotColorType index)
93{
94 QSignalBlocker b(ui->pathColorComboBox);
95 ui->pathColorComboBox->setCurrentIndex(static_cast<int>(index));
96}
CameraOptionsWidget
Definition: cameraoptionswidget.h:33
CameraTool
Definition: cameratool.h:45
Editor
Definition: editor.h:71
Properties
Definition: basetool.h:39
QAbstractButton::clicked
void clicked(bool checked)
QComboBox
QComboBox::currentIndexChanged
void currentIndexChanged(int index)
QSignalBlocker
QWidget
QWidget::setupUi
void setupUi(QWidget *widget)
Generated on Thu May 8 2025 04:47:53 for Pencil2D by doxygen 1.9.6 based on revision 4513250b1d5b1a3676ec0e67b06b7a885ceaae39