From: Yoonsang Lee Date: Thu, 16 Jul 2015 08:44:05 +0000 (+0900) Subject: [DALi][DOC-213] Add Background Knowledge, Handle/Body Pattern X-Git-Tag: tizen_3.0/TD_SYNC/20161201~700^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1bb6cd54dd646e6133e31b1c5fd476ae275d9cfa;p=sdk%2Fonline-doc.git [DALi][DOC-213] Add Background Knowledge, Handle/Body Pattern Signed-off-by: Yoonsang Lee Change-Id: I9641d605283964806484ca130d6a8bdacb4987ee --- diff --git a/org.tizen.ui.guides/html/index.htm b/org.tizen.ui.guides/html/index.htm index f89430d..db33965 100755 --- a/org.tizen.ui.guides/html/index.htm +++ b/org.tizen.ui.guides/html/index.htm @@ -224,6 +224,7 @@
  • Resources
  • Rendering and Effects
  • +
  • Background Knowledge
  • diff --git a/org.tizen.ui.guides/html/native/dali/actors_n.htm b/org.tizen.ui.guides/html/native/dali/actors_n.htm index 8d8f930..dd6e416 100755 --- a/org.tizen.ui.guides/html/native/dali/actors_n.htm +++ b/org.tizen.ui.guides/html/native/dali/actors_n.htm @@ -109,6 +109,8 @@ Stage::GetCurrent().Add(actor);
  • An actor with the position (X = actorWidth*0.5, Y = actorWidth*0.5) appears at the top-left corner of the screen.
  • +

    Please see API reference for Dali::Actor::SetPosition() (in mobile and wearable) for more details.

    + diff --git a/org.tizen.ui.guides/html/native/dali/background_n.htm b/org.tizen.ui.guides/html/native/dali/background_n.htm new file mode 100755 index 0000000..248f420 --- /dev/null +++ b/org.tizen.ui.guides/html/native/dali/background_n.htm @@ -0,0 +1,207 @@ + + + + + + + + + + + + + + Background Knowledge: Using DALi More Effectively + + + + + + +
    +

    Background Knowledge: Using DALi More Effectively

    + +

    This section describes useful background knowledge that enables you to use DALi more effectively. + +

    Handle/Body Pattern

    + +

    DALi widely adopts the handle/body pattern (a.k.a. pimpl pattern) which seperates implementation details (the body class) from its interface (the handle class). In DALi, Dali::Handle represents the interface part and hides internal implementation classes. It additionally provides smart-pointer semantics which manages internal objects with reference counts. +

    + +

    This structure is benificial for both users and developers of DALi:

    +
      +
    • Easier memory management +

      Each internal Dali::Object class (the body class) contains a single reference count object which can be intitialized with the static "New" methods in the DALi public API. This means that C++ new/delete operators do not have to be used in the user code.

      +
    • +
    • Better encapsulation +

      The danger of API/ABI breaks is reduced since the implementation of a class can be changed without modifying the public API, thus without recompiling code using the public API. This also can reduce the build time.

      +
    • +
    + +

    Guide for Handles

    + +
      + +
    • No need to call destructors +
      +class HandleTest
      +{
      +  HandleTest()
      +  {
      +    mActor = Actor::New();
      +  }
      +
      +  ~HandleTest() {} // Actor object is destroyed automatically
      +
      +  Actor mActor;
      +};
      +
      +
    • + +
    • Can be stored in STL containers +
      +class HandleTest
      +{
      +  HandleTest()
      +  {
      +    mActors.push_back( Actor::New() );
      +    mActors.push_back( Actor::New() );
      +    ...
      +  }
      +
      +  ~HandleTest() {} // Actors are destroyed automatically
      +
      +  std::vector<Actor> mActors;
      +};
      +
      +
    • + +
    • Passing by value is encouraged +
      +void SomeFunction( Actor actor )
      +{
      +  if( actor )
      +  {
      +    actor.SomeMethod();
      +  }
      +}
      +
      +
    • + +
    • Validity check +
      +{
      +  ...
      +  Actor actor;  // Create a NULL object
      +
      +  // At this stage we cannot call any of the Actor methods
      +  if( !actor )  // This test is will pass, since the actor is NULL
      +  {
      +    actor = Actor::New();
      +    ...
      +  }
      +  ...
      +}
      +
      +
    • + +
    • Equality operators +
      +{
      +  Actor handle1;
      +  Actor handle2;
      +  cout << handle1 == handle2 << endl; // "true", both handles are empty
      +
      +  handle2 = Actor::New();
      +  cout << handle1 == handle2 << endl; // "false", one handle is empty
      +
      +  handle1 = Actor::New();
      +  cout << handle1 == handle2 << endl; // "false", handles to different objects
      +
      +  handle1 = handle2;
      +  cout << handle1 == handle2 << endl; // "true", handles to same object
      +}
      +
      +
    • + +
    • Reference counting examples +
      +class AnimationTest
      +{
      +...
      +private:
      +  Animation mAnimation; // animation handle
      +};
      +void AnimationTest::Initialize ()
      +{
      +  mAnimation = Animation::New( 10.0f ); // reference count will be 1, animation object stays alive when method returns
      +  ...
      +}
      +void AnimationTest::SetAnimation( Animation anim )
      +{
      +  mAnimation = anim; // reference count of original animation decreased, 'anim' is referenced instead
      +                     // if nobody else had a reference on the initial animation, the object is destroyed
      +}
      +
      + +
      +// At this point we own a Dali::Actor named "container"
      +// Enter a code block
      +{
      +  // Create an text label
      +  TextLabel actor = TextLabel::New("test");
      +  // Add the text label to a container
      +  container.Add(actor);
      +}
      +// Exit the code block
      +// At this stage the text label is still alive
      +// We don't keep the handle to the text label, but it can be retrieved from the container
      +
      + +
    + + + + + +
    + +Go to top + + + + + + + + diff --git a/org.tizen.ui.guides/html/native/dali/dali_overview_n.htm b/org.tizen.ui.guides/html/native/dali/dali_overview_n.htm index 0fcfe76..969d0ed 100755 --- a/org.tizen.ui.guides/html/native/dali/dali_overview_n.htm +++ b/org.tizen.ui.guides/html/native/dali/dali_overview_n.htm @@ -69,7 +69,7 @@

    DALi has a concept of camera to display its virtual 3D world to a 2D screen. There are two ways of using the camera in DALi:

    diff --git a/org.tizen.ui.guides/html/native/dali/guides_dali_n.htm b/org.tizen.ui.guides/html/native/dali/guides_dali_n.htm index d900875..4be15be 100755 --- a/org.tizen.ui.guides/html/native/dali/guides_dali_n.htm +++ b/org.tizen.ui.guides/html/native/dali/guides_dali_n.htm @@ -55,6 +55,8 @@

    Enables you to manage resource images.

  • Rendering and Effects: Managing Viewing Modes and Shader Effects

    Enables you to manage DALi viewing modes and create shade effects.

  • +
  • Background Knowledge: Using DALi More Effectively +

    Enables you to use DALi more effectively with background knowledge.