1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-22 15:23:58 +00:00
openmw/apps/opencs/view/render/orbitcameramode.cpp

61 lines
1.6 KiB
C++
Raw Normal View History

2016-04-03 20:32:07 +00:00
#include "orbitcameramode.hpp"
#include <QMenu>
2022-10-19 17:02:00 +00:00
#include <memory>
#include "../../model/prefs/shortcut.hpp"
2022-10-19 17:02:00 +00:00
#include <apps/opencs/view/widget/modebutton.hpp>
2016-04-03 20:32:07 +00:00
#include "worldspacewidget.hpp"
2022-10-19 17:02:00 +00:00
namespace CSVWidget
{
class SceneToolbar;
}
2016-04-03 20:32:07 +00:00
namespace CSVRender
{
2022-09-22 18:26:05 +00:00
OrbitCameraMode::OrbitCameraMode(
WorldspaceWidget* worldspaceWidget, const QIcon& icon, const QString& tooltip, QWidget* parent)
2016-04-03 20:32:07 +00:00
: ModeButton(icon, tooltip, parent)
, mWorldspaceWidget(worldspaceWidget)
2020-11-13 07:39:47 +00:00
, mCenterOnSelection(nullptr)
2016-04-03 20:32:07 +00:00
{
2016-08-08 18:36:50 +00:00
mCenterShortcut = new CSMPrefs::Shortcut("orbit-center-selection", worldspaceWidget);
mCenterShortcut->enable(false);
2022-09-22 18:26:05 +00:00
connect(mCenterShortcut, qOverload<>(&CSMPrefs::Shortcut::activated), this, &OrbitCameraMode::centerSelection);
}
2016-04-03 20:32:07 +00:00
void OrbitCameraMode::activate(CSVWidget::SceneToolbar* toolbar)
{
mCenterOnSelection = new QAction("Center on selected object", this);
mCenterShortcut->associateAction(mCenterOnSelection);
connect(mCenterOnSelection, &QAction::triggered, this, &OrbitCameraMode::centerSelection);
mCenterShortcut->enable(true);
}
void OrbitCameraMode::deactivate(CSVWidget::SceneToolbar* toolbar)
{
2020-11-13 07:39:47 +00:00
mCenterShortcut->associateAction(nullptr);
mCenterShortcut->enable(false);
2016-04-03 20:32:07 +00:00
}
bool OrbitCameraMode::createContextMenu(QMenu* menu)
{
if (menu)
{
menu->addAction(mCenterOnSelection);
}
return true;
}
void OrbitCameraMode::centerSelection()
{
mWorldspaceWidget->centerOrbitCameraOnSelection();
}
}