~om26er/ubuntu/oneiric/nux/sru-888039

« back to all changes in this revision

Viewing changes to Nux/Area.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2011-07-21 18:41:46 UTC
  • mfrom: (1.1.23 upstream)
  • Revision ID: james.westby@ubuntu.com-20110721184146-po1lz9xhvsz1x7kt
Tags: 1.0.6-0ubuntu1
* New upstream release.
* debian/control:
  - dep on libglu1-mesa-dev
* debian/rules:
  - bump shlib

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include "VSplitter.h"
28
28
#include "HSplitter.h"
29
29
#include "BaseWindow.h"
 
30
#include "MenuPage.h"
30
31
 
31
32
namespace nux
32
33
{
41
42
    ,   _max_size (AREA_MAX_WIDTH, AREA_MAX_HEIGHT)
42
43
  {
43
44
    _parent_area = NULL;
 
45
    next_object_to_key_focus_area_ = NULL;
 
46
    has_key_focus_ = false;
 
47
 
44
48
    _stretch_factor = 1;
45
49
    _layout_properties = NULL;
46
50
    _visible = true;
47
51
    _sensitive = true;
48
52
 
 
53
    _on_geometry_changeg_reconfigure_parent_layout = true;
 
54
    _accept_mouse_wheel_event = false;
 
55
    _accept_keyboard_event = false;
 
56
 
49
57
    _2d_xform.Identity ();
50
58
    _3d_xform.Identity ();
51
59
    _3d_area = false;
136
144
 
137
145
    CheckMinSize();
138
146
 
139
 
    InitiateResizeLayout();
 
147
    ReconfigureParentLayout();
140
148
  }
141
149
 
142
150
  void Area::SetMaximumSize (int w, int h)
147
155
 
148
156
    CheckMaxSize();
149
157
 
150
 
    InitiateResizeLayout();
 
158
    ReconfigureParentLayout();
151
159
  }
152
160
 
153
161
  void Area::SetMinMaxSize (int w, int h)
157
165
    SetMinimumSize (w, h);
158
166
    SetMaximumSize (w, h);
159
167
 
160
 
    //InitiateResizeLayout();
 
168
    //ReconfigureParentLayout();
161
169
  }
162
170
 
163
171
  void Area::ApplyMinWidth()
164
172
  {
165
173
    _geometry.width = _min_size.width;
166
174
 
167
 
    InitiateResizeLayout();
 
175
    ReconfigureParentLayout();
168
176
  }
169
177
 
170
178
  void Area::ApplyMinHeight()
171
179
  {
172
180
    _geometry.height = _min_size.height;
173
181
 
174
 
    InitiateResizeLayout();
 
182
    ReconfigureParentLayout();
175
183
  }
176
184
 
177
185
  void Area::ApplyMaxWidth()
178
186
  {
179
187
    _geometry.width = _max_size.width;
180
188
 
181
 
    InitiateResizeLayout();
 
189
    ReconfigureParentLayout();
182
190
  }
183
191
 
184
192
  void Area::ApplyMaxHeight()
185
193
  {
186
194
    _geometry.height = _max_size.height;
187
195
 
188
 
    InitiateResizeLayout();
 
196
    ReconfigureParentLayout();
189
197
  }
190
198
 
191
199
  Size Area::GetMinimumSize() const
203
211
    nuxAssert (w >= 0);
204
212
    _min_size.width = w;
205
213
    CheckMinSize();
206
 
    InitiateResizeLayout();
 
214
    ReconfigureParentLayout();
207
215
  }
208
216
 
209
217
  void Area::SetMaximumWidth (int w)
211
219
    nuxAssert (w >= 0);
212
220
    _max_size.width = w;
213
221
    CheckMaxSize();
214
 
    InitiateResizeLayout();
 
222
    ReconfigureParentLayout();
215
223
  }
216
224
 
217
225
  void Area::SetMinimumHeight (int h)
219
227
    nuxAssert (h >= 0);
220
228
    _min_size.height = h;
221
229
    CheckMinSize();
222
 
    InitiateResizeLayout();
 
230
    ReconfigureParentLayout();
223
231
  }
224
232
 
225
233
  void Area::SetMaximumHeight (int h)
227
235
    nuxAssert (h >= 0);
228
236
    _max_size.height = h;
229
237
    CheckMaxSize();
230
 
    InitiateResizeLayout();
 
238
    ReconfigureParentLayout();
231
239
  }
232
240
 
233
241
  int Area::GetMinimumWidth() const
313
321
    return _geometry.height;
314
322
  }
315
323
 
316
 
  void Area::SetGeometry (int x, int y, int w, int h)
 
324
  void Area::SetGeometry(int x, int y, int w, int h)
317
325
  {
318
326
    h = nux::Clamp<int> (h, _min_size.height, _max_size.height);
319
327
    w = nux::Clamp<int> (w, _min_size.width, _max_size.width);
322
330
    if (_geometry == geometry)
323
331
      return;
324
332
 
325
 
    GeometryChangePending ();
 
333
    GeometryChangePending();
326
334
    _geometry = geometry;
327
 
    InitiateResizeLayout();
328
 
    GeometryChanged ();
 
335
    ReconfigureParentLayout();
 
336
    GeometryChanged();
329
337
 
330
 
    OnGeometryChanged.emit (this, _geometry);
 
338
    OnGeometryChanged.emit(this, _geometry);
331
339
  }
332
340
 
333
341
  void Area::SetGeometry (const Geometry &geo)
340
348
    return _geometry;
341
349
  }
342
350
 
343
 
  void Area::SetBaseX    (int x)
 
351
  void Area::SetBaseX(int x)
344
352
  {
345
 
    SetGeometry (x, _geometry.y, _geometry.width, _geometry.height);
 
353
    SetGeometry(x, _geometry.y, _geometry.width, _geometry.height);
346
354
  }
347
355
 
348
356
  void Area::SetBaseY    (int y)
396
404
 
397
405
  }
398
406
 
399
 
  void Area::InitiateResizeLayout (Area *child)
400
 
  {
 
407
  void Area::SetReconfigureParentLayoutOnGeometryChange(bool reconfigure_parent_layout)
 
408
  {
 
409
    _on_geometry_changeg_reconfigure_parent_layout = reconfigure_parent_layout;
 
410
  }
 
411
  
 
412
  bool Area::ReconfigureParentLayoutOnGeometryChange()
 
413
  {
 
414
    return _on_geometry_changeg_reconfigure_parent_layout;
 
415
  }
 
416
 
 
417
  void Area::ReconfigureParentLayout(Area *child)
 
418
  {
 
419
    if(_on_geometry_changeg_reconfigure_parent_layout == false)
 
420
      return;
 
421
 
401
422
    if (GetWindowThread ()->IsComputingLayout() )
402
423
    {
403
424
      // there is no need to do the following while we are already computing the layout.
432
453
        }
433
454
      }
434
455
      else if (ic->_parent_area)
435
 
        ic->_parent_area->InitiateResizeLayout (this);
 
456
        ic->_parent_area->ReconfigureParentLayout (this);
436
457
      else
437
458
      {
438
459
        GetWindowThread ()->QueueObjectLayout (ic);
472
493
          else
473
494
          {
474
495
            // The parent object of an object of type View is a Layout object type.
475
 
            layout->_parent_area->InitiateResizeLayout (this);
 
496
            layout->_parent_area->ReconfigureParentLayout (this);
476
497
          }
477
498
        }
478
499
        else
479
500
        {
480
 
          layout->_parent_area->InitiateResizeLayout (this);
 
501
          layout->_parent_area->ReconfigureParentLayout (this);
481
502
        }
482
503
      }
483
504
      else
499
520
        }
500
521
 
501
522
        // The parent object of an object of type InputArea is a Layout object type.
502
 
        this->_parent_area->InitiateResizeLayout (this);
 
523
        this->_parent_area->ReconfigureParentLayout (this);
503
524
      }
504
525
    }
505
526
  }
684
705
 
685
706
  Geometry Area::GetAbsoluteGeometry () const
686
707
  {
687
 
    if (Type ().IsDerivedFromType (BaseWindow::StaticObjectType) || (this == GetWindowThread ()->GetMainLayout ()))
 
708
    if (Type().IsDerivedFromType(BaseWindow::StaticObjectType) ||
 
709
      Type().IsDerivedFromType(MenuPage::StaticObjectType) ||
 
710
      (this == GetWindowThread()->GetMainLayout()))
688
711
    {
689
712
      // Do not apply the _2D_xform matrix  to a BaseWindow or the main layout
690
713
      return _geometry;
818
841
    return false;
819
842
  }
820
843
 
 
844
  bool Area::IsChildOf(Area* parent)
 
845
  {
 
846
    if (this == parent)
 
847
      return true;
 
848
 
 
849
    if (!parent || !_parent_area)
 
850
      return false;
 
851
 
 
852
    return _parent_area->IsChildOf(parent);    
 
853
  }
 
854
 
821
855
  /* handles our focusable code */
822
856
  bool Area::DoGetFocused ()
823
857
  {
850
884
    nux::GetWindowThread ()->QueueObjectLayout (this);
851
885
  }
852
886
  
 
887
  void Area::SetAcceptKeyboardEvent(bool accept_keyboard_event)
 
888
  {
 
889
    _accept_keyboard_event = accept_keyboard_event;
 
890
  }
 
891
 
 
892
  bool Area::AcceptKeyboardEvent() const
 
893
  {
 
894
    return _accept_keyboard_event;
 
895
  }
 
896
 
 
897
  void Area::SetAcceptMouseWheelEvent(bool accept_mouse_wheel_event)
 
898
  {
 
899
    _accept_mouse_wheel_event = accept_mouse_wheel_event;
 
900
  }
 
901
 
 
902
  bool Area::AcceptMouseWheelEvent() const
 
903
  {
 
904
    return _accept_mouse_wheel_event;
 
905
  }
 
906
 
 
907
  bool Area::TestMousePointerInclusion(const Point& mouse_position, NuxEventType event_type)
 
908
  {
 
909
    bool mouse_pointer_inside_area = false;
 
910
 
 
911
    if (Type().IsDerivedFromType(MenuPage::StaticObjectType))
 
912
    {
 
913
      // A MenuPage geometry is already in absolute coordinates.
 
914
      mouse_pointer_inside_area = _geometry.IsInside(mouse_position);
 
915
    }
 
916
    else
 
917
    {
 
918
      mouse_pointer_inside_area = GetAbsoluteGeometry().IsInside(mouse_position);
 
919
    }
 
920
 
 
921
    if ((event_type == NUX_MOUSE_WHEEL) && mouse_pointer_inside_area)
 
922
    {
 
923
      if (_accept_mouse_wheel_event == false)
 
924
        return NULL;
 
925
    }
 
926
 
 
927
    return mouse_pointer_inside_area;
 
928
  }
 
929
 
 
930
  bool Area::TestMousePointerInclusionFilterMouseWheel(const Point& mouse_position, NuxEventType event_type)
 
931
  {
 
932
    bool mouse_pointer_inside_area = false;
 
933
 
 
934
    if (Type().IsDerivedFromType(MenuPage::StaticObjectType))
 
935
    {
 
936
      // A MenuPage geometry is already in absolute coordinates.
 
937
      mouse_pointer_inside_area = _geometry.IsInside(mouse_position);
 
938
    }
 
939
    else
 
940
    {
 
941
      mouse_pointer_inside_area = GetAbsoluteGeometry().IsInside(mouse_position);
 
942
    }
 
943
 
 
944
    return mouse_pointer_inside_area;
 
945
  }
 
946
 
 
947
  Area* Area::FindAreaUnderMouse(const Point& mouse_position, NuxEventType event_type)
 
948
  {
 
949
    return NULL;
 
950
  }
 
951
  
 
952
  Area* Area::FindKeyFocusArea(unsigned int key_symbol,
 
953
   unsigned long x11_key_code,
 
954
   unsigned long special_keys_state)
 
955
  {
 
956
    if (has_key_focus_)
 
957
    {
 
958
      return this;
 
959
    }
 
960
    else if (next_object_to_key_focus_area_)
 
961
    {
 
962
      return next_object_to_key_focus_area_->FindKeyFocusArea(key_symbol, x11_key_code, special_keys_state);
 
963
    }
 
964
    return NULL;
 
965
  }
 
966
 
 
967
  void Area::SetPathToKeyFocusArea()
 
968
  {
 
969
    has_key_focus_ = true;
 
970
    next_object_to_key_focus_area_ = NULL;
 
971
 
 
972
    Area* child = this;
 
973
    Area* parent = GetParentObject();
 
974
 
 
975
    while (parent)
 
976
    {
 
977
      parent->next_object_to_key_focus_area_ = child;
 
978
      parent->has_key_focus_ = false;
 
979
      child = parent;
 
980
      parent = parent->GetParentObject();
 
981
    }
 
982
  }
 
983
 
 
984
  void Area::ResetDownwardPathToKeyFocusArea()
 
985
  {
 
986
    has_key_focus_ = false;
 
987
    if (next_object_to_key_focus_area_)
 
988
    {
 
989
      next_object_to_key_focus_area_->ResetDownwardPathToKeyFocusArea();
 
990
    }
 
991
    next_object_to_key_focus_area_ = NULL;
 
992
  }
 
993
 
 
994
  void Area::ResetUpwardPathToKeyFocusArea()
 
995
  {
 
996
    has_key_focus_ = false;
 
997
    if (_parent_area)
 
998
    {
 
999
      _parent_area->ResetUpwardPathToKeyFocusArea();
 
1000
    }
 
1001
    next_object_to_key_focus_area_ = NULL;
 
1002
  }
 
1003
 
 
1004
  bool Area::InspectKeyEvent(unsigned int eventType,
 
1005
    unsigned int keysym,
 
1006
    const char* character)
 
1007
  {
 
1008
    return false;
 
1009
  }
 
1010
 
 
1011
  bool Area::AcceptKeyNavFocus()
 
1012
  {
 
1013
    return true;
 
1014
  }
 
1015
 
 
1016
  Area* Area::KeyNavIteration(KeyNavDirection direction)
 
1017
  {
 
1018
    return NULL;
 
1019
  }
 
1020
 
 
1021
  bool Area::HasKeyFocus() const
 
1022
  {
 
1023
    return has_key_focus_;
 
1024
  }
853
1025
}
 
1026