// -*- 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 .
*
* Authored by: Jason Smith
*/
#ifndef SWITCHERCONTROLLER_H
#define SWITCHERCONTROLLER_H
#include
#include
#include
#include "AbstractLauncherIcon.h"
#include
#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()> WindowCreator;
typedef std::unique_ptr ImplPtr;
typedef std::shared_ptr Ptr;
public:
Controller(WindowCreator const& create_window = nullptr);
~Controller();
void Show(ShowMode show,
SortMode sort,
std::vector const& results);
void Hide(bool accept_state=true);
bool CanShowSwitcher(std::vector 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 GetView() const;
ui::LayoutWindow::Vector const& ExternalRenderTargets() const;
int StartIndex() const;
double Opacity() const;
Selection GetCurrentSelection() const;
sigc::connection ConnectToViewBuilt(sigc::slot const&);
// Introspectable methods
std::string GetName() const;
void AddProperties(debug::IntrospectionData&);
nux::RWProperty detail;
nux::ROProperty detail_mode;
nux::Property first_selection_mode;
nux::Property show_desktop_disabled;
nux::Property mouse_disabled;
nux::Property timeout_length;
nux::Property detail_on_timeout;
nux::Property detail_timeout_length;
nux::Property initial_detail_timeout_length;
private:
bool visible_;
int monitor_;
DetailMode detail_mode_;
ImplPtr impl_;
};
}
}
#endif // SWITCHERCONTROLLER_H