Commit e741d5417c0562be266b4ccf76d152d446451019
1 parent
fe211667
Example of setting PixelArea in ImageView
Change-Id: I488842dcec638e1d290142b143a11e82945eb3c3
Showing
4 changed files
with
133 additions
and
0 deletions
com.samsung.dali-demo.xml
| ... | ... | @@ -127,4 +127,7 @@ |
| 127 | 127 | <ui-application appid="image-view.example" exec="/usr/apps/com.samsung.dali-demo/bin/image-view.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> |
| 128 | 128 | <label>Image View</label> |
| 129 | 129 | </ui-application> |
| 130 | + <ui-application appid="image-view-pixel-area.example" exec="/usr/apps/com.samsung.dali-demo/bin/image-view-pixel-area.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> | |
| 131 | + <label>ImageView Pixel Area</label> | |
| 132 | + </ui-application> | |
| 130 | 133 | </manifest> | ... | ... |
demo/dali-demo.cpp
| ... | ... | @@ -69,6 +69,7 @@ int main(int argc, char **argv) |
| 69 | 69 | demo.AddExample(Example("line-mesh.example", DALI_DEMO_STR_TITLE_LINE_MESH)); |
| 70 | 70 | demo.AddExample(Example("gradients.example", DALI_DEMO_STR_TITLE_COLOR_GRADIENT)); |
| 71 | 71 | demo.AddExample(Example("image-view.example", DALI_DEMO_STR_TITLE_IMAGE_VIEW)); |
| 72 | + demo.AddExample(Example("image-view-pixel-area.example", DALI_DEMO_STR_TITLE_IMAGE_VIEW_PIXEL_AREA)); | |
| 72 | 73 | demo.AddExample(Example("super-blur-bloom.example", DALI_DEMO_STR_TITLE_SUPER_BLUR_BLOOM)); |
| 73 | 74 | |
| 74 | 75 | demo.SortAlphabetically( true ); | ... | ... |
examples/image-view-pixel-area/image-view-pixel-area-example.cpp
0 → 100644
| 1 | +/* | |
| 2 | + * Copyright (c) 2015 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 <dali-toolkit/dali-toolkit.h> | |
| 19 | + | |
| 20 | +using namespace Dali; | |
| 21 | + | |
| 22 | +namespace | |
| 23 | +{ | |
| 24 | +const char* IMAGE_PATH[] = { DALI_IMAGE_DIR "gallery-large-7.jpg", | |
| 25 | + DALI_IMAGE_DIR "gallery-large-12.jpg", | |
| 26 | + DALI_IMAGE_DIR "gallery-large-18.jpg" }; | |
| 27 | + | |
| 28 | +const unsigned int NUM_IMAGES = sizeof(IMAGE_PATH) / sizeof(char*); | |
| 29 | +} | |
| 30 | + | |
| 31 | +class ImageViewPixelAreaApp : public ConnectionTracker | |
| 32 | +{ | |
| 33 | +public: | |
| 34 | + ImageViewPixelAreaApp( Application& application ) | |
| 35 | + : mApplication( application ), | |
| 36 | + mIndex(0u) | |
| 37 | + { | |
| 38 | + // Connect to the Application's Init signal | |
| 39 | + mApplication.InitSignal().Connect( this, &ImageViewPixelAreaApp::Create ); | |
| 40 | + } | |
| 41 | + | |
| 42 | + ~ImageViewPixelAreaApp() | |
| 43 | + { | |
| 44 | + // Nothing to do here; | |
| 45 | + } | |
| 46 | + | |
| 47 | +private: | |
| 48 | + // The Init signal is received once (only) during the Application lifetime | |
| 49 | + void Create( Application& application ) | |
| 50 | + { | |
| 51 | + // Get a handle to the stage | |
| 52 | + Stage stage = Stage::GetCurrent(); | |
| 53 | + stage.KeyEventSignal().Connect(this, &ImageViewPixelAreaApp::OnKeyEvent); | |
| 54 | + | |
| 55 | + ImageDimensions size( 510, 510 ); | |
| 56 | + float subSize = 170.f; | |
| 57 | + float relativeSubSize = 0.33; | |
| 58 | + Animation animation = Animation::New( 10.f ); | |
| 59 | + for( int i=0; i<3;i++ ) | |
| 60 | + for( int j=0; j<3; j++ ) | |
| 61 | + { | |
| 62 | + mImageView[i][j] = Toolkit::ImageView::New( IMAGE_PATH[mIndex], size ); | |
| 63 | + mImageView[i][j].SetParentOrigin( ParentOrigin::CENTER ); | |
| 64 | + mImageView[i][j].SetAnchorPoint(AnchorPoint::CENTER ); | |
| 65 | + mImageView[i][j].SetPosition( subSize*(i-1)*1.1f, subSize*(j-1)*1.1f ); | |
| 66 | + mImageView[i][j].SetSize( subSize, subSize ); | |
| 67 | + stage.Add(mImageView[i][j]); | |
| 68 | + | |
| 69 | + animation.AnimateTo( Property(mImageView[i][j], Toolkit::ImageView::Property::PIXEL_AREA), | |
| 70 | + Vector4( relativeSubSize*i, relativeSubSize*j, relativeSubSize, relativeSubSize ), | |
| 71 | + AlphaFunction::BOUNCE ); | |
| 72 | + } | |
| 73 | + animation.SetLooping( true ); | |
| 74 | + animation.Play(); | |
| 75 | + | |
| 76 | + // Respond to a click anywhere on the stage | |
| 77 | + stage.GetRootLayer().TouchedSignal().Connect( this, &ImageViewPixelAreaApp::OnTouch ); | |
| 78 | + } | |
| 79 | + | |
| 80 | + bool OnTouch( Actor actor, const TouchEvent& touch ) | |
| 81 | + { | |
| 82 | + const TouchPoint &point = touch.GetPoint(0); | |
| 83 | + if(point.state == TouchPoint::Down) | |
| 84 | + { | |
| 85 | + mIndex++; | |
| 86 | + for( int i=0; i<3;i++ ) | |
| 87 | + for( int j=0; j<3; j++ ) | |
| 88 | + { | |
| 89 | + mImageView[i][j].SetImage( IMAGE_PATH[mIndex%NUM_IMAGES] ); | |
| 90 | + } | |
| 91 | + } | |
| 92 | + return true; | |
| 93 | + } | |
| 94 | + | |
| 95 | + void OnKeyEvent(const KeyEvent& event) | |
| 96 | + { | |
| 97 | + if(event.state == KeyEvent::Down) | |
| 98 | + { | |
| 99 | + if( IsKey( event, Dali::DALI_KEY_ESCAPE) || IsKey( event, Dali::DALI_KEY_BACK) ) | |
| 100 | + { | |
| 101 | + mApplication.Quit(); | |
| 102 | + } | |
| 103 | + } | |
| 104 | + } | |
| 105 | + | |
| 106 | +private: | |
| 107 | + Application& mApplication; | |
| 108 | + Toolkit::ImageView mImageView[3][3]; | |
| 109 | + unsigned int mIndex; | |
| 110 | +}; | |
| 111 | + | |
| 112 | +void RunTest( Application& application ) | |
| 113 | +{ | |
| 114 | + ImageViewPixelAreaApp test( application ); | |
| 115 | + | |
| 116 | + application.MainLoop(); | |
| 117 | +} | |
| 118 | + | |
| 119 | +// Entry point for Linux & Tizen applications | |
| 120 | +// | |
| 121 | +int main( int argc, char **argv ) | |
| 122 | +{ | |
| 123 | + Application application = Application::New( &argc, &argv ); | |
| 124 | + | |
| 125 | + RunTest( application ); | |
| 126 | + | |
| 127 | + return 0; | |
| 128 | +} | ... | ... |
shared/dali-demo-strings.h
| ... | ... | @@ -98,6 +98,7 @@ extern "C" |
| 98 | 98 | #define DALI_DEMO_STR_TITLE_LINE_MESH "Mesh Line" |
| 99 | 99 | #define DALI_DEMO_STR_TITLE_COLOR_GRADIENT "Color Gradient" |
| 100 | 100 | #define DALI_DEMO_STR_TITLE_IMAGE_VIEW "Image View" |
| 101 | +#define DALI_DEMO_STR_TITLE_IMAGE_VIEW_PIXEL_AREA "Image View Pixel Area" | |
| 101 | 102 | #define DALI_DEMO_STR_TITLE_SUPER_BLUR_BLOOM "Super Blur and Bloom" |
| 102 | 103 | |
| 103 | 104 | #endif | ... | ... |