From: Xiangyin Ma Date: Fri, 8 Jul 2016 15:25:40 +0000 (+0100) Subject: Clean up more ResourceImage Usage X-Git-Tag: dali_1.1.43~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F97%2F79197%2F4;hp=0b676857adc3e57f13586abb857f1c3a172d49a6;p=platform%2Fcore%2Fuifw%2Fdali-demo.git Clean up more ResourceImage Usage Change-Id: Iaefcd75232bb19ed72555960bea8732b34e07937 --- diff --git a/.gitignore b/.gitignore index 9a6f694..4f0ee13 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,4 @@ dali-builder /packaging/home* *.mo demo-theme.json +simple-image-wall.js diff --git a/build/tizen/CMakeLists.txt b/build/tizen/CMakeLists.txt index 8a05b1f..11b2fec 100644 --- a/build/tizen/CMakeLists.txt +++ b/build/tizen/CMakeLists.txt @@ -76,7 +76,7 @@ FOREACH(flag ${LOCAL_MODELS_LIST}) INSTALL(FILES ${LOCAL_MODELS_DIR}/${flag} DESTINATION ${MODELS_DIR}) ENDFOREACH(flag) -FILE(GLOB LOCAL_SCRIPTS_LIST RELATIVE "${LOCAL_SCRIPTS_DIR}" "${LOCAL_SCRIPTS_DIR}/*") +FILE(GLOB LOCAL_SCRIPTS_LIST RELATIVE "${LOCAL_SCRIPTS_DIR}" "${LOCAL_SCRIPTS_DIR}/*.json") FOREACH(flag ${LOCAL_SCRIPTS_LIST}) INSTALL(FILES ${LOCAL_SCRIPTS_DIR}/${flag} DESTINATION ${SCRIPTS_DIR}) ENDFOREACH(flag) @@ -85,6 +85,8 @@ ENDFOREACH(flag) SET(DEMO_STYLE_IMAGE_DIR ${IMAGES_DIR}) CONFIGURE_FILE( ${LOCAL_STYLE_DIR}/demo-theme.json.in ${LOCAL_STYLE_DIR}/demo-theme.json ) INSTALL(FILES ${LOCAL_STYLE_DIR}/demo-theme.json DESTINATION ${STYLE_DIR}) +CONFIGURE_FILE( ${LOCAL_SCRIPTS_DIR}/simple-image-wall.js.in ${LOCAL_SCRIPTS_DIR}/simple-image-wall.js ) +INSTALL(FILES ${LOCAL_SCRIPTS_DIR}/simple-image-wall.js DESTINATION ${SCRIPTS_DIR}) SET(PKG_LIST dali-core dali-adaptor diff --git a/examples/image-view/image-view-example.cpp b/examples/image-view/image-view-example.cpp index 89bd8d6..15d37e8 100644 --- a/examples/image-view/image-view-example.cpp +++ b/examples/image-view/image-view-example.cpp @@ -35,15 +35,7 @@ const char* IMAGE_PATH[] = { DEMO_IMAGE_DIR "heartsframe.9.png", }; -const char* RESOURCE_IMAGE_PATH[] = { - DEMO_IMAGE_DIR "contacts-image.png", - DEMO_IMAGE_DIR "gallery-small-27.jpg", - DEMO_IMAGE_DIR "selection-popup-bg.8.9.png", - DEMO_IMAGE_DIR "heartsframe.9.png", -}; - const unsigned int NUM_IMAGES = sizeof(IMAGE_PATH) / sizeof(char*); -const unsigned int NUM_RESOURCE_IMAGES = sizeof(RESOURCE_IMAGE_PATH) / sizeof(char*); const unsigned int COLUMNS = 3; const unsigned int ROWS = 4; @@ -59,7 +51,6 @@ class ImageViewController: public ConnectionTracker mCurrentPositionToggle( 0, 0 ), mCurrentPositionImage( 0, 0 ), mToggleOff( true ), - mUseResource( false ), mImageIdx( 1 ) { // Connect to the Application's Init signal @@ -131,14 +122,6 @@ class ImageViewController: public ConnectionTracker button2.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); buttonsTable.AddChild( button2, Toolkit::TableView::CellPosition( 1, 0 ) ); - Toolkit::CheckBoxButton button3 = Toolkit::CheckBoxButton::New(); - button3.SetLabelText( "Use Resource Images" ); - button3.SetParentOrigin( ParentOrigin::CENTER ); - button3.SetAnchorPoint( AnchorPoint::CENTER ); - button3.ClickedSignal().Connect( this, &ImageViewController::UseResourceImagesClicked ); - button3.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); - buttonsTable.AddChild( button3, Toolkit::TableView::CellPosition( 2, 0 ) ); - mContentLayer.Add(buttonsTable); Stage::GetCurrent().KeyEventSignal().Connect(this, &ImageViewController::OnKeyEvent); @@ -177,15 +160,7 @@ private: { Toolkit::ImageView imageView = mImageViews[ mCurrentPositionImage.columnIndex ][ mCurrentPositionImage.rowIndex ]; - if( mUseResource ) - { - ResourceImage image = ResourceImage::New( RESOURCE_IMAGE_PATH[ mImageIdx ] ); - imageView.SetImage( image ); - } - else - { - imageView.SetImage( IMAGE_PATH[ mImageIdx ] ); - } + imageView.SetImage( IMAGE_PATH[ mImageIdx ] ); ++mCurrentPositionImage.columnIndex; if( mCurrentPositionImage.columnIndex == COLUMNS ) @@ -198,8 +173,7 @@ private: mCurrentPositionImage.rowIndex = 0; ++mImageIdx; - int numImages = mUseResource ? NUM_RESOURCE_IMAGES : NUM_IMAGES; - if( mImageIdx == numImages ) + if( mImageIdx == NUM_IMAGES ) { mImageIdx = 0; } @@ -208,19 +182,6 @@ private: return true; } - bool UseResourceImagesClicked( Toolkit::Button button ) - { - mUseResource = !mUseResource; - - int numImages = mUseResource ? NUM_RESOURCE_IMAGES : NUM_IMAGES; - if( mImageIdx >= numImages ) - { - mImageIdx = 0; - } - - return true; - } - /** * Main key event handler */ @@ -248,7 +209,6 @@ private: Toolkit::TableView::CellPosition mCurrentPositionImage; bool mToggleOff; - bool mUseResource; int mImageIdx; }; diff --git a/resources/scripts/simple-image-wall.js b/resources/scripts/simple-image-wall.js.in similarity index 59% rename from resources/scripts/simple-image-wall.js rename to resources/scripts/simple-image-wall.js.in index 2620865..36aba3f 100644 --- a/resources/scripts/simple-image-wall.js +++ b/resources/scripts/simple-image-wall.js.in @@ -2,27 +2,12 @@ // // Example usage of Dali API // -// -// -// get the dali-demo image directory path -// hard code for the device to /usr/apps/com.samsung.dali-demo/images/ -var imageDir = dali.DALI_DATA_DIRECTORY; - -if (imageDir != "/usr/share/dali//") { - imageDir = imageDir.substring(0, imageDir.lastIndexOf("dali/")); - imageDir += "com.samsung.dali-demo/images/"; -} else // on device -{ - imageDir = "/usr/apps/com.samsung.dali-demo/images/"; -} +var imageDir = "@DEMO_STYLE_IMAGE_DIR@"; var NUMBER_OF_IMAGES = 40; // for now use 16 ( demo files go up to 30) -var DEMO_IMAGES = []; // array to store Dali Images -var VIDEO_WALL_ACTORS = []; // array to store Image actors var VIDEO_WALL_ROWS = 7; // use 3 rows for the video wall var VIDEO_WALL_COLUMNS = 12; // use 12 columns for the video wall -var VIDEO_WALL_TOTAL_ITEMS = VIDEO_WALL_COLUMNS * VIDEO_WALL_ROWS; // total items var VIDEO_WALL_ITEM_SIZE = 128; // width / height of a item in the video wall var BORDER_SIZE = 5; var VIDEO_WALL_ITEM_SIZE_NO_BORDER = VIDEO_WALL_ITEM_SIZE - BORDER_SIZE; @@ -39,14 +24,6 @@ daliApp.getFileName = function(index) { return fileName; } -// load the images -daliApp.loadImages = function() { - for (index = 0; index < NUMBER_OF_IMAGES; ++index) { - fileName = imageDir + daliApp.getFileName(index); - DEMO_IMAGES[index] = new dali.ResourceImage( { url:fileName } ); - } -} - daliApp.createRootActor = function() { wallRootActor = new dali.Actor(); wallRootActor.parentOrigin = dali.CENTER; @@ -54,8 +31,6 @@ daliApp.createRootActor = function() { dali.stage.add(wallRootActor); } - - daliApp.getWallActorIndex = function(x, y) { return x + y * VIDEO_WALL_COLUMNS; } @@ -67,16 +42,16 @@ daliApp.createActors = function() { for (x = 0; x < VIDEO_WALL_COLUMNS; ++x) { var actorIndex = daliApp.getWallActorIndex(x, y); - var imageActor = new dali.ImageActor(); + var imageView = new dali.Control("ImageView"); // wrap image index between 0 and NUMBER_OF_IMAGES var imageIndex = actorIndex % NUMBER_OF_IMAGES; - imageActor.setImage(DEMO_IMAGES[imageIndex]); + imageView.image = imageDir + daliApp.getFileName(imageIndex); - imageActor.parentOrigin = dali.CENTER; - imageActor.anchorPoint = dali.CENTER; - imageActor.size = [VIDEO_WALL_ITEM_SIZE_NO_BORDER, VIDEO_WALL_ITEM_SIZE_NO_BORDER, 1.0]; // start with zero size so it zooms up + imageView.parentOrigin = dali.CENTER; + imageView.anchorPoint = dali.CENTER; + imageView.size = [VIDEO_WALL_ITEM_SIZE_NO_BORDER, VIDEO_WALL_ITEM_SIZE_NO_BORDER, 1.0]; // start with zero size so it zooms up var xPosition = x * VIDEO_WALL_ITEM_SIZE; // as the middle the wall is at zero (relative to wallRootActor), we need to subtract half the wall width. @@ -86,23 +61,16 @@ daliApp.createActors = function() { var yPosition = y * VIDEO_WALL_ITEM_SIZE; yPosition = yPosition - (VIDEO_WALL_HEIGHT / 2) + (VIDEO_WALL_ITEM_SIZE / 2); - imageActor.position = [xPosition, yPosition, 0.0]; - // store the actor - VIDEO_WALL_ACTORS[actorIndex] = imageActor; + imageView.position = [xPosition, yPosition, 0.0]; // Add to the video wall root actor. - wallRootActor.add(imageActor); + wallRootActor.add(imageView); } } } function Initialise() { - - daliApp.loadImages(); - daliApp.createActors(); - - } Initialise();