Back to index

unity  6.0.0
unity-mt-grab-handle.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2011 Canonical Ltd
00003  *
00004  * This program is free software: you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License version 3 as
00006  * published by the Free Software Foundation.
00007  *
00008  * This program is distributed in the hope that it will be useful,
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011  * GNU General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU General Public License
00014  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00015  *
00016  * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
00017  */
00018 
00019 #include "unity-mt-grab-handle.h"
00020 #include "unity-mt-grab-handle-group.h"
00021 #include "unity-mt-grab-handle-window.h"
00022 #include "unity-mt-texture.h"
00023 #include "unity-mt-grab-handle-impl-factory.h"
00024 
00025 void
00026 unity::MT::GrabHandle::buttonPress (int x,
00027                                     int y,
00028                                     unsigned int button) const
00029 {
00030   mImpl->buttonPress (x, y, button);
00031 }
00032 
00033 void
00034 unity::MT::GrabHandle::requestMovement (int x,
00035                                         int y,
00036                                         unsigned int button) const
00037 {
00038   unity::MT::GrabHandleGroup::Ptr ghg = mOwner.lock ();
00039   ghg->requestMovement (x, y, (maskHandles.find (mId))->second, button);
00040 }
00041 
00042 void
00043 unity::MT::GrabHandle::show ()
00044 {
00045   mImpl->show ();
00046 }
00047 
00048 void
00049 unity::MT::GrabHandle::hide ()
00050 {
00051   mImpl->hide ();
00052 }
00053 
00054 void
00055 unity::MT::GrabHandle::raise () const
00056 {
00057   unity::MT::GrabHandleGroup::Ptr ghg = mOwner.lock ();
00058   boost::shared_ptr <const unity::MT::GrabHandle> gh = shared_from_this ();
00059   ghg->raiseHandle (gh);
00060 }
00061 
00062 void
00063 unity::MT::GrabHandle::reposition(int          x,
00064                                   int          y,
00065                               unsigned int flags)
00066 {
00067   damage (mRect);
00068 
00069   if (flags & PositionSet)
00070   {
00071     mRect.x = x;
00072     mRect.y = y;
00073   }
00074 
00075   if (flags & PositionLock)
00076   {
00077     mImpl->lockPosition (x, y, flags);
00078   }
00079 
00080   damage (mRect);
00081 }
00082 
00083 void
00084 unity::MT::GrabHandle::reposition(int x, int y, unsigned int flags) const
00085 {
00086   if (flags & PositionLock)
00087   {
00088     mImpl->lockPosition (x, y, flags);
00089   }
00090 }
00091 
00092 unity::MT::TextureLayout
00093 unity::MT::GrabHandle::layout()
00094 {
00095   return TextureLayout(mTexture, mRect);
00096 }
00097 
00098 unity::MT::GrabHandle::GrabHandle(Texture::Ptr texture,
00099                                   unsigned int    width,
00100                                   unsigned int    height,
00101                                   const boost::shared_ptr <GrabHandleGroup> &owner,
00102                               unsigned int    id) :
00103   mOwner(owner),
00104   mTexture (texture),
00105   mId(id),
00106   mRect (0, 0, width, height),
00107   mImpl (NULL)
00108 {
00109 }
00110 
00111 unity::MT::GrabHandle::Ptr
00112 unity::MT::GrabHandle::create (Texture::Ptr texture, unsigned int width, unsigned int height,
00113                                const boost::shared_ptr <GrabHandleGroup> &owner,
00114                                unsigned int id)
00115 {
00116   unity::MT::GrabHandle::Ptr p (new unity::MT::GrabHandle (texture, width, height, owner, id));
00117   p->mImpl = unity::MT::GrabHandle::ImplFactory::Default ()->create (p);
00118 
00119   return p;
00120 }
00121 
00122 unity::MT::GrabHandle::~GrabHandle()
00123 {
00124   delete mImpl;
00125 }