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

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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
/*
 * Copyright (C) 2011-2013 Canonical Ltd
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 3 as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Authored by: Jason Smith <jason.smith@canonical.com>
 */

#ifndef SWITCHERCONTROLLER_H
#define SWITCHERCONTROLLER_H

#include <memory>
#include <string>
#include <sigc++/connection.h>

#include "AbstractLauncherIcon.h"
#include <Nux/Nux.h>
#include "unity-shared/Introspectable.h"
#include "unity-shared/LayoutSystem.h"


namespace unity
{
namespace switcher
{

class SwitcherView;

enum class SortMode
{
  LAUNCHER_ORDER,
  FOCUS_ORDER,
};

enum class ShowMode
{
  ALL,
  CURRENT_VIEWPORT,
};

enum class DetailMode
{
  TAB_NEXT_WINDOW,
  TAB_NEXT_WINDOW_LOOP,
  TAB_NEXT_TILE,
};

enum class FirstSelectionMode
{
  LAST_ACTIVE_VIEW,
  LAST_ACTIVE_APP
};

/**
 * Represents a selected application+window to be switched to.
 */
struct Selection
{
  launcher::AbstractLauncherIcon::Ptr application_;
  Window                              window_;
};


class Controller : public debug::Introspectable, public sigc::trackable
{
public:
  class Impl;
  typedef std::function<nux::ObjectPtr<nux::BaseWindow>()> WindowCreator;
  typedef std::unique_ptr<Impl> ImplPtr;
  typedef std::shared_ptr<Controller> Ptr;

public:
  Controller(WindowCreator const& create_window = nullptr);

  ~Controller();

  void Show(ShowMode show,
            SortMode sort,
            std::vector<launcher::AbstractLauncherIcon::Ptr> const& results);
  void Hide(bool accept_state=true);

  bool CanShowSwitcher(std::vector<launcher::AbstractLauncherIcon::Ptr> const& resutls) const;
  void AddIcon(launcher::AbstractLauncherIcon::Ptr const&);
  void RemoveIcon(launcher::AbstractLauncherIcon::Ptr const&);

  bool Visible();
  nux::Geometry GetInputWindowGeometry() const;

  void Next();
  void Prev();

  void InitiateDetail();
  void NextDetail();
  void PrevDetail();

  void Select(int index);

  bool IsDetailViewShown();
  void SetDetail(bool detail,
                 unsigned int min_windows = 1);

  void SelectFirstItem();

  nux::ObjectPtr<SwitcherView> GetView() const;

  ui::LayoutWindow::Vector const& ExternalRenderTargets() const;

  int StartIndex() const;
  double Opacity() const;

  Selection GetCurrentSelection() const;

  sigc::connection ConnectToViewBuilt(sigc::slot<void> const&);

  // Introspectable methods
  std::string GetName() const;
  void AddProperties(debug::IntrospectionData&);

  nux::RWProperty<bool> detail;
  nux::ROProperty<DetailMode> detail_mode;
  nux::Property<FirstSelectionMode> first_selection_mode;
  nux::Property<bool> show_desktop_disabled;
  nux::Property<bool> mouse_disabled;
  nux::Property<int>  timeout_length;
  nux::Property<bool> detail_on_timeout;
  nux::Property<int>  detail_timeout_length;
  nux::Property<int>  initial_detail_timeout_length;

private:
  bool       visible_;
  int        monitor_;
  DetailMode detail_mode_;

  ImplPtr    impl_;
};

}
}

#endif // SWITCHERCONTROLLER_H