37
37
Area::Area (NUX_FILE_LINE_DECL)
38
38
: InitiallyUnownedObject (NUX_FILE_LINE_PARAM)
40
39
, geometry_ (0, 0, DEFAULT_WIDGET_WIDTH, DEFAULT_WIDGET_HEIGHT)
41
, _min_size (AREA_MIN_WIDTH, AREA_MIN_HEIGHT)
42
, _max_size (AREA_MAX_WIDTH, AREA_MAX_HEIGHT)
40
, min_size_ (AREA_MIN_WIDTH, AREA_MIN_HEIGHT)
41
, max_size_ (AREA_MAX_WIDTH, AREA_MAX_HEIGHT)
45
next_object_to_key_focus_area_ = NULL;
46
has_key_focus_ = false;
49
_layout_properties = NULL;
47
next_object_to_key_focus_area_ = NULL;
48
has_key_focus_ = false;
53
53
on_geometry_change_reconfigure_parent_layout_ = true;
79
77
void Area::CheckMinSize()
81
int w = _min_size.width;
79
int w = min_size_.width;
82
80
w = Max<int>(AREA_MIN_WIDTH, w);
83
int h = _min_size.height;
81
int h = min_size_.height;
84
82
h = Max<int>(AREA_MIN_HEIGHT, h);
86
_min_size = Size(w, h);
88
if (_min_size.width > _max_size.width)
90
_max_size.width = _min_size.width;
93
if (_min_size.height > _max_size.height)
95
_max_size.height = _min_size.height;
98
if (geometry_.width < _min_size.width)
100
geometry_.width = _min_size.width;
103
if (geometry_.height < _min_size.height )
105
geometry_.height = _min_size.height;
84
min_size_ = Size(w, h);
86
if (min_size_.width > max_size_.width)
88
max_size_.width = min_size_.width;
91
if (min_size_.height > max_size_.height)
93
max_size_.height = min_size_.height;
96
if (geometry_.width < min_size_.width)
98
geometry_.width = min_size_.width;
101
if (geometry_.height < min_size_.height )
103
geometry_.height = min_size_.height;
109
107
void Area::CheckMaxSize()
111
int w = _max_size.width;
109
int w = max_size_.width;
112
110
w = Min<int>(AREA_MAX_WIDTH, w);
113
int h = _max_size.height;
111
int h = max_size_.height;
114
112
h = Min<int>(AREA_MAX_HEIGHT, h);
116
_max_size = Size(w, h);
118
if (_min_size.width > _max_size.width)
120
_min_size.width = _max_size.width;
123
if (_min_size.height > _max_size.height)
125
_min_size.height = _max_size.height;
128
if (geometry_.width > _max_size.width)
130
geometry_.width = _max_size.width;
133
if (geometry_.height > _max_size.height)
135
geometry_.height = _max_size.height;
114
max_size_ = Size(w, h);
116
if (min_size_.width > max_size_.width)
118
min_size_.width = max_size_.width;
121
if (min_size_.height > max_size_.height)
123
min_size_.height = max_size_.height;
126
if (geometry_.width > max_size_.width)
128
geometry_.width = max_size_.width;
131
if (geometry_.height > max_size_.height)
133
geometry_.height = max_size_.height;
171
169
void Area::ApplyMinWidth()
173
geometry_.width = _min_size.width;
171
geometry_.width = min_size_.width;
175
173
ReconfigureParentLayout();
178
176
void Area::ApplyMinHeight()
180
geometry_.height = _min_size.height;
178
geometry_.height = min_size_.height;
182
180
ReconfigureParentLayout();
185
183
void Area::ApplyMaxWidth()
187
geometry_.width = _max_size.width;
185
geometry_.width = max_size_.width;
189
187
ReconfigureParentLayout();
192
190
void Area::ApplyMaxHeight()
194
geometry_.height = _max_size.height;
192
geometry_.height = max_size_.height;
196
194
ReconfigureParentLayout();
199
197
Size Area::GetMinimumSize() const
204
202
Size Area::GetMaximumSize() const
209
207
void Area::SetMinimumWidth (int w)
211
209
nuxAssert (w >= 0);
214
212
ReconfigureParentLayout();
233
231
void Area::SetMaximumHeight (int h)
235
233
nuxAssert (h >= 0);
236
_max_size.height = h;
234
max_size_.height = h;
238
236
ReconfigureParentLayout();
241
239
int Area::GetMinimumWidth() const
243
return _min_size.width;
241
return min_size_.width;
246
244
int Area::GetMaximumWidth() const
248
return _max_size.width;
246
return max_size_.width;
251
249
int Area::GetMinimumHeight() const
253
return _min_size.height;
251
return min_size_.height;
256
254
int Area::GetMaximumHeight() const
258
return _max_size.height;
256
return max_size_.height;
261
259
unsigned int Area::GetStretchFactor()
263
return _stretch_factor;
261
return scale_factor_;
266
264
void Area::SetStretchFactor (unsigned int sf)
268
266
// re implemented by Layout
269
_stretch_factor = sf;
272
270
bool Area::SetParentObject (Area *parent)
280
if (_parent_area && (_parent_area != parent))
278
if (parent_area_ && (parent_area_ != parent))
282
nuxAssertMsg (0, TEXT ("[Area::SetParentObject] Object already has a parent. You must UnParent the object before you can parenting again.") );
280
nuxAssertMsg (0, "[Area::SetParentObject] Object already has a parent. You must UnParent the object before you can parenting again." );
288
286
// Already parented to the same area. Return.
292
_parent_area = parent;
290
parent_area_ = parent;
332
330
void Area::SetGeometry(int x, int y, int w, int h)
334
h = nux::Clamp<int> (h, _min_size.height, _max_size.height);
335
w = nux::Clamp<int> (w, _min_size.width, _max_size.width);
332
h = nux::Clamp<int> (h, min_size_.height, max_size_.height);
333
w = nux::Clamp<int> (w, min_size_.width, max_size_.width);
337
335
nux::Geometry geometry(x, y, w, h);
338
336
if (geometry_ == geometry)
469
467
Layout *layout = static_cast<Layout *>(this);
471
if (layout->_parent_area)
469
if (layout->parent_area_)
473
if (layout->_parent_area->Type().IsDerivedFromType (View::StaticObjectType) )
471
if (layout->parent_area_->Type().IsDerivedFromType (View::StaticObjectType) )
475
View *ic = (View *) (layout->_parent_area);
473
View *ic = (View *) (layout->parent_area_);
477
475
if (ic->CanBreakLayout() )
520
518
// The parent object of an object of type InputArea is a Layout object type.
521
this->_parent_area->ReconfigureParentLayout (this);
519
this->parent_area_->ReconfigureParentLayout (this);
526
524
void Area::RequestBottomUpLayoutComputation (Area *bo_initiator)
528
if (_parent_area && _parent_area->IsLayout() )
526
if (parent_area_ && parent_area_->IsLayout() )
530
_parent_area->RequestBottomUpLayoutComputation (bo_initiator);
528
parent_area_->RequestBottomUpLayoutComputation (bo_initiator);
534
void Area::SetLayoutProperties (LayoutProperties *properties)
536
if (_layout_properties)
537
delete _layout_properties;
539
_layout_properties = properties;
542
Area::LayoutProperties * Area::GetLayoutProperties ()
544
return _layout_properties;
547
532
void Area::SetVisible (bool visible)
549
534
if (visible_ == visible)
562
void Area::SetSensitive (bool sensitive)
547
void Area::SetSensitive(bool sensitive)
549
SetInputEventSensitivity(sensitive);
552
void Area::SetInputEventSensitivity(bool sensitive)
564
554
if (sensitive_ == sensitive)
567
557
sensitive_ = sensitive;
569
OnSensitiveChanged.emit (this, sensitive_);
572
bool Area::IsSensitive ()
559
OnSensitiveChanged.emit(this, sensitive_);
562
bool Area::IsSensitive() const
564
return GetInputEventSensitivity();
567
bool Area::GetInputEventSensitivity() const
574
569
return sensitive_;
577
572
MinorDimensionPosition Area::GetPositioning()
574
return minor_axis_position_;
582
577
void Area::SetPositioning (MinorDimensionPosition p)
579
minor_axis_position_ = p;
587
582
MinorDimensionSize Area::GetExtend()
584
return minor_axis_size_;
592
587
void Area::SetExtend (MinorDimensionSize ext)
589
minor_axis_size_ = ext;
597
592
float Area::GetPercentage()
594
return minor_axis_size_scale_;
602
597
void Area::SetPercentage (float p)
599
minor_axis_size_scale_ = p;
607
602
bool Area::IsLayoutDone()
612
607
void Area::SetLayoutDone (bool b)
617
612
bool Area::IsArea () const
861
856
return _accept_mouse_wheel_event;
864
bool Area::TestMousePointerInclusion(const Point& mouse_position, NuxEventType event_type)
866
if (IsSensitive() == false)
869
bool mouse_pointer_inside_area = false;
871
if (Type().IsDerivedFromType(MenuPage::StaticObjectType))
873
// A MenuPage geometry is already in absolute coordinates.
874
mouse_pointer_inside_area = geometry_.IsInside(mouse_position);
878
mouse_pointer_inside_area = GetAbsoluteGeometry().IsInside(mouse_position);
881
if ((event_type == NUX_MOUSE_WHEEL) && mouse_pointer_inside_area)
883
if (_accept_mouse_wheel_event == false)
887
return mouse_pointer_inside_area;
890
bool Area::TestMousePointerInclusionFilterMouseWheel(const Point& mouse_position, NuxEventType event_type)
892
if (IsSensitive() == false)
895
bool mouse_pointer_inside_area = false;
897
if (Type().IsDerivedFromType(MenuPage::StaticObjectType))
899
// A MenuPage geometry is already in absolute coordinates.
900
mouse_pointer_inside_area = geometry_.IsInside(mouse_position);
904
mouse_pointer_inside_area = GetAbsoluteGeometry().IsInside(mouse_position);
907
return mouse_pointer_inside_area;
859
bool Area::TestMousePointerInclusion(const Point& mouse_position, NuxEventType event_type)
861
if ((IsLayout() == false) && ((GetInputEventSensitivity() == false) || (view_enabled_ == false)))
863
// If this area is not a view and:
864
// - it is insensitive to input event
865
// - it is not enabled
866
// - it is not visible
867
// then return false.
871
bool mouse_pointer_inside_area = false;
873
if (Type().IsDerivedFromType(MenuPage::StaticObjectType))
875
// A MenuPage geometry is already in absolute coordinates.
876
mouse_pointer_inside_area = geometry_.IsInside(mouse_position);
880
mouse_pointer_inside_area = GetAbsoluteGeometry().IsInside(mouse_position);
883
if ((event_type == NUX_MOUSE_WHEEL) && mouse_pointer_inside_area)
885
if (_accept_mouse_wheel_event == false)
889
return mouse_pointer_inside_area;
892
bool Area::TestMousePointerInclusionFilterMouseWheel(const Point& mouse_position, NuxEventType event_type)
894
if ((IsLayout() == false) && ((GetInputEventSensitivity() == false) || (view_enabled_ == false)))
896
// If this area is not a view and:
897
// - it is insensitive to input event
898
// - it is not enabled
899
// - it is not visible
900
// then return false.
905
bool mouse_pointer_inside_area = false;
907
if (Type().IsDerivedFromType(MenuPage::StaticObjectType))
909
// A MenuPage geometry is already in absolute coordinates.
910
mouse_pointer_inside_area = geometry_.IsInside(mouse_position);
914
mouse_pointer_inside_area = GetAbsoluteGeometry().IsInside(mouse_position);
917
return mouse_pointer_inside_area;
910
920
Area* Area::FindAreaUnderMouse(const Point& mouse_position, NuxEventType event_type)