~ken-vandine/unity/make-quicklists-work-again

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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#ifndef LAUNCHER_H
#define LAUNCHER_H

#include <Nux/View.h>
#include <Nux/BaseWindow.h>
#include "LauncherIcon.h"
#include "NuxGraphics/IOpenGLAsmShader.h"
#include "Nux/TimerProc.h"

class LauncherModel;

class Launcher : public nux::View
{
public:
    Launcher(NUX_FILE_LINE_PROTO);
    ~Launcher();

    virtual long ProcessEvent(nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
    virtual void Draw(nux::GraphicsContext& GfxContext, bool force_draw);
    virtual void DrawContent(nux::GraphicsContext& GfxContext, bool force_draw);
    virtual void PostDraw(nux::GraphicsContext& GfxContext, bool force_draw);

    LauncherIcon* GetActiveTooltipIcon() {return m_ActiveTooltipIcon;}
    LauncherIcon* GetActiveMenuIcon() {return m_ActiveMenuIcon;}

    bool TooltipNotify(LauncherIcon* Icon);
    bool MenuNotify(LauncherIcon* Icon);
    
    void SetIconSize(int tile_size, int icon_size, nux::BaseWindow *parent);
    void NotifyMenuTermination(LauncherIcon* Icon);
    
    void SetModel (LauncherModel *model);
    
    virtual void RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags);
    virtual void RecvMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
    virtual void RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
    virtual void RecvMouseEnter(int x, int y, unsigned long button_flags, unsigned long key_flags);
    virtual void RecvMouseLeave(int x, int y, unsigned long button_flags, unsigned long key_flags);
    virtual void RecvMouseMove(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
    virtual void RecvMouseWheel(int x, int y, int wheel_delta, unsigned long button_flags, unsigned long key_flags);

private:
  typedef enum
  {
    LAUNCHER_FOLDED,
    LAUNCHER_UNFOLDED
  } LauncherState;

  typedef enum
  {
    ACTION_NONE,
    ACTION_DRAG_LAUNCHER,
    ACTION_DRAG_ICON,
  } LauncherActionState;

  void OnIconAdded (void *icon_pointer);
  void OnIconRemoved (void *icon_pointer);
  void OnOrderChanged ();


  void OnIconNeedsRedraw (void *icon);

  void FoldingCallback(void* v);
  void RevealCallback(void* v);

  void RenderIcon (nux::GraphicsContext& GfxContext, LauncherIcon* launcher_view);
  void RenderIconImage(nux::GraphicsContext& GfxContext, LauncherIcon* launcher_view);
  void UpdateIconXForm ();
  LauncherIcon* MouseIconIntersection (int x, int y);
  void EventLogic ();
  void MouseDownLogic ();
  void MouseUpLogic ();

  void SlideDown(float stepy, int mousedy);
  void SlideUp(float stepy, int mousedy);

  virtual void PreLayoutManagement();
  virtual long PostLayoutManagement(long LayoutResult);
  virtual void PositionChildLayout(float offsetX, float offsetY);

  void OrderRevealedIcons();
  void OrderFoldedIcons(int FocusIconIndex);
  void ScheduleRevealAnimation ();
  void ScheduleFoldAnimation ();

  nux::HLayout* m_Layout;
  int m_ContentOffsetY;

  LauncherIcon* m_ActiveTooltipIcon;
  LauncherIcon* m_ActiveMenuIcon;

  float _folding_angle;
  float _angle_rate;
  float _timer_intervals;
  int   _space_between_icons;
  int   _anim_duration;
  float _folded_angle;
  float _neg_folded_angle;
  float _folded_z_distance;
  float _launcher_top_y;
  float _launcher_bottom_y;
  LauncherState _launcher_state;
  LauncherActionState _launcher_action_state;
  LauncherIcon* _icon_under_mouse;
  LauncherIcon* _icon_mouse_down;
  int _icon_size;
  int _icon_image_size;
  int _icon_image_size_delta;
  nux::BaseTexture* _icon_bkg_texture;
  nux::BaseTexture* _icon_outline_texture;
  int _dnd_delta;
  int _dnd_security;

  nux::TimerFunctor* _folding_functor;
  nux::TimerHandle _folding_timer_handle;
  nux::TimerFunctor* _reveal_functor;
  nux::TimerHandle _reveal_timer_handle;

  nux::Matrix4  _view_matrix;
  nux::Matrix4  _projection_matrix;
  nux::Point2   _mouse_position;
  nux::IntrusiveSP<nux::IOpenGLShaderProgram>    _shader_program_uv_persp_correction;
  nux::IntrusiveSP<nux::IOpenGLAsmShaderProgram> _AsmShaderProg;
  nux::BaseTexture* m_RunningIndicator;
  nux::BaseTexture* m_ActiveIndicator;
  nux::AbstractPaintLayer* m_BackgroundLayer;
  LauncherModel* _model;
};

#endif // LAUNCHER_H