projects
/
platform
/
core
/
uifw
/
dali-toolkit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Text-related Programming guide updates
[platform/core/uifw/dali-toolkit.git]
/
docs
/
content
/
programming-guide
/
hello-world.h
diff --git
a/docs/content/programming-guide/hello-world.h
b/docs/content/programming-guide/hello-world.h
index
8031d99
..
2065659
100644
(file)
--- a/
docs/content/programming-guide/hello-world.h
+++ b/
docs/content/programming-guide/hello-world.h
@@
-12,56
+12,71
@@
Let's take a look at the code for this test application.
<h2 class="pg"> Example code </h2>
\code
<h2 class="pg"> Example code </h2>
\code
-#include <dali/dali.h>
-using namespace Dali;
+#include <dali-toolkit/dali-toolkit.h>
-/******************************************************
- * Demonstrates how to display "Hello World" on screen
- ******************************************************/
+using namespace Dali;
+using Dali::Toolkit::TextLabel;
-class ExampleApp
+// This example shows how to create and display Hello World! using a simple TextActor
+//
+class HelloWorldController : public ConnectionTracker
{
public:
{
public:
- ExampleApp(Application &app)
- : mApp(app)
+
+ HelloWorldController( Application& application )
+ : mApplication( application )
{
{
- // Connect to
Dali::Application init signal. Do not make calls to Dali before this signal is received.
-
app.SignalInit().Connect(this, &ExampleApp::Create
);
+ // Connect to
the Application's Init signal
+
mApplication.InitSignal().Connect( this, &HelloWorldController::Create
);
}
}
- ~
ExampleApp
()
+ ~
HelloWorldController
()
{
{
- // Remove Hello World
TextA
ctor from stage
- Stage::GetCurrent().Remove(mText
Actor
);
+ // Remove Hello World
a
ctor from stage
+ Stage::GetCurrent().Remove(mText
Label
);
}
}
-public:
-
- void Create(Application& app)
+ // The Init signal is received once (only) during the Application lifetime
+ void Create( Application& application )
{
{
- // Initialize the actor
- mTextActor = TextActor::New("Hello World");
+ // Get a handle to the stage
+ Stage stage = Stage::GetCurrent();
+
+ mTextLabel = TextLabel::New( "Hello World" );
+ mTextLabel.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ stage.Add( mTextLabel );
- // Center the actor. Note: default anchor point is CENTER
- mTextActor.SetParentOrigin(ParentOrigin::CENTER);
+ // Respond to a click anywhere on the stage
+ stage.GetRootLayer().TouchedSignal().Connect( this, &HelloWorldController::OnTouch );
+ }
- // Display the actor on the stage
- Stage::GetCurrent().Add(mTextActor);
+ bool OnTouch( Actor actor, const TouchEvent& touch )
+ {
+ // quit the application
+ mApplication.Quit();
+ return true;
}
private:
}
private:
- Application&
mApp
;
- Text
Actor mTextActor
;
+ Application&
mApplication
;
+ Text
Label mTextLabel
;
};
};
-int
-main(int argc, char **argv)
+void RunTest( Application& application )
+{
+ HelloWorldController test( application );
+
+ application.MainLoop();
+}
+
+// Entry point for Linux & Tizen applications
+//
+int main( int argc, char **argv )
{
{
- Application
daliApp(&argc, &argv
);
+ Application
application = Application::New( &argc, &argv
);
- ExampleApp helloApp (daliApp);
- daliApp.MainLoop();
+ RunTest( application );
return 0;
}
return 0;
}
@@
-85,10
+100,10
@@
main(int argc, char **argv)
That's why we store the Actor's handle:
\code
...
That's why we store the Actor's handle:
\code
...
- mText
Actor = TextActor
::New("Hello World");
+ mText
Label = TextLabel
::New("Hello World");
...
\endcode
...
\endcode
- Even if the Text
Actor
is removed from the stage, it will be kept alive through our reference.\n
+ Even if the Text
Label
is removed from the stage, it will be kept alive through our reference.\n
You can read more about implicit smart-pointer semantics in chapter \link handle-body-idiom Handle – body\endlink.
<h2 class="pg"> Main loop </h2>
You can read more about implicit smart-pointer semantics in chapter \link handle-body-idiom Handle – body\endlink.
<h2 class="pg"> Main loop </h2>
@@
-107,6
+122,12
@@
main(int argc, char **argv)
After running './hello' this should be visible on the screen:
After running './hello' this should be visible on the screen:
- \image html Text-Actor.png "Hello world example"
+<table border=0 cellpadding=10>
+<tr>
+ <td>
+ \image html Text-Label.png "Hello world example"
+ </td>
+</tr>
+</table>
*/
*/