~azzar1/unity/dont-focus-me-on-mouse-down2

« back to all changes in this revision

Viewing changes to plugins/unity-mt-grab-handles/src/unity-mt-grab-handle.cpp

  • Committer: Tarmac
  • Author(s): Sam Spilsbury
  • Date: 2011-12-24 05:43:55 UTC
  • mfrom: (1794.3.6 901714.split_files)
  • Revision ID: tarmac-20111224054355-yu544y9qscv4u38b
Splits code into files. Fixes: https://bugs.launchpad.net/bugs/907174. Appoved by Thomas Voß.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2011 Canonical Ltd
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License version 3 as
 
6
 * published by the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
 
17
 */
 
18
 
 
19
#include "unity-mt-grab-handle.h"
 
20
#include "unity-mt-grab-handle-group.h"
 
21
#include "unity-mt-grab-handle-window.h"
 
22
#include "unity-mt-texture.h"
 
23
#include "unity-mt-grab-handle-impl-factory.h"
 
24
 
 
25
void
 
26
unity::MT::GrabHandle::buttonPress (int x,
 
27
                                    int y,
 
28
                                    unsigned int button) const
 
29
{
 
30
  mImpl->buttonPress (x, y, button);
 
31
}
 
32
 
 
33
void
 
34
unity::MT::GrabHandle::requestMovement (int x,
 
35
                                        int y,
 
36
                                        unsigned int button) const
 
37
{
 
38
  unity::MT::GrabHandleGroup::Ptr ghg = mOwner.lock ();
 
39
  ghg->requestMovement (x, y, (maskHandles.find (mId))->second, button);
 
40
}
 
41
 
 
42
void
 
43
unity::MT::GrabHandle::show ()
 
44
{
 
45
  mImpl->show ();
 
46
}
 
47
 
 
48
void
 
49
unity::MT::GrabHandle::hide ()
 
50
{
 
51
  mImpl->hide ();
 
52
}
 
53
 
 
54
void
 
55
unity::MT::GrabHandle::raise () const
 
56
{
 
57
  unity::MT::GrabHandleGroup::Ptr ghg = mOwner.lock ();
 
58
  boost::shared_ptr <const unity::MT::GrabHandle> gh = shared_from_this ();
 
59
  ghg->raiseHandle (gh);
 
60
}
 
61
 
 
62
void
 
63
unity::MT::GrabHandle::reposition(int          x,
 
64
                                  int          y,
 
65
                                  unsigned int flags)
 
66
{
 
67
  damage (mRect);
 
68
 
 
69
  if (flags & PositionSet)
 
70
  {
 
71
    mRect.x = x;
 
72
    mRect.y = y;
 
73
  }
 
74
 
 
75
  if (flags & PositionLock)
 
76
  {
 
77
    mImpl->lockPosition (x, y, flags);
 
78
  }
 
79
 
 
80
  damage (mRect);
 
81
}
 
82
 
 
83
void
 
84
unity::MT::GrabHandle::reposition(int x, int y, unsigned int flags) const
 
85
{
 
86
  if (flags & PositionLock)
 
87
  {
 
88
    mImpl->lockPosition (x, y, flags);
 
89
  }
 
90
}
 
91
 
 
92
unity::MT::TextureLayout
 
93
unity::MT::GrabHandle::layout()
 
94
{
 
95
  return TextureLayout(mTexture, mRect);
 
96
}
 
97
 
 
98
unity::MT::GrabHandle::GrabHandle(Texture::Ptr texture,
 
99
                                  unsigned int    width,
 
100
                                  unsigned int    height,
 
101
                                  const boost::shared_ptr <GrabHandleGroup> &owner,
 
102
                                  unsigned int    id) :
 
103
  mOwner(owner),
 
104
  mTexture (texture),
 
105
  mId(id),
 
106
  mRect (0, 0, width, height),
 
107
  mImpl (NULL)
 
108
{
 
109
}
 
110
 
 
111
unity::MT::GrabHandle::Ptr
 
112
unity::MT::GrabHandle::create (Texture::Ptr texture, unsigned int width, unsigned int height,
 
113
                               const boost::shared_ptr <GrabHandleGroup> &owner,
 
114
                               unsigned int id)
 
115
{
 
116
  unity::MT::GrabHandle::Ptr p (new unity::MT::GrabHandle (texture, width, height, owner, id));
 
117
  p->mImpl = unity::MT::GrabHandle::ImplFactory::Default ()->create (p);
 
118
 
 
119
  return p;
 
120
}
 
121
 
 
122
unity::MT::GrabHandle::~GrabHandle()
 
123
{
 
124
  delete mImpl;
 
125
}