Back to index

unity  6.0.0
LauncherHideMachine.h
Go to the documentation of this file.
00001 // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
00002 /*
00003  * Copyright (C) 2011 Canonical Ltd
00004  *
00005  * This program is free software: you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License version 3 as
00007  * published by the Free Software Foundation.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  *
00017  * Authored by: Jason Smith <jason.smith@canonical.com>
00018  */
00019 
00020 #ifndef LAUNCHERHIDEMACHINE
00021 #define LAUNCHERHIDEMACHINE
00022 
00023 #include <sigc++/sigc++.h>
00024 #include <glib.h>
00025 #include <string>
00026 #include <UnityCore/GLibSource.h>
00027 
00028 #include "Decaymulator.h"
00029 
00030 namespace unity
00031 {
00032 namespace launcher
00033 {
00034 
00035 class LauncherHideMachine : public sigc::trackable
00036 {
00037 public:
00038   typedef enum
00039   {
00040     HIDE_NEVER,
00041     AUTOHIDE,
00042     DODGE_WINDOWS,
00043     DODGE_ACTIVE_WINDOW,
00044   } HideMode;
00045 
00046   typedef enum
00047   {
00048     DEFAULT                = 0,
00049     LAUNCHER_HIDDEN        = 1 << 0,
00050     MOUSE_OVER_LAUNCHER    = 1 << 1,
00051     QUICKLIST_OPEN         = 1 << 4,
00052     EXTERNAL_DND_ACTIVE    = 1 << 5,
00053     INTERNAL_DND_ACTIVE    = 1 << 6,
00054     TRIGGER_BUTTON_SHOW    = 1 << 7,
00055     DND_PUSHED_OFF         = 1 << 10,
00056     MOUSE_MOVE_POST_REVEAL = 1 << 11,
00057     VERTICAL_SLIDE_ACTIVE  = 1 << 12,
00058     KEY_NAV_ACTIVE         = 1 << 13,
00059     PLACES_VISIBLE         = 1 << 14,
00060     LAST_ACTION_ACTIVATE   = 1 << 15,
00061     SCALE_ACTIVE           = 1 << 16,
00062     EXPO_ACTIVE            = 1 << 17,
00063     MT_DRAG_OUT            = 1 << 18,
00064     REVEAL_PRESSURE_PASS   = 1 << 19,
00065     LAUNCHER_PULSE         = 1 << 20,
00066     LOCK_HIDE              = 1 << 21
00067   } HideQuirk;
00068 
00069   nux::Property<int> reveal_pressure;
00070   nux::Property<int> edge_decay_rate;
00071   nux::Property<float> reveal_progress;
00072 
00073   LauncherHideMachine();
00074 
00075   void     SetMode(HideMode mode);
00076   HideMode GetMode() const;
00077 
00078   void AddRevealPressure(int pressure);
00079 
00080   void SetQuirk(HideQuirk quirk, bool active);
00081   bool GetQuirk(HideQuirk quirk, bool allow_partial = true) const;
00082 
00083   bool ShouldHide() const;
00084 
00085   sigc::signal<void, bool> should_hide_changed;
00086 
00087   std::string DebugHideQuirks() const;
00088 
00089 private:
00090   void EnsureHideState(bool skip_delay);
00091   void SetShouldHide(bool value, bool skip_delay);
00092   bool EmitShouldHideChanged();
00093 
00094   void OnDecayRateChanged (int value);
00095 
00096   ui::Decaymulator::Ptr decaymulator_;
00097   HideMode  _mode;
00098   HideQuirk _quirks;
00099   bool      _should_hide;
00100   bool      _latest_emit_should_hide;
00101 
00102   glib::Source::UniquePtr _hide_delay_timeout;
00103   glib::Source::UniquePtr _hide_changed_emit_idle;
00104 };
00105 
00106 } // namespace launcher
00107 } // namespace unity
00108 
00109 #endif