Dali 3D User Interface Engine
actor.h
Go to the documentation of this file.
1 #ifndef __DALI_ACTOR_H__
2 #define __DALI_ACTOR_H__
3 
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20 
21 // EXTERNAL INCLUDES
22 #include <string>
23 
24 // INTERNAL INCLUDES
31 namespace Dali
32 {
38 namespace Internal DALI_INTERNAL
39 {
40 class Actor;
41 }
42 
43 class Actor;
44 class Renderer;
45 struct Degree;
46 class Quaternion;
47 class Layer;
48 struct KeyEvent;
49 struct TouchEvent;
50 struct HoverEvent;
51 struct WheelEvent;
52 struct Vector2;
53 struct Vector3;
54 struct Vector4;
55 
56 typedef Rect<float> Padding;
57 
246 {
247 public:
248 
253  struct Property
254  {
255  enum
256  {
309  };
310  };
311 
312  // Typedefs
313 
320 
321  // Creation
322 
329  Actor();
330 
337  static Actor New();
338 
349  static Actor DownCast( BaseHandle handle );
350 
357  ~Actor();
358 
365  Actor(const Actor& copy);
366 
374  Actor& operator=(const Actor& rhs);
375 
383  const std::string& GetName() const;
384 
392  void SetName(const std::string& name);
393 
401  unsigned int GetId() const;
402 
403  // Containment
404 
412  bool IsRoot() const;
413 
423  bool OnStage() const;
424 
432  bool IsLayer() const;
433 
441  Layer GetLayer();
442 
458  void Add(Actor child);
459 
469  void Remove(Actor child);
470 
478  void Unparent();
479 
487  unsigned int GetChildCount() const;
488 
497  Actor GetChildAt(unsigned int index) const;
498 
508  Actor FindChildByName(const std::string& actorName);
509 
519  Actor FindChildById(const unsigned int id);
520 
528  Actor GetParent() const;
529 
530  // Positioning
531 
545  void SetParentOrigin(const Vector3& origin);
546 
555  Vector3 GetCurrentParentOrigin() const;
556 
572  void SetAnchorPoint(const Vector3& anchorPoint);
573 
582  Vector3 GetCurrentAnchorPoint() const;
583 
596  void SetSize(float width, float height);
597 
610  void SetSize(float width, float height, float depth);
611 
623  void SetSize(const Vector2& size);
624 
635  void SetSize(const Vector3& size);
636 
645  Vector3 GetTargetSize() const;
646 
655  Vector3 GetCurrentSize() const;
656 
665  Vector3 GetNaturalSize() const;
666 
677  void SetPosition(float x, float y);
678 
689  void SetPosition(float x, float y, float z);
690 
699  void SetPosition(const Vector3& position);
700 
709  void SetX(float x);
710 
719  void SetY(float y);
720 
729  void SetZ(float z);
730 
738  void TranslateBy(const Vector3& distance);
739 
748  Vector3 GetCurrentPosition() const;
749 
758  Vector3 GetCurrentWorldPosition() const;
759 
770  void SetPositionInheritanceMode( PositionInheritanceMode mode );
771 
780 
791  void SetOrientation( const Degree& angle, const Vector3& axis )
792  {
793  SetOrientation( Radian( angle ), axis );
794  }
795 
806  void SetOrientation(const Radian& angle, const Vector3& axis);
807 
817  void SetOrientation(const Quaternion& orientation);
818 
827  void RotateBy( const Degree& angle, const Vector3& axis )
828  {
829  RotateBy( Radian( angle ), axis );
830  }
831 
840  void RotateBy(const Radian& angle, const Vector3& axis);
841 
849  void RotateBy(const Quaternion& relativeRotation);
850 
859  Quaternion GetCurrentOrientation() const;
860 
870  void SetInheritOrientation(bool inherit);
871 
879  bool IsOrientationInherited() const;
880 
889  Quaternion GetCurrentWorldOrientation() const;
890 
899  void SetScale(float scale);
900 
911  void SetScale(float scaleX, float scaleY, float scaleZ);
912 
921  void SetScale(const Vector3& scale);
922 
930  void ScaleBy(const Vector3& relativeScale);
931 
940  Vector3 GetCurrentScale() const;
941 
950  Vector3 GetCurrentWorldScale() const;
951 
961  void SetInheritScale( bool inherit );
962 
970  bool IsScaleInherited() const;
971 
980  Matrix GetCurrentWorldMatrix() const;
981 
982  // Visibility & Color
983 
995  void SetVisible(bool visible);
996 
1008  bool IsVisible() const;
1009 
1018  void SetOpacity(float opacity);
1019 
1028  float GetCurrentOpacity() const;
1029 
1039  void SetColor(const Vector4& color);
1040 
1050  Vector4 GetCurrentColor() const;
1051 
1061  void SetColorMode( ColorMode colorMode );
1062 
1070  ColorMode GetColorMode() const;
1071 
1080  Vector4 GetCurrentWorldColor() const;
1081 
1103  void SetDrawMode( DrawMode::Type drawMode );
1104 
1111  DrawMode::Type GetDrawMode() const;
1112 
1113  // Input Handling
1114 
1140  void SetSensitive(bool sensitive);
1141 
1152  bool IsSensitive() const;
1153 
1166  bool ScreenToLocal(float& localX, float& localY, float screenX, float screenY) const;
1167 
1179  void SetLeaveRequired(bool required);
1180 
1189  bool GetLeaveRequired() const;
1190 
1200  void SetKeyboardFocusable( bool focusable );
1201 
1209  bool IsKeyboardFocusable() const;
1210 
1211  // SIZE NEGOTIATION
1212 
1220  void SetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension );
1221 
1229  ResizePolicy::Type GetResizePolicy( Dimension::Type dimension ) const;
1230 
1237  void SetSizeScalePolicy( SizeScalePolicy::Type policy );
1238 
1245  SizeScalePolicy::Type GetSizeScalePolicy() const;
1246 
1259  void SetSizeModeFactor( const Vector3& factor );
1260 
1268  Vector3 GetSizeModeFactor() const;
1269 
1280  float GetHeightForWidth( float width );
1281 
1292  float GetWidthForHeight( float height );
1293 
1301  float GetRelayoutSize( Dimension::Type dimension ) const;
1302 
1309  void SetPadding( const Padding& padding );
1310 
1317  void GetPadding( Padding& paddingOut ) const;
1318 
1325  void SetMinimumSize( const Vector2& size );
1326 
1333  Vector2 GetMinimumSize();
1334 
1341  void SetMaximumSize( const Vector2& size );
1342 
1349  Vector2 GetMaximumSize();
1350 
1357  int GetHierarchyDepth();
1358 
1359 public: // Renderer
1360 
1370  unsigned int AddRenderer( Renderer& renderer );
1371 
1378  unsigned int GetRendererCount() const;
1379 
1389  Renderer GetRendererAt( unsigned int index );
1390 
1397  void RemoveRenderer( Renderer& renderer );
1398 
1407  void RemoveRenderer( unsigned int index );
1408 
1409 public: // Signals
1410 
1424  TouchSignalType& TouchedSignal();
1425 
1439  HoverSignalType& HoveredSignal();
1440 
1454  WheelEventSignalType& WheelEventSignal();
1455 
1478  OnStageSignalType& OnStageSignal();
1479 
1502  OffStageSignalType& OffStageSignal();
1503 
1510  OnRelayoutSignalType& OnRelayoutSignal();
1511 
1512 public: // Not intended for application developers
1513 
1520  explicit DALI_INTERNAL Actor(Internal::Actor* actor);
1521 };
1522 
1531 inline void UnparentAndReset( Actor& actor )
1532 {
1533  if( actor )
1534  {
1535  actor.Unparent();
1536  actor.Reset();
1537  }
1538 }
1539 
1543 } // namespace Dali
1544 
1545 #endif // __DALI_ACTOR_H__
Dali Docs Home
Read more about Dali