GaitGeneration by Graph Search
読み取り中…
検索中…
一致する文字列を見つけられません
camera_dragger.h
[詳解]
1
3
4// Copyright(c) 2023-2025 Design Engineering Laboratory, Saitama University
5// Released under the MIT license
6// https://opensource.org/licenses/mit-license.php
7
8#ifndef DESIGNLAB_CAMERA_DRAGGER_H_
9#define DESIGNLAB_CAMERA_DRAGGER_H_
10
11#include <memory>
12
13#include "dxlib_camera.h"
16
17
18namespace designlab
19{
20
24{
25public:
27 explicit CameraDragger(const std::shared_ptr<DxlibCamera> camera);
28
30 [[maybe_unused]] int cursor_x,
31 [[maybe_unused]] int cursor_y) const override
32 {
33 // カメラの操作はどこをクリックしても可能.
34 return true;
35 };
36
37 bool IsDragged() const override { return is_dragged_; };
38
39 void SetDragged(bool is_dragged) override { is_dragged_ = is_dragged; };
40
41 void DraggedAction(
42 int cursor_dif_x, int cursor_dif_y,
43 unsigned int mouse_key_bit) override;
44
46 [[maybe_unused]] int cursor_x,
47 [[maybe_unused]] int cursor_y) const override
48 {
49 // カメラの操作はどこをクリックしても可能.
50 return true;
51 };
52
53 void RotMouseWheel(int rot) const override;
54
55private:
56 const float kCameraZoomSpeed{ 50.f };
57
58 const float kCameraMoveSpeed{ 0.007f };
59
60 const float kCameraTargetMoveSpeed{ 3.f };
61
63 const double kMouseMoveMargin{ 0.5 };
64
66 const std::shared_ptr<DxlibCamera> camera_ptr_;
67
68 bool is_dragged_{ false };
69};
70
71} // namespace designlab
72
73
74#endif // DESIGNLAB_CAMERA_DRAGGER_H_
マウスの入力でカメラを動かすクラス.
void SetDragged(bool is_dragged) override
ドラッグ中かどうかを設定する.
bool IsDraggable(int cursor_x, int cursor_y) const override
ドラッグ可能な位置にあるかを判定する.
bool CanHandleWheel(int cursor_x, int cursor_y) const override
マウスホイールが回転したときの処理を行うかどうかを判定する.
bool IsDragged() const override
ドラッグ中かどうかを取得する.
void DraggedAction(int cursor_dif_x, int cursor_dif_y, unsigned int mouse_key_bit) override
ドラッグ中の処理を行う. カーソルは上にあるけど,ドラッグ中ではない場合でも呼び出される.
void RotMouseWheel(int rot) const override
マウスホイールが回転したときの処理を行う. マウスホイールが回転したときに呼び出される.
ドラッグ可能なGUIのインターフェース.
マウスホイールの入力を受け取るためのインターフェース.