~ubuntu-branches/ubuntu/oneiric/nux/oneiric

« back to all changes in this revision

Viewing changes to Nux/Area.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2011-06-22 17:16:16 UTC
  • mfrom: (1.1.21 upstream)
  • Revision ID: james.westby@ubuntu.com-20110622171616-3cyhhiwsb6ga9d30
Tags: 1.0.2-0ubuntu1
* New upstream release.
* Cherry-pick a fix for FTBFS with -fpermissive
* debian/control:
  - add new libxdamage-dev and libxcomposite-dev build-dep
  - add new libboost1.42-dev dep as well, should be transitionned to 1.46 once
    compiz is transitionned as well
* remove debian/patches/01_build_with_gcc46.patch as included upstream
* debian/rules:
  - disable google code tests while building
* debian/control, debian/rules, debian/libnux-1.0-common.install,
  debian/libnux-1.0-dev.install, debian/libnux-1.0-doc.install,
  debian/libnux-1.0-0.install:
  - change, prepare next ABI breakage and remove no more needed Breaks: with
    new soname bump
* libnux-1.0-common now replaces: libnux-0.9-common for the apport hook

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
 
71
71
  void Area::CheckMinSize()
72
72
  {
73
 
    int w = _min_size.GetWidth();
 
73
    int w = _min_size.width;
74
74
    w = Max<int>(AREA_MIN_WIDTH, w);
75
 
    int h = _min_size.GetHeight();
 
75
    int h = _min_size.height;
76
76
    h = Max<int>(AREA_MIN_HEIGHT, h);
77
77
 
78
 
    _min_size.SetWidth(w);
79
 
    _min_size.SetHeight(h);
80
 
 
81
 
    if (_min_size.GetWidth() > _max_size.GetWidth())
82
 
    {
83
 
      //temp = _max_size.GetWidth();
84
 
      _max_size.SetWidth (_min_size.GetWidth());
85
 
      //_min_size.SetWidth(temp);
86
 
    }
87
 
 
88
 
    if (_min_size.GetHeight() > _max_size.GetHeight())
89
 
    {
90
 
      //temp = _max_size.GetBaseHeight();
91
 
      _max_size.SetHeight (_min_size.GetHeight());
92
 
      //_min_size.SetHeight(temp);
93
 
    }
94
 
 
95
 
    if (_geometry.GetWidth() < _min_size.GetWidth() )
96
 
    {
97
 
      _geometry.SetWidth (_min_size.GetWidth() );
98
 
    }
99
 
 
100
 
    if (_geometry.GetHeight() < _min_size.GetHeight() )
101
 
    {
102
 
      _geometry.SetHeight (_min_size.GetHeight() );
 
78
    _min_size = Size(w, h);
 
79
 
 
80
    if (_min_size.width > _max_size.width)
 
81
    {
 
82
      _max_size.width = _min_size.width;
 
83
    }
 
84
 
 
85
    if (_min_size.height > _max_size.height)
 
86
    {
 
87
      _max_size.height = _min_size.height;
 
88
    }
 
89
 
 
90
    if (_geometry.width < _min_size.width)
 
91
    {
 
92
      _geometry.width = _min_size.width;
 
93
    }
 
94
 
 
95
    if (_geometry.height < _min_size.height )
 
96
    {
 
97
      _geometry.height = _min_size.height;
103
98
    }
104
99
  }
105
100
 
106
101
  void Area::CheckMaxSize()
107
102
  {
108
 
    int w = _max_size.GetWidth();
 
103
    int w = _max_size.width;
109
104
    w = Min<int>(AREA_MAX_WIDTH, w);
110
 
    int h = _max_size.GetHeight();
 
105
    int h = _max_size.height;
111
106
    h = Min<int>(AREA_MAX_HEIGHT, h);
112
107
 
113
 
    _max_size.SetWidth(w);
114
 
    _max_size.SetHeight(h);
115
 
 
116
 
    if (_min_size.GetWidth() > _max_size.GetWidth() )
117
 
    {
118
 
      //temp = _max_size.GetWidth();
119
 
      _min_size.SetWidth (_max_size.GetWidth() );
120
 
      //_min_size.SetWidth(temp);
121
 
    }
122
 
 
123
 
    if (_min_size.GetHeight() > _max_size.GetHeight() )
124
 
    {
125
 
      //temp = _max_size.GetBaseHeight();
126
 
      _min_size.SetHeight (_max_size.GetHeight() );
127
 
      //_min_size.SetHeight(temp);
128
 
    }
129
 
 
130
 
    if (_geometry.GetWidth() > _max_size.GetWidth() )
131
 
    {
132
 
      _geometry.SetWidth (_max_size.GetWidth() );
133
 
    }
134
 
 
135
 
    if (_geometry.GetHeight() > _max_size.GetHeight() )
136
 
    {
137
 
      _geometry.SetHeight (_max_size.GetHeight() );
 
108
    _max_size = Size(w, h);
 
109
 
 
110
    if (_min_size.width > _max_size.width)
 
111
    {
 
112
      _min_size.width = _max_size.width;
 
113
    }
 
114
 
 
115
    if (_min_size.height > _max_size.height)
 
116
    {
 
117
      _min_size.height = _max_size.height;
 
118
    }
 
119
 
 
120
    if (_geometry.width > _max_size.width)
 
121
    {
 
122
      _geometry.width = _max_size.width;
 
123
    }
 
124
 
 
125
    if (_geometry.height > _max_size.height)
 
126
    {
 
127
      _geometry.height = _max_size.height;
138
128
    }
139
129
  }
140
130
 
142
132
  {
143
133
    nuxAssert (w >= 0);
144
134
    nuxAssert (h >= 0);
145
 
    _min_size.SetWidth (w);
146
 
    _min_size.SetHeight (h);
 
135
    _min_size = Size(w, h);
147
136
 
148
137
    CheckMinSize();
149
138
 
154
143
  {
155
144
    nuxAssert (w >= 0);
156
145
    nuxAssert (h >= 0);
157
 
    _max_size.SetWidth (w);
158
 
    _max_size.SetHeight (h);
 
146
    _max_size = Size(w, h);
159
147
 
160
148
    CheckMaxSize();
161
149
 
174
162
 
175
163
  void Area::ApplyMinWidth()
176
164
  {
177
 
    _geometry.SetWidth (_min_size.GetWidth() );
 
165
    _geometry.width = _min_size.width;
178
166
 
179
167
    InitiateResizeLayout();
180
168
  }
181
169
 
182
170
  void Area::ApplyMinHeight()
183
171
  {
184
 
    _geometry.SetHeight (_min_size.GetHeight() );
 
172
    _geometry.height = _min_size.height;
185
173
 
186
174
    InitiateResizeLayout();
187
175
  }
188
176
 
189
177
  void Area::ApplyMaxWidth()
190
178
  {
191
 
    _geometry.SetWidth (_max_size.GetWidth() );
 
179
    _geometry.width = _max_size.width;
192
180
 
193
181
    InitiateResizeLayout();
194
182
  }
195
183
 
196
184
  void Area::ApplyMaxHeight()
197
185
  {
198
 
    _geometry.SetHeight (_max_size.GetHeight() );
 
186
    _geometry.height = _max_size.height;
199
187
 
200
188
    InitiateResizeLayout();
201
189
  }
213
201
  void Area::SetMinimumWidth (int w)
214
202
  {
215
203
    nuxAssert (w >= 0);
216
 
    _min_size.SetWidth (w);
 
204
    _min_size.width = w;
217
205
    CheckMinSize();
218
206
    InitiateResizeLayout();
219
207
  }
221
209
  void Area::SetMaximumWidth (int w)
222
210
  {
223
211
    nuxAssert (w >= 0);
224
 
    _max_size.SetWidth (w);
 
212
    _max_size.width = w;
225
213
    CheckMaxSize();
226
214
    InitiateResizeLayout();
227
215
  }
229
217
  void Area::SetMinimumHeight (int h)
230
218
  {
231
219
    nuxAssert (h >= 0);
232
 
    _min_size.SetHeight (h);
 
220
    _min_size.height = h;
233
221
    CheckMinSize();
234
222
    InitiateResizeLayout();
235
223
  }
237
225
  void Area::SetMaximumHeight (int h)
238
226
  {
239
227
    nuxAssert (h >= 0);
240
 
    _max_size.SetHeight (h);
 
228
    _max_size.height = h;
241
229
    CheckMaxSize();
242
230
    InitiateResizeLayout();
243
231
  }
244
232
 
245
233
  int Area::GetMinimumWidth() const
246
234
  {
247
 
    return _min_size.GetWidth();
 
235
    return _min_size.width;
248
236
  }
249
237
 
250
238
  int Area::GetMaximumWidth() const
251
239
  {
252
 
    return _max_size.GetWidth();
 
240
    return _max_size.width;
253
241
  }
254
242
 
255
243
  int Area::GetMinimumHeight() const
256
244
  {
257
 
    return _min_size.GetHeight();
 
245
    return _min_size.height;
258
246
  }
259
247
 
260
248
  int Area::GetMaximumHeight() const
261
249
  {
262
 
    return _max_size.GetHeight();
 
250
    return _max_size.height;
263
251
  }
264
252
 
265
253
  unsigned int Area::GetStretchFactor()
317
305
 
318
306
  int Area::GetBaseWidth    () const
319
307
  {
320
 
    return _geometry.GetWidth();
 
308
    return _geometry.width;
321
309
  }
322
310
 
323
311
  int Area::GetBaseHeight   () const
324
312
  {
325
 
    return _geometry.GetHeight();
 
313
    return _geometry.height;
326
314
  }
327
315
 
328
316
  void Area::SetGeometry (int x, int y, int w, int h)
329
317
  {
330
 
    h = nux::Clamp<int> (h, _min_size.GetHeight (), _max_size.GetHeight ());
331
 
    w = nux::Clamp<int> (w, _min_size.GetWidth (), _max_size.GetWidth ());
 
318
    h = nux::Clamp<int> (h, _min_size.height, _max_size.height);
 
319
    w = nux::Clamp<int> (w, _min_size.width, _max_size.width);
332
320
 
333
 
    if (_geometry.x == x && _geometry.y == y && _geometry.width == w && _geometry.height == h)
 
321
    nux::Geometry geometry(x, y, w, h);
 
322
    if (_geometry == geometry)
334
323
      return;
335
324
 
336
325
    GeometryChangePending ();
337
 
    _geometry = nux::Geometry (x, y, w, h);
 
326
    _geometry = geometry;
338
327
    InitiateResizeLayout();
339
328
    GeometryChanged ();
340
329
 
346
335
    SetGeometry (geo.x, geo.y, geo.width, geo.height);
347
336
  }
348
337
 
349
 
  Geometry Area::GetGeometry() const
 
338
  Geometry const& Area::GetGeometry() const
350
339
  {
351
340
    return _geometry;
352
341
  }
384
373
  void Area::IncreaseSize (int x, int y)
385
374
  {
386
375
    _geometry.OffsetPosition (x, y);
387
 
    OnResize.emit (_geometry.x, _geometry.y, _geometry.GetWidth(), _geometry.GetHeight() );
 
376
    OnResize.emit (_geometry.x, _geometry.y, _geometry.width, _geometry.height );
388
377
  }
389
378
 
390
379
  long Area::ComputeChildLayout()