From 6e3cc5416aae71df67186e7f8b9f6ae580238e84 Mon Sep 17 00:00:00 2001 From: Adeel Kazmi Date: Tue, 2 Jun 2015 16:38:20 +0100 Subject: [PATCH] (Programmin Guide) Images Change-Id: I642e0a6d3eb1563d0d7a001df76dbfd5f3b6f3ea --- docs/content/images/resource/9-patch-full.png | Bin 0 -> 1545 bytes docs/content/images/resource/9-patch-zoomed.png | Bin 0 -> 2008 bytes docs/content/images/resource/9-patch.png | Bin 0 -> 1013 bytes docs/content/main.md | 6 +- docs/content/programming-guide/constraints.h | 24 ++++---- .../resources.md | 62 +++++++++++++++++++++ 6 files changed, 77 insertions(+), 15 deletions(-) create mode 100644 docs/content/images/resource/9-patch-full.png create mode 100644 docs/content/images/resource/9-patch-zoomed.png create mode 100644 docs/content/images/resource/9-patch.png create mode 100644 docs/content/shared-javascript-and-cpp-documentation/resources.md diff --git a/docs/content/images/resource/9-patch-full.png b/docs/content/images/resource/9-patch-full.png new file mode 100644 index 0000000000000000000000000000000000000000..3895bc857752a36d9f758e1455166f59b59ad57e GIT binary patch literal 1545 zcmeAS@N?(olHy`uVBq!ia0vp^CqS5k4M?tyST_$yu_bxCyDx`7I;J! zGca%qgD@k*tT_@uLG}_)Usv|~Y)t%ex)aQ0pD{47PV;ne45_&F_RiVt+uvmmeC*db z?HabkqHE>dTh$!On>jODzdrcOzWYk_w%dJ6H#qSp+Vwb`GH`4$QDm9VWcSvBBS(4n z*J)2pZsb+onz46>fobx5@)f^-|2%a}@W8|% z_u7QIx_>E4gMOZU_3Bmi)vT{;tM<;bwy^M!mR!HP#Om(3=bw9%HvU*YapJ`L&p-cs zEv^@n@$Y)$l+#aN_siM-%BZfkPM;%F?(FQmwfOnDvvIphGT%*YJahg$zg^v*ANLL& zI<#9*aQS^Z(Z%*!F0XxbXZ?)Ya#{ECldadUdmWd)-Rfbl>GD*6>y3zeJt116OM_ne zsZIX*^Xcj7xAj?#tgUZ{uMPXZYr}>QhfC_M)Xw+2|DC&BaN-P&=kKgjs zA1C}*@LGCl{<^rmzb^av%r*b@>zP$y&4;ur_ka4xd}&bG=Ix*SsQIDC_vMcdHnZFB zEPH!Pe>c<2*|Vj0*8l(4E+{zJUb_3&kFK2;gI^_2ond1y=Q-)f;dXxeowdKqb_t(& z_UzfyyLaz4KHQjO;`QH5w<_o{yMJ=U8j17sY^}F$+47}MeS+80Pmen~Ca$be(aaXL z-IcR+lElnY?k-1e-MXc3)wpK;`hHiJE$6QIbk6&>sB!JuwVfRu`+olX`7mws%+8J* zx*RR{fZ}e83yqW(<)^2sU$#v8^=DqQT>R#JSqb_1?|aX6vDO$jHaIvaChpY-i2yQDv6^0O!+hD4Q5km14L?ea}%seD_VF)1t=-+-O zNkg^@Pc@}Q_MVgUt^8G&F~#5P?|5PV$HzL5!)1w8{#SPw75zgQ(!463mogXGTb5+0 z_z6_}WO>PQNsL2A*27z&;KubZ9p=Wv*L&A_?-J$S_5RUa^$s8%zUJ`zEv!s;wXZ$A zUb8mh!zxj4g%4d2Vs)xP!IQ45b{~#MTqtcSvCTZ%^v>Gj`|1cbrdaJTv)Omw?hLSm)u&p!tPeDiszyToqy|uJr)Mckd=_A*uO0fSOlERFgdqohL~;ohm#pP>+_FZ zxNzawj~_qsm6a|D3YNdWm+Ry2zdv$i$TF$3N{clMAmL?@7Jvz5Gdi%NZyWaa=N}oA%CMG^6=Ff__ z_0M}IKh~Rn{`xs!=B$2vtas;hy?5@lfjeXDc5dAG@gp!pf=apD=jYqY=WM^N`S{6J zd&f&J%k-va^YHTO&ah($ literal 0 HcmV?d00001 diff --git a/docs/content/images/resource/9-patch-zoomed.png b/docs/content/images/resource/9-patch-zoomed.png new file mode 100644 index 0000000000000000000000000000000000000000..2196d660eec616a7354aecc57a050aef214c2697 GIT binary patch literal 2008 zcmbVNc{Cf?8c)=e+FP$$ZG&KzGiX}+7*dI99Mn=vmNbe8BD{#cbKc+Ye&^nM&UcsZckl1}-TQ}wy`{X&B^dw! zAa8Aja1!-?qPih{TGZ~G?*xjv(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VV|@Ka%>8BRxZ91a`Byziv#85;w!vz`$X|IY0NH#z%UXv#PO4NHrXHQUszPMiq}JS91;m`tX>VkA3EOAvCe zR~%2T*Z+_}EEda096>5r0HJcYU*tCImkJcbnV_KGNFazjgCr}Z<1Fa5`VU{jG8^{8 z{sw~~X}8;7OCZzJ(|Znw;}wo#_j3w#F|#b0v~jcOhizzR=&8%);*LE*@;vVz931?{ zb38;o<$>NB5K|gwEI}rb70ZJdu)MrHdhSB!yV@bF4@vFoi!SbA+y>14)wirb93@bw(T+u jQCB-kLGXe8p8x{@uMnIntroduction +

Introduction

Constraints are used to modify the property of an actor, based on other properties of the same actor; properties of the actor's parent; or properties of another actor altogether, when the modification needs to be at run-time. Custom functions or functors can be supplied, where the desired value of the property can be calculated. @@ -15,7 +15,7 @@ This means that Constraints override the values set by Animations. Not all properties can be used as a constraint input, please see Dali::Handle::IsPropertyAConstraintInput() for more details. -

When to use a Constraint

+

When to use a Constraint

Constraints are designed as a way of modifying properties that cannot be modified by any existing built in functionality; Like Animations, Size negotiation or Parent anchor, origin settings. As they provide the ability for the application developer to execute their own code within the update thread, DALi can no-longer guarantee the timeliness of this code, or how optimised it may be. @@ -60,13 +60,13 @@ Consider the following use cases as an example of when and when not to use a con For most general cases, the position and size requirements of a child or parent actor (from it's child or parent) can be calculated with Size Negotiation. -

Constraint Sources

+

Constraint Sources

These are properties of this (or another actor) that are used as inputs into the constraint. The constraint will take these values, optionally perform a calculation on them (if using a custom functor) and write the result to the specified property of the target actor. The source actor is specified as either the same actor, it's parent or another actor. -

Local Source

+

Local Source

A local source is based on the local properties (i.e. size, position, scale, orientation, color) of an actor. For example, the actor's orientation could be used as a constraint input source. @@ -75,7 +75,7 @@ For example, the actor's orientation could be used as a constraint input source. Dali::ConstraintSource source( Dali::LocalSource( Dali::Actor::Property::ORIENTATION ) ); @endcode -

Parent Source

+

Parent Source

A parent source is based on properties of the actor's parent. For example, a parent's position can be used as a constraint input source. @@ -84,7 +84,7 @@ For example, a parent's position can be used as a constraint input source. Dali::ConstraintSource source( Dali::ParentSource( Dali::Actor::Property::POSITION ) ); @endcode -

Source

+

Source

Finally, you can base your source on the properties of another handle altogether. For example, a sibling actor's color could be used as a constraint input source. @@ -93,7 +93,7 @@ For example, a sibling actor's color could be used as a constraint input source. Dali::ConstraintSource source( Dali::Source( anotherHandle, Dali::Actor::Property::COLOR ) ); @endcode -

The Constraint Function

+

The Constraint Function

The signature of the constraint function is: @@ -124,9 +124,9 @@ const Dali::Vector3& parentPosition( inputs[2]->GetVector3() ); const Dali::Vector3& parentSize( inputs[3]->GetVector3() ); @endcode -

Creating a Constraint

+

Creating a Constraint

-

Using C Functions

+

Using C Functions

If you do not have any data that is changed at runtime, then C functions should be used. For example, the color of an actor could be changed based on its position along the x-axis till a preset distance of 100, beyond which it is transparent. @@ -163,7 +163,7 @@ void MyConstraintFunction( Dali::Vector4& current, const Dali::PropertyInputCont Please have a look at Dali::Constraint::New() for more details. -

Using Functors

+

Using Functors

If you need to store some data in a struct/class, then a functor can be used. Reusing the last example, the color of an actor is changed based on its position along the x-axis, but the distance when it is transparent is different for each applied constraint. @@ -216,9 +216,9 @@ MyFunctor could then be used with another constraint with a different distance. Please have a look at Dali::Constraint::New(Handle, Property::Index, const T&) for more details. Instead of using the default functor, another method can be declared in the class or struct and used as the constraint function. -Please have a look at appropriate Dali::Constraint::New() method for more details. +Please have a look at the appropriate Dali::Constraint::New() method for more details. -

Removing Constraints

+

Removing Constraints

The actor's constraints can later be removed in several ways: diff --git a/docs/content/shared-javascript-and-cpp-documentation/resources.md b/docs/content/shared-javascript-and-cpp-documentation/resources.md new file mode 100644 index 0000000..50ca99b --- /dev/null +++ b/docs/content/shared-javascript-and-cpp-documentation/resources.md @@ -0,0 +1,62 @@ + +# Resources {#resoources} + +## Resource Image {#resource-image} + +A resource image is an image that is loaded using a file path or a URL. + +To create a resource image: +~~~{.cpp} +Dali::ResourceImage image = Dali::ResourceImage::New( "/my-path/my-image.png" ); +~~~ +Which can then be used with actors (e.g. ImageActor). + +Resources are loaded in separate threads. +The application can connect to the Dali::ResourceImage::LoadingFinishedSignal() to get notified when the image has loaded. + +By default, resource images start loading immediately and the data is released only when the ResourceImage handle is destroyed. +To optimise an application's memory footprint, the application can ask resources to be only loaded when actually required and +their data to be released automatically when they are no longer being used (not being used by Actors). +~~~{.cpp} +Dali::ResourceImage image = Dali::ResourceImage::New( "/my-path/my-image.png", Dali::ResourceImage::ON_DEMAND, Dali::Image::UNUSED ); +~~~ +If Dali::Image::UNUSED is used, then when the ResourceImage is used again, the resource data is reloaded automatically. + +If the application requires the image dimensions immediately, then they can be retrieved synchronously: +~~~{.cpp} +Dali::ImageDimensions dimensions = Dali::ResourceImage::GetImageSize( "/my-path/my-image.png" ); +~~~ +This is a disk read which can be slow and will block the event thread, so should only be used if absolutely necessary. + +## 9-Patch Image {#resource-9-patch} + +DALi has support for 9-patch images. +These are stretchable, repeatable images which are reduced to their smallest size. +Essentially, an image is sliced up into 9 squares and the four corners do not change size at all. +The other 5 segments are stretched (or repeated) to allow the whole image to scale appropriately. + +DALi has inbuilt support for *.9.png, *.9.jpg etc. images as well. +More information about these images can be found here: http://developer.android.com/tools/help/draw9patch.html + +The following is an example of a *.9.png image: +![ ](resource/9-patch.png) + +Zoomed in, the red section shows the part that will be repeated. +The four corners areas remain static. +The one pixel border will also be stripped out. +![ ](resource/9-patch-zoomed.png) + +And if the image is given a 200 by 200 size, it will look like the following: +![ ](resource/9-patch-full.png) + +## Buffer Image {#resource-buffer} + +A BufferImage represents an image resource in the form of a pixel buffer data that can be provided by the application developer. +The application can then write to this buffer as required and the image is updated on the screen. + +~~~{.cpp} +Dali::BufferImage image = Dali::BufferImage::New( 200, 200 ); // Creates a 200 by 200 pixel buffer with a color-depth of 32-bits (with alpha) +~~~ + +*/ -- 2.7.4