Commit 1e93137cfc5666f5345ba025240acea3a569da53
Committed by
Adeel Kazmi
1 parent
d4cfce30
Add Progress Bar Control Demo Application
Change-Id: I9a725b76acc387f114478eb5f0a626e211b285e6 Signed-off-by: shiva.jm <shiva.jm@samsung.com>
Showing
13 changed files
with
227 additions
and
1 deletions
com.samsung.dali-demo.xml
| ... | ... | @@ -172,4 +172,7 @@ |
| 172 | 172 | <ui-application appid="styling.example" exec="/usr/apps/com.samsung.dali-demo/bin/styling.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> |
| 173 | 173 | <label>Styling</label> |
| 174 | 174 | </ui-application> |
| 175 | + <ui-application appid="progress-bar.example" exec="/usr/apps/com.samsung.dali-demo/bin/progress-bar.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> | |
| 176 | + <label>Progress Bar</label> | |
| 177 | + </ui-application> | |
| 175 | 178 | </manifest> | ... | ... |
demo/dali-demo.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2014 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2016 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -82,6 +82,7 @@ int DALI_EXPORT_API main(int argc, char **argv) |
| 82 | 82 | demo.AddExample(Example("primitive-shapes.example", DALI_DEMO_STR_TITLE_PRIMITIVE_SHAPES)); |
| 83 | 83 | demo.AddExample(Example("styling.example", DALI_DEMO_STR_TITLE_STYLING)); |
| 84 | 84 | demo.AddExample(Example("sparkle.example", DALI_DEMO_STR_TITLE_SPARKLE)); |
| 85 | + demo.AddExample(Example("progress-bar.example", DALI_DEMO_STR_TITLE_PROGRESS_BAR)); | |
| 85 | 86 | |
| 86 | 87 | demo.SortAlphabetically( true ); |
| 87 | 88 | ... | ... |
examples/progress-bar/progress-bar-example.cpp
0 → 100644
| 1 | +/* | |
| 2 | + * Copyright (c) 2016 Samsung Electronics Co., Ltd. | |
| 3 | + * | |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 | + * you may not use this file except in compliance with the License. | |
| 6 | + * You may obtain a copy of the License at | |
| 7 | + * | |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | + * | |
| 10 | + * Unless required by applicable law or agreed to in writing, software | |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | + * See the License for the specific language governing permissions and | |
| 14 | + * limitations under the License. | |
| 15 | + * | |
| 16 | + */ | |
| 17 | + | |
| 18 | +#include "shared/view.h" | |
| 19 | +#include <dali-toolkit/dali-toolkit.h> | |
| 20 | +#include <dali-toolkit/devel-api/controls/progress-bar/progress-bar.h> | |
| 21 | + | |
| 22 | +using namespace Dali; | |
| 23 | +using namespace Dali::Toolkit; | |
| 24 | +using Dali::Toolkit::ProgressBar; | |
| 25 | + | |
| 26 | +namespace | |
| 27 | +{ | |
| 28 | + | |
| 29 | +const char* const BACKGROUND_IMAGE = DEMO_IMAGE_DIR "background-gradient.jpg"; | |
| 30 | +const char* const TOOLBAR_IMAGE = DEMO_IMAGE_DIR "top-bar.png"; | |
| 31 | +const char* const TOOLBAR_TITLE = "Progress Bar"; | |
| 32 | + | |
| 33 | +const Vector4 BACKGROUND_COLOUR( 1.0f, 1.0f, 1.0f, 0.15f ); | |
| 34 | + | |
| 35 | +// Layout sizes | |
| 36 | +const int MARGIN_SIZE = 10; | |
| 37 | +const int TOP_MARGIN = 85; | |
| 38 | + | |
| 39 | +} // namespace | |
| 40 | + | |
| 41 | +/** This example shows how to create and use PROGRESS BAR. | |
| 42 | + */ | |
| 43 | + | |
| 44 | +class ProgressBarExample: public ConnectionTracker | |
| 45 | +{ | |
| 46 | +public: | |
| 47 | + | |
| 48 | + ProgressBarExample( Application& application ) | |
| 49 | + : mApplication( application ) | |
| 50 | + { | |
| 51 | + // Connect to the Application's Init signal | |
| 52 | + mProgressValue = 0.0f; | |
| 53 | + mApplication.InitSignal().Connect( this, &ProgressBarExample::Create ); | |
| 54 | + } | |
| 55 | + | |
| 56 | + ~ProgressBarExample() | |
| 57 | + { | |
| 58 | + // Nothing to do here | |
| 59 | + } | |
| 60 | + | |
| 61 | + void Create( Application& application ) | |
| 62 | + { | |
| 63 | + // The Init signal is received once (only) during the Application lifetime | |
| 64 | + | |
| 65 | + // Respond to key events | |
| 66 | + Stage::GetCurrent().KeyEventSignal().Connect( this, &ProgressBarExample::OnKeyEvent ); | |
| 67 | + | |
| 68 | + // Creates a default view with a default tool bar. | |
| 69 | + // The view is added to the stage. | |
| 70 | + | |
| 71 | + mContentLayer = DemoHelper::CreateView( application, | |
| 72 | + mView, | |
| 73 | + mToolBar, | |
| 74 | + BACKGROUND_IMAGE, | |
| 75 | + TOOLBAR_IMAGE, | |
| 76 | + TOOLBAR_TITLE ); | |
| 77 | + | |
| 78 | + mProgressBar = ProgressBar::New(); | |
| 79 | + mProgressBar.SetParentOrigin(ParentOrigin::TOP_CENTER); | |
| 80 | + mProgressBar.SetAnchorPoint(AnchorPoint::TOP_CENTER); | |
| 81 | + mProgressBar.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH); | |
| 82 | + mProgressBar.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT); | |
| 83 | + | |
| 84 | + Toolkit::TableView contentTable = Toolkit::TableView::New(2, 1); | |
| 85 | + contentTable.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH); | |
| 86 | + contentTable.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT); | |
| 87 | + contentTable.SetAnchorPoint(AnchorPoint::TOP_LEFT); | |
| 88 | + contentTable.SetParentOrigin(ParentOrigin::TOP_LEFT); | |
| 89 | + contentTable.SetCellPadding(Size(MARGIN_SIZE, MARGIN_SIZE * 0.5f)); | |
| 90 | + | |
| 91 | + for( unsigned int i = 0; i < contentTable.GetRows(); ++i ) | |
| 92 | + { | |
| 93 | + contentTable.SetFitHeight( i ); | |
| 94 | + } | |
| 95 | + | |
| 96 | + contentTable.SetPosition( 0.0f, TOP_MARGIN ); | |
| 97 | + mContentLayer.Add( contentTable ); | |
| 98 | + | |
| 99 | + // Image selector for progress bar | |
| 100 | + Toolkit::TableView progressBackground = Toolkit::TableView::New( 1, 1 ); | |
| 101 | + progressBackground.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); | |
| 102 | + progressBackground.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT ); | |
| 103 | + progressBackground.SetBackgroundColor( BACKGROUND_COLOUR ); | |
| 104 | + progressBackground.SetCellPadding( Size( MARGIN_SIZE, MARGIN_SIZE ) ); | |
| 105 | + progressBackground.SetRelativeWidth( 0, 1.0f ); | |
| 106 | + progressBackground.SetFitHeight( 0 ); | |
| 107 | + contentTable.Add( progressBackground ); | |
| 108 | + progressBackground.Add( mProgressBar ); | |
| 109 | + | |
| 110 | + // Create buttons | |
| 111 | + Toolkit::TableView buttonBackground = Toolkit::TableView::New( 2, 1 ); | |
| 112 | + buttonBackground.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); | |
| 113 | + buttonBackground.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT ); | |
| 114 | + buttonBackground.SetBackgroundColor( BACKGROUND_COLOUR ); | |
| 115 | + buttonBackground.SetCellPadding( Size( MARGIN_SIZE, MARGIN_SIZE ) ); | |
| 116 | + | |
| 117 | + for( unsigned int i = 0; i < buttonBackground.GetRows(); ++i ) | |
| 118 | + { | |
| 119 | + buttonBackground.SetFitHeight( i ); | |
| 120 | + } | |
| 121 | + | |
| 122 | + contentTable.Add( buttonBackground ); | |
| 123 | + | |
| 124 | + mSetProgressButton = Toolkit::PushButton::New(); | |
| 125 | + mSetProgressButton.SetLabelText( "Set Progress" ); | |
| 126 | + mSetProgressButton.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); | |
| 127 | + mSetProgressButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT ); | |
| 128 | + mSetProgressButton.ClickedSignal().Connect( this, &ProgressBarExample::OnSetProgressButtonSelected ); | |
| 129 | + | |
| 130 | + buttonBackground.Add( mSetProgressButton ); | |
| 131 | + | |
| 132 | + mResetProgressButton = Toolkit::PushButton::New(); | |
| 133 | + mResetProgressButton.SetLabelText( "Reset Progress" ); | |
| 134 | + mResetProgressButton.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); | |
| 135 | + mResetProgressButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT ); | |
| 136 | + mResetProgressButton.ClickedSignal().Connect( this, &ProgressBarExample::OnResetProgressButtonSelected ); | |
| 137 | + | |
| 138 | + buttonBackground.Add( mResetProgressButton ); | |
| 139 | + } | |
| 140 | + | |
| 141 | + bool OnResetProgressButtonSelected( Toolkit::Button button ) | |
| 142 | + { | |
| 143 | + mProgressValue = 0.0f; | |
| 144 | + mProgressBar.SetProperty(ProgressBar::Property::PROGRESS_VALUE, 0.0f); | |
| 145 | + return true; | |
| 146 | + } | |
| 147 | + | |
| 148 | + bool OnSetProgressButtonSelected( Toolkit::Button button ) | |
| 149 | + { | |
| 150 | + mProgressValue += 0.1f; | |
| 151 | + mProgressBar.SetProperty(ProgressBar::Property::PROGRESS_VALUE, mProgressValue); | |
| 152 | + return true; | |
| 153 | + } | |
| 154 | + | |
| 155 | + void OnKeyEvent( const KeyEvent& event ) | |
| 156 | + { | |
| 157 | + if( event.state == KeyEvent::Down ) | |
| 158 | + { | |
| 159 | + if( IsKey( event, Dali::DALI_KEY_ESCAPE ) || IsKey( event, Dali::DALI_KEY_BACK ) ) | |
| 160 | + { | |
| 161 | + // Exit application when click back or escape. | |
| 162 | + mApplication.Quit(); | |
| 163 | + } | |
| 164 | + } | |
| 165 | + } | |
| 166 | + | |
| 167 | +private: | |
| 168 | + | |
| 169 | + Application& mApplication; | |
| 170 | + Toolkit::Control mView; ///< The View instance. | |
| 171 | + Toolkit::ToolBar mToolBar; ///< The View's Toolbar. | |
| 172 | + Layer mContentLayer; ///< Content layer. | |
| 173 | + ProgressBar mProgressBar; | |
| 174 | + Toolkit::PushButton mSetProgressButton; | |
| 175 | + Toolkit::PushButton mResetProgressButton; | |
| 176 | + float mProgressValue; | |
| 177 | +}; | |
| 178 | + | |
| 179 | +void RunTest( Application& application ) | |
| 180 | +{ | |
| 181 | + ProgressBarExample test( application ); | |
| 182 | + application.MainLoop(); | |
| 183 | +} | |
| 184 | + | |
| 185 | +// Entry point for Linux & Tizen applications | |
| 186 | +int DALI_EXPORT_API main( int argc, char **argv ) | |
| 187 | +{ | |
| 188 | + Application application = Application::New( &argc, &argv, DEMO_THEME_PATH ); | |
| 189 | + | |
| 190 | + RunTest( application ); | |
| 191 | + | |
| 192 | + return 0; | |
| 193 | +} | ... | ... |
resources/po/as.po
resources/po/de.po
| ... | ... | @@ -88,6 +88,9 @@ msgstr "Seite wechseln" |
| 88 | 88 | msgid "DALI_DEMO_STR_TITLE_POPUP" |
| 89 | 89 | msgstr "Popup-Menü" |
| 90 | 90 | |
| 91 | +msgid "DALI_DEMO_STR_TITLE_PROGRESS_BAR" | |
| 92 | +msgstr "Fortschrittsanzeige" | |
| 93 | + | |
| 91 | 94 | msgid "DALI_DEMO_STR_TITLE_PRIMITIVE_SHAPES" |
| 92 | 95 | msgstr "Grundformen" |
| 93 | 96 | ... | ... |
resources/po/en_GB.po
resources/po/en_US.po
resources/po/es.po
| ... | ... | @@ -88,6 +88,9 @@ msgstr "Vista de páginas" |
| 88 | 88 | msgid "DALI_DEMO_STR_TITLE_POPUP" |
| 89 | 89 | msgstr "Popup" |
| 90 | 90 | |
| 91 | +msgid "DALI_DEMO_STR_TITLE_PROGRESS_BAR" | |
| 92 | +msgstr "Barra de progreso" | |
| 93 | + | |
| 91 | 94 | msgid "DALI_DEMO_STR_TITLE_PRIMITIVE_SHAPES" |
| 92 | 95 | msgstr "Primitvas 3D" |
| 93 | 96 | ... | ... |
resources/po/ko.po
resources/po/ml.po
| ... | ... | @@ -88,6 +88,9 @@ msgstr "പേജ് ലേഔട്ട്" |
| 88 | 88 | msgid "DALI_DEMO_STR_TITLE_POPUP" |
| 89 | 89 | msgstr "പോപപ്പ് മെനുവിൽ" |
| 90 | 90 | |
| 91 | +msgid "DALI_DEMO_STR_TITLE_PROGRESS_BAR" | |
| 92 | +msgstr "പ്രോഗ്രസ് ബാർ" | |
| 93 | + | |
| 91 | 94 | msgid "DALI_DEMO_STR_TITLE_PRIMITIVE_SHAPES" |
| 92 | 95 | msgstr "അടിസ്ഥാന രൂപങ്ങൾ" |
| 93 | 96 | ... | ... |
resources/po/ur.po
resources/po/zn_CH.po
shared/dali-demo-strings.h
| ... | ... | @@ -62,6 +62,7 @@ extern "C" |
| 62 | 62 | #define DALI_DEMO_STR_TITLE_NEGOTIATE_SIZE dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_NEGOTIATE_SIZE") |
| 63 | 63 | #define DALI_DEMO_STR_TITLE_PAGE_TURN_VIEW dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_PAGE_TURN_VIEW") |
| 64 | 64 | #define DALI_DEMO_STR_TITLE_POPUP dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_POPUP") |
| 65 | +#define DALI_DEMO_STR_TITLE_PROGRESS_BAR dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_PROGRESS_BAR") | |
| 65 | 66 | #define DALI_DEMO_STR_TITLE_PRIMITIVE_SHAPES dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_PRIMITIVE_SHAPES") |
| 66 | 67 | #define DALI_DEMO_STR_TITLE_RADIAL_MENU dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_RADIAL_MENU") |
| 67 | 68 | #define DALI_DEMO_STR_TITLE_REFRACTION dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_REFRACTION") |
| ... | ... | @@ -127,6 +128,7 @@ extern "C" |
| 127 | 128 | #define DALI_DEMO_STR_TITLE_TEXT_LABEL_MULTI_LANGUAGE "Text Scripts" |
| 128 | 129 | #define DALI_DEMO_STR_TITLE_TEXT_SCROLLING "Text Scrolling" |
| 129 | 130 | #define DALI_DEMO_STR_TITLE_TILT_SENSOR "Tilt Sensor" |
| 131 | +#define DALI_DEMO_STR_TITLE_PROGRESS_BAR "Progress Bar" | |
| 130 | 132 | |
| 131 | 133 | #endif |
| 132 | 134 | ... | ... |