Back to index

unity  6.0.0
PanelTitlebarGrabAreaView.h
Go to the documentation of this file.
00001 // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
00002 /*
00003  * Copyright (C) 2010-2012 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: Neil Jagdish Patel <neil.patel@canonical.com>
00018  *              Sam Spilsbury <sam.spilsbury@canonical.com>
00019  *              Didier Roche <didier.roche@canonical.com>
00020  *              Marco Trevisan (TreviƱo) <mail@3v1n0.net>
00021  */
00022 
00023 #ifndef PANEL_TITLEBAR_GRAB_AREA_H
00024 #define PANEL_TITLEBAR_GRAB_AREA_H_H
00025 
00026 #include <Nux/View.h>
00027 #include <UnityCore/GLibSource.h>
00028 
00029 #include "unity-shared/Introspectable.h"
00030 
00031 namespace unity
00032 {
00033 
00034 class PanelTitlebarGrabArea : public nux::InputArea, public unity::debug::Introspectable
00035 {
00036   /* This acts a bit like a decorator, it can be clicked or grabbed (such that
00037    * we can pull the window down) */
00038 
00039 public:
00040   PanelTitlebarGrabArea();
00041   ~PanelTitlebarGrabArea();
00042 
00043   void SetGrabbed(bool enabled);
00044   bool IsGrabbed();
00045 
00046   sigc::signal<void, int, int> lower_request;
00047   sigc::signal<void, int, int> activate_request;
00048   sigc::signal<void, int, int> restore_request;
00049   sigc::signal<void, int, int> grab_started;
00050   sigc::signal<void, int, int> grab_move;
00051   sigc::signal<void, int, int> grab_end;
00052 
00053 protected:
00054   std::string GetName() const;
00055   void AddProperties(GVariantBuilder* builder);
00056 
00057 private:
00058   void OnMouseDown(int x, int y, unsigned long button_flags, unsigned long);
00059   void OnMouseUp(int x, int y, unsigned long button_flags, unsigned long);
00060   void OnGrabMove(int x, int y, int, int, unsigned long button_flags, unsigned long);
00061 
00062   Cursor grab_cursor_;
00063   bool grab_started_;
00064   nux::Point mouse_down_point_;
00065   unsigned int mouse_down_button_;
00066   glib::Source::UniquePtr mouse_down_timer_;
00067 };
00068 
00069 } // NAMESPACE
00070 
00071 #endif