aboutsummaryrefslogtreecommitdiff
path: root/src/components/Scrollbar.hpp
blob: 5caba75e2048019b7c53afa4743939413ea5bb33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "Component.hpp"
#include <algorithm>    // std::max
#include <cmath>

namespace cgeditor {
class Scrollbar : public Component {
  /// @brief Set to true if it is the horizontal scrollbar
  bool IsHorizontal;
  Element bg,bar;
  double DragY,DragX;
  double FocusX,FocusY;
  /// @brief Should focus be applied on the next draw
  bool ShouldApplyFocus;
  /// @brief Use to detect scrollbar drags
  bool Trigger;
  /// @brief Goto a given graphical coordinate (if possible using current scroll range)
  void ApplyFocus();
public:
  Scrollbar(Status* s,bool IsHorizontal);
  void Refresh();
  /// @brief Focus on a coordinate on the next draw
  void Focus(double XorY);
  /// @brief Undo all scroll operations, go back to the origin
  void Reset();
};
} // namespace cgeditor