~3v1n0/unity/scale-window-cast-protection

« back to all changes in this revision

Viewing changes to unity-shared/VScrollBarOverlayWindow.h

  • Committer: Marco Trevisan (Treviño)
  • Date: 2016-03-07 18:51:47 UTC
  • mfrom: (4080 unity)
  • mto: This revision was merged to the branch mainline in revision 4085.
  • Revision ID: mail@3v1n0.net-20160307185147-0p1m89up4tqfb6w1
Merge with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2
 
/*
3
 
 * Copyright (C) 2012 Canonical Ltd
4
 
 *
5
 
 * This program is free software: you can redistribute it and/or modify
6
 
 * it under the terms of the GNU General Public License version 3 as
7
 
 * published by the Free Software Foundation.
8
 
 *
9
 
 * This program is distributed in the hope that it will be useful,
10
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 
 * GNU General Public License for more details.
13
 
 *
14
 
 * You should have received a copy of the GNU General Public License
15
 
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
 
 *
17
 
 * Authored by: Brandon Schaefer <brandon.schaefer@canonical.com>
18
 
 */
19
 
 
20
 
 
21
 
#ifndef VSCROLLBAR_OVERLAY_WINDOW_H
22
 
#define VSCROLLBAR_OVERLAY_WINDOW_H
23
 
 
24
 
#include <Nux/Nux.h>
25
 
#include <Nux/BaseWindow.h>
26
 
#include <NuxCore/Animation.h>
27
 
 
28
 
namespace unity
29
 
{
30
 
 
31
 
class VScrollBarOverlayWindow : public nux::BaseWindow
32
 
{
33
 
public:
34
 
  VScrollBarOverlayWindow(nux::Geometry const& geo);
35
 
 
36
 
  nux::Property<double> scale;
37
 
 
38
 
  void UpdateGeometry(nux::Geometry const& geo);
39
 
  void SetThumbOffsetY(int y);
40
 
 
41
 
  void MouseDown();
42
 
  void MouseUp();
43
 
 
44
 
  void MouseNear();
45
 
  void MouseBeyond();
46
 
 
47
 
  void MouseEnter();
48
 
  void MouseLeave();
49
 
 
50
 
  void ThumbInsideSlider();
51
 
  void ThumbOutsideSlider();
52
 
 
53
 
  void PageUpAction();
54
 
  void PageDownAction();
55
 
  
56
 
  bool IsMouseInsideThumb(int y) const;
57
 
  bool IsMouseBeingDragged() const;
58
 
 
59
 
  int GetThumbHeight() const;
60
 
  int GetThumbOffsetY() const;
61
 
 
62
 
  nux::Geometry GetThumbGeometry() const;
63
 
 
64
 
  void ResetStates();
65
 
 
66
 
protected:
67
 
  virtual void Draw(nux::GraphicsEngine& graphics_engine, bool force_draw);
68
 
 
69
 
private:
70
 
  enum class ThumbAction : unsigned int
71
 
  {
72
 
    NONE,
73
 
    DRAGGING,
74
 
    PAGE_UP,
75
 
    PAGE_DOWN
76
 
  };
77
 
 
78
 
  enum ThumbState
79
 
  {
80
 
    NONE          = 1 << 0,
81
 
    MOUSE_DOWN    = 1 << 1,
82
 
    MOUSE_NEAR    = 1 << 2,
83
 
    MOUSE_INSIDE  = 1 << 3,
84
 
    INSIDE_SLIDER = 1 << 4
85
 
  };
86
 
 
87
 
  void MouseDragging();
88
 
  void UpdateMouseOffsetX();
89
 
  void UpdateContentGeometry();
90
 
  int GetValidOffsetYValue(int y) const;
91
 
 
92
 
  void ShouldShow();
93
 
  void ShouldHide();
94
 
 
95
 
  void UpdateTexture();
96
 
 
97
 
  nux::Geometry content_size_;
98
 
  nux::ObjectPtr<nux::BaseTexture> thumb_texture_;
99
 
  
100
 
  int content_offset_x_;
101
 
  int mouse_offset_y_;
102
 
 
103
 
  void AddState(ThumbState const& state);
104
 
  void RemoveState(ThumbState const& state);
105
 
  bool HasState(ThumbState const& state) const;
106
 
  
107
 
  unsigned int current_state_;
108
 
  ThumbAction current_action_;
109
 
  nux::animation::AnimateValue<double> show_animator_;
110
 
};
111
 
 
112
 
} // namespace unity
113
 
 
114
 
#endif // VSCROLLBAR_OVERLAY_WINDOW_H