CMakeFiles/
cmake_install.cmake
demo/dali-demo
+examples-reel/dali-examples
install_manifest.txt
/demo/dali-demo
/demo/dali-examples
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS}")
INCLUDE_DIRECTORIES(${ROOT_SRC_DIR})
-#INCLUDE_DIRECTORIES(${DEMO_SRC_DIR})
ADD_SUBDIRECTORY(demo)
ADD_SUBDIRECTORY(examples)
+ADD_SUBDIRECTORY(examples-reel)
ADD_SUBDIRECTORY(builder)
AUX_SOURCE_DIRECTORY(${DEMO_SRC_DIR} DEMO_SRCS)
-SET(DEMO_SRCS ${DEMO_SRCS} "${ROOT_SRC_DIR}/shared/resources-location.cpp")
+SET(DEMO_SRCS
+ ${DEMO_SRCS}
+ "${ROOT_SRC_DIR}/shared/resources-location.cpp"
+ "${ROOT_SRC_DIR}/shared/dali-table-view.cpp"
+)
ADD_EXECUTABLE(${PROJECT_NAME} ${DEMO_SRCS})
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${REQUIRED_PKGS_LDFLAGS} -pie)
--- /dev/null
+SET(EXAMPLES_REEL_SRC_DIR ${ROOT_SRC_DIR}/examples-reel)
+
+AUX_SOURCE_DIRECTORY(${EXAMPLES_REEL_SRC_DIR} EXAMPLES_REEL_SRCS)
+
+SET(EXAMPLES_REEL_SRCS
+ ${EXAMPLES_REEL_SRCS}
+ "${ROOT_SRC_DIR}/shared/resources-location.cpp"
+ "${ROOT_SRC_DIR}/shared/dali-table-view.cpp"
+)
+
+ADD_EXECUTABLE(dali-examples ${EXAMPLES_REEL_SRCS})
+TARGET_LINK_LIBRARIES(dali-examples ${REQUIRED_PKGS_LDFLAGS} -pie)
+
+INSTALL(TARGETS dali-examples DESTINATION ${BINDIR})
+
<assign>
<filesystem path="/usr/share/icons/com.samsung.dali-demo.png" label="_" />
</assign>
+ <assign>
+ <filesystem path="/usr/share/icons/dali-examples.png" label="_" />
+ </assign>
<request>
<domain name="com.samsung.dali-demo" />
</request>
<icon>/usr/share/icons/com.samsung.dali-demo.png</icon>
<label>DALi demo</label>
</ui-application>
+ <ui-application appid="com.samsung.dali-examples" exec="/usr/apps/com.samsung.dali-demo/bin/dali-examples" nodisplay="false" multiple="false" type="c++app" taskmanage="true">
+ <icon>/usr/share/icons/dali-examples.png</icon>
+ <label>DALi Examples</label>
+ </ui-application>
<ui-application appid="hello-world.example" exec="/usr/apps/com.samsung.dali-demo/bin/hello-world.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
<label>Hello World</label>
</ui-application>
<label>First Person Camera Game</label>
</ui-application>
<ui-application appid="transitions.example" exec="/usr/apps/com.samsung.dali-demo/bin/transitions.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
+ <label>Shadow button</label>
+ </ui-application>
+ <ui-application appid="visual-transitions.example" exec="/usr/apps/com.samsung.dali-demo/bin/visual-transitions.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
<label>Visual Transitions</label>
</ui-application>
<ui-application appid="animated-images.example" exec="/usr/apps/com.samsung.dali-demo/bin/animated-images.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
#include <dali/dali.h>
// INTERNAL INCLUDES
-#include "dali-table-view.h"
+#include "shared/dali-table-view.h"
#include "shared/dali-demo-strings.h"
using namespace Dali;
// Create the demo launcher
DaliTableView demo(app);
- demo.AddExample(Example("animated-images.example", DALI_DEMO_STR_TITLE_ANIMATED_IMAGES));
- demo.AddExample(Example("animated-shapes.example", DALI_DEMO_STR_TITLE_ANIMATED_SHAPES));
- demo.AddExample(Example("bubble-effect.example", DALI_DEMO_STR_TITLE_BUBBLES));
demo.AddExample(Example("blocks.example", DALI_DEMO_STR_TITLE_BLOCKS));
+ demo.AddExample(Example("bubble-effect.example", DALI_DEMO_STR_TITLE_BUBBLES));
+ demo.AddExample(Example("contact-cards.example", DALI_DEMO_STR_TITLE_CONTACT_CARDS));
demo.AddExample(Example("cube-transition-effect.example", DALI_DEMO_STR_TITLE_CUBE_TRANSITION));
- demo.AddExample(Example("dissolve-effect.example", DALI_DEMO_STR_TITLE_DISSOLVE_TRANSITION));
+ demo.AddExample(Example("fpp-game.example", DALI_DEMO_STR_TITLE_FPP_GAME));
demo.AddExample(Example("item-view.example", DALI_DEMO_STR_TITLE_ITEM_VIEW));
- demo.AddExample(Example("renderer-stencil.example", DALI_DEMO_STR_TITLE_RENDERER_STENCIL));
- demo.AddExample(Example("magnifier.example", DALI_DEMO_STR_TITLE_MAGNIFIER));
+ demo.AddExample(Example("mesh-visual.example", DALI_DEMO_STR_TITLE_MESH_VISUAL));
demo.AddExample(Example("motion-blur.example", DALI_DEMO_STR_TITLE_MOTION_BLUR));
- demo.AddExample(Example("motion-stretch.example", DALI_DEMO_STR_TITLE_MOTION_STRETCH));
- demo.AddExample(Example("page-turn-view.example", DALI_DEMO_STR_TITLE_PAGE_TURN_VIEW));
demo.AddExample(Example("refraction-effect.example", DALI_DEMO_STR_TITLE_REFRACTION));
- demo.AddExample(Example("scroll-view.example", DALI_DEMO_STR_TITLE_SCROLL_VIEW));
+ demo.AddExample(Example("renderer-stencil.example", DALI_DEMO_STR_TITLE_RENDERER_STENCIL));
demo.AddExample(Example("shadows-and-lights.example", DALI_DEMO_STR_TITLE_LIGHTS_AND_SHADOWS));
- demo.AddExample(Example("builder.example", DALI_DEMO_STR_TITLE_SCRIPT_BASED_UI));
- demo.AddExample(Example("image-scaling-and-filtering.example", DALI_DEMO_STR_TITLE_IMAGE_FITTING_SAMPLING));
- demo.AddExample(Example("image-scaling-irregular-grid.example", DALI_DEMO_STR_TITLE_IMAGE_SCALING));
- demo.AddExample(Example("text-field.example", DALI_DEMO_STR_TITLE_TEXT_FIELD));
- demo.AddExample(Example("text-label.example", DALI_DEMO_STR_TITLE_TEXT_LABEL));
- demo.AddExample(Example("text-label-multi-language.example", DALI_DEMO_STR_TITLE_TEXT_LABEL_MULTI_LANGUAGE));
- demo.AddExample(Example("text-label-emojis.example", DALI_DEMO_STR_TITLE_EMOJI_TEXT));
- demo.AddExample(Example("text-scrolling.example", DALI_DEMO_STR_TITLE_TEXT_SCROLLING));
- demo.AddExample(Example("text-editor.example", DALI_DEMO_STR_TITLE_TEXT_EDITOR));
- demo.AddExample(Example("size-negotiation.example", DALI_DEMO_STR_TITLE_NEGOTIATE_SIZE));
- demo.AddExample(Example("popup.example", DALI_DEMO_STR_TITLE_POPUP));
- demo.AddExample(Example("buttons.example", DALI_DEMO_STR_TITLE_BUTTONS));
- demo.AddExample(Example("logging.example", DALI_DEMO_STR_TITLE_LOGGING));
- demo.AddExample(Example("mesh-morph.example", DALI_DEMO_STR_TITLE_MESH_MORPH));
- demo.AddExample(Example("mesh-sorting.example", DALI_DEMO_STR_TITLE_MESH_SORTING));
- demo.AddExample(Example("metaball-explosion.example", DALI_DEMO_STR_TITLE_METABALL_EXPLOSION));
- demo.AddExample(Example("metaball-refrac.example", DALI_DEMO_STR_TITLE_METABALL_REFRAC));
- demo.AddExample(Example("textured-mesh.example", DALI_DEMO_STR_TITLE_TEXTURED_MESH));
- demo.AddExample(Example("line-mesh.example", DALI_DEMO_STR_TITLE_LINE_MESH));
- demo.AddExample(Example("gradients.example", DALI_DEMO_STR_TITLE_COLOR_GRADIENT));
- demo.AddExample(Example("image-view.example", DALI_DEMO_STR_TITLE_IMAGE_VIEW));
- demo.AddExample(Example("image-view-pixel-area.example", DALI_DEMO_STR_TITLE_IMAGE_VIEW_PIXEL_AREA));
- demo.AddExample(Example("image-view-alpha-blending.example", DALI_DEMO_STR_TITLE_IMAGE_VIEW_ALPHA_BLENDING));
- demo.AddExample(Example("image-view-svg.example", DALI_DEMO_STR_TITLE_IMAGE_VIEW_SVG));
- demo.AddExample(Example("super-blur-bloom.example", DALI_DEMO_STR_TITLE_SUPER_BLUR_BLOOM));
- demo.AddExample(Example("tilt.example", DALI_DEMO_STR_TITLE_TILT_SENSOR));
- demo.AddExample(Example("effects-view.example", DALI_DEMO_STR_TITLE_EFFECTS_VIEW));
- demo.AddExample(Example("native-image-source.example", DALI_DEMO_STR_TITLE_NATIVE_IMAGE_SOURCE));
- demo.AddExample(Example("mesh-visual.example", DALI_DEMO_STR_TITLE_MESH_VISUAL));
- demo.AddExample(Example("primitive-shapes.example", DALI_DEMO_STR_TITLE_PRIMITIVE_SHAPES));
- demo.AddExample(Example("styling.example", DALI_DEMO_STR_TITLE_STYLING));
demo.AddExample(Example("sparkle.example", DALI_DEMO_STR_TITLE_SPARKLE));
- demo.AddExample(Example("transitions.example", DALI_DEMO_STR_TITLE_VISUAL_TRANSITIONS));
- demo.AddExample(Example("progress-bar.example", DALI_DEMO_STR_TITLE_PROGRESS_BAR));
- demo.AddExample(Example("contact-cards.example", DALI_DEMO_STR_TITLE_CONTACT_CARDS));
- demo.AddExample(Example("flex-container.example", DALI_DEMO_STR_TITLE_FLEXBOX_PLAYGROUND));
- demo.AddExample(Example("fpp-game.example", DALI_DEMO_STR_TITLE_FPP_GAME));
- demo.AddExample(Example("tooltip.example", DALI_DEMO_STR_TITLE_TOOLTIP));
- demo.AddExample(Example("clipping.example", DALI_DEMO_STR_TITLE_CLIPPING));
demo.SortAlphabetically( true );
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/dali.h>
+
+// INTERNAL INCLUDES
+#include "shared/dali-table-view.h"
+#include "shared/dali-demo-strings.h"
+
+using namespace Dali;
+
+int DALI_EXPORT_API main(int argc, char **argv)
+{
+ // Configure gettext for internalization
+ bindtextdomain(DALI_DEMO_DOMAIN_LOCAL, DEMO_LOCALE_DIR);
+ textdomain(DALI_DEMO_DOMAIN_LOCAL);
+ setlocale(LC_ALL, DEMO_LANG);
+
+ Application app = Application::New(&argc, &argv, DEMO_THEME_PATH);
+
+ // Create the demo launcher
+ DaliTableView demo(app);
+
+ demo.AddExample(Example("animated-images.example", DALI_DEMO_STR_TITLE_ANIMATED_IMAGES));
+ demo.AddExample(Example("animated-shapes.example", DALI_DEMO_STR_TITLE_ANIMATED_SHAPES));
+ demo.AddExample(Example("builder.example", DALI_DEMO_STR_TITLE_SCRIPT_BASED_UI));
+ demo.AddExample(Example("buttons.example", DALI_DEMO_STR_TITLE_BUTTONS));
+ demo.AddExample(Example("clipping.example", DALI_DEMO_STR_TITLE_CLIPPING));
+ demo.AddExample(Example("dissolve-effect.example", DALI_DEMO_STR_TITLE_DISSOLVE_TRANSITION));
+ demo.AddExample(Example("effects-view.example", DALI_DEMO_STR_TITLE_EFFECTS_VIEW));
+ demo.AddExample(Example("flex-container.example", DALI_DEMO_STR_TITLE_FLEXBOX_PLAYGROUND));
+ demo.AddExample(Example("gradients.example", DALI_DEMO_STR_TITLE_COLOR_GRADIENT));
+ demo.AddExample(Example("image-scaling-and-filtering.example", DALI_DEMO_STR_TITLE_IMAGE_FITTING_SAMPLING));
+ demo.AddExample(Example("image-scaling-irregular-grid.example", DALI_DEMO_STR_TITLE_IMAGE_SCALING));
+ demo.AddExample(Example("image-view.example", DALI_DEMO_STR_TITLE_IMAGE_VIEW));
+ demo.AddExample(Example("image-view-alpha-blending.example", DALI_DEMO_STR_TITLE_IMAGE_VIEW_ALPHA_BLENDING));
+ demo.AddExample(Example("image-view-pixel-area.example", DALI_DEMO_STR_TITLE_IMAGE_VIEW_PIXEL_AREA));
+ demo.AddExample(Example("image-view-svg.example", DALI_DEMO_STR_TITLE_IMAGE_VIEW_SVG));
+ demo.AddExample(Example("line-mesh.example", DALI_DEMO_STR_TITLE_LINE_MESH));
+ demo.AddExample(Example("logging.example", DALI_DEMO_STR_TITLE_LOGGING));
+ demo.AddExample(Example("magnifier.example", DALI_DEMO_STR_TITLE_MAGNIFIER));
+ demo.AddExample(Example("mesh-morph.example", DALI_DEMO_STR_TITLE_MESH_MORPH));
+ demo.AddExample(Example("mesh-sorting.example", DALI_DEMO_STR_TITLE_MESH_SORTING));
+ demo.AddExample(Example("motion-stretch.example", DALI_DEMO_STR_TITLE_MOTION_STRETCH));
+ demo.AddExample(Example("native-image-source.example", DALI_DEMO_STR_TITLE_NATIVE_IMAGE_SOURCE));
+ demo.AddExample(Example("popup.example", DALI_DEMO_STR_TITLE_POPUP));
+ demo.AddExample(Example("primitive-shapes.example", DALI_DEMO_STR_TITLE_PRIMITIVE_SHAPES));
+ demo.AddExample(Example("progress-bar.example", DALI_DEMO_STR_TITLE_PROGRESS_BAR));
+ demo.AddExample(Example("scroll-view.example", DALI_DEMO_STR_TITLE_SCROLL_VIEW));
+ demo.AddExample(Example("size-negotiation.example", DALI_DEMO_STR_TITLE_NEGOTIATE_SIZE));
+ demo.AddExample(Example("styling.example", DALI_DEMO_STR_TITLE_STYLING));
+ demo.AddExample(Example("text-editor.example", DALI_DEMO_STR_TITLE_TEXT_EDITOR));
+ demo.AddExample(Example("text-field.example", DALI_DEMO_STR_TITLE_TEXT_FIELD));
+ demo.AddExample(Example("text-label.example", DALI_DEMO_STR_TITLE_TEXT_LABEL));
+ demo.AddExample(Example("text-label-multi-language.example", DALI_DEMO_STR_TITLE_TEXT_LABEL_MULTI_LANGUAGE));
+ demo.AddExample(Example("text-label-emojis.example", DALI_DEMO_STR_TITLE_EMOJI_TEXT));
+ demo.AddExample(Example("text-scrolling.example", DALI_DEMO_STR_TITLE_TEXT_SCROLLING));
+ demo.AddExample(Example("textured-mesh.example", DALI_DEMO_STR_TITLE_TEXTURED_MESH));
+ demo.AddExample(Example("tilt.example", DALI_DEMO_STR_TITLE_TILT_SENSOR));
+ demo.AddExample(Example("tooltip.example", DALI_DEMO_STR_TITLE_TOOLTIP));
+ demo.AddExample(Example("transitions.example", DALI_DEMO_STR_TITLE_VISUAL_TRANSITIONS));
+
+ demo.SortAlphabetically( true );
+
+ // Start the event loop
+ app.MainLoop();
+
+ return 0;
+}
const float DEFAULT_OPT_COL_COUNT ( 4 );
const float DEFAULT_OPT_PAGE_COUNT ( 10 );
const bool DEFAULT_OPT_USE_TABLEVIEW ( true );
-const bool DEFAULT_OPT_BATCHING_ENABLED ( true );
const bool DEFAULT_OPT_ICON_LABELS ( true );
const IconType DEFAULT_OPT_ICON_TYPE ( IMAGEVIEW );
const bool DEFAULT_OPT_USE_TEXT_LABEL ( false );
mCols( DEFAULT_OPT_COL_COUNT ),
mPageCount( DEFAULT_OPT_PAGE_COUNT ),
mTableViewEnabled( DEFAULT_OPT_USE_TABLEVIEW ),
- mBatchingEnabled( DEFAULT_OPT_BATCHING_ENABLED ),
mIconLabelsEnabled( DEFAULT_OPT_ICON_LABELS ),
mIconType( DEFAULT_OPT_ICON_TYPE ),
mUseTextLabel( DEFAULT_OPT_USE_TEXT_LABEL )
int mCols;
int mPageCount;
bool mTableViewEnabled;
- bool mBatchingEnabled;
bool mIconLabelsEnabled;
IconType mIconType;
bool mUseTextLabel;
imagePath << IMAGE_PATH_PREFIX << currentIconIndex << IMAGE_PATH_POSTFIX;
map[ Dali::Toolkit::ImageVisual::Property::URL ] = imagePath.str();
- // Enable/disable batching
- map[ Toolkit::ImageVisual::Property::BATCHING_ENABLED ] = mConfig.mBatchingEnabled;
-
imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, map );
imageView.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
imageView.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO );
page.SetAnchorPoint( AnchorPoint::CENTER );
page.SetPosition( Vector3( stageSize.x * i, 0.0f, 0.0f ) );
mScrollParent.Add( page );
-
- if( mConfig.mTableViewEnabled && mConfig.mBatchingEnabled )
- {
- page.SetProperty( DevelActor::Property::BATCH_PARENT, true );
- }
}
mScrollParent.SetOpacity( 1.0f );
PrintHelp( "c<num>", " Number of columns" );
PrintHelp( "r<num>", " Number of rows" );
PrintHelp( "p<num>", " Number of pages ( must be greater than 1 )" );
- PrintHelp( "-disable-tableview", " Disables the use of TableView for layouting (must be enabled for batching)" );
- PrintHelp( "-disable-batching", " Disables geometry batching" );
+ PrintHelp( "-disable-tableview", " Disables the use of TableView for layouting" );
PrintHelp( "-disable-icon-labels", " Disables labels for each icon" );
PrintHelp( "-use-checkbox", " Uses checkboxes for icons" );
PrintHelp( "-use-text-label", " Uses TextLabel instead of a TextVisual" );
{
config.mTableViewEnabled = false;
}
- else if( arg.compare( "--disable-batching" ) == 0 )
- {
- config.mBatchingEnabled = false;
- }
else if( arg.compare( "--disable-icon-labels" ) == 0 )
{
config.mIconLabelsEnabled = false;
#include <dali/dali.h>
#include <dali-toolkit/dali-toolkit.h>
#include <dali-toolkit/devel-api/controls/popup/popup.h>
+#include <dali-toolkit/public-api/visuals/image-visual-properties.h>
#include "shared/view.h"
#include <iostream>
}
}
- void OnImageLoaded( ResourceImage image )
- {
- DALI_ASSERT_DEBUG( image == mNextImage );
- mImageView.SetImage( image );
- mImageView.SetSize( Size( image.GetWidth(), image.GetHeight() ) );
- mImageLoading = false;
-
- // We have finished loading, if a resize had occured during the load, trigger another load now.
- if( mQueuedImageLoad )
- {
- mQueuedImageLoad = false;
- LoadImage();
- }
- }
-
bool OnControlTouched( Actor actor, const TouchData& event )
{
if(event.GetPointCount() > 0)
const char * const path = IMAGE_PATHS[ mCurrentPath ];
Stage stage = Stage::GetCurrent();
Size imageSize = stage.GetSize() * mImageStageScale;
- const ImageDimensions imageSizeInt = ImageDimensions::FromFloatArray( &imageSize.x );
+ mImageView.SetSize( imageSize );
- ResourceImage image = ResourceImage::New( path, imageSizeInt, mFittingMode, mSamplingMode );
+ Property::Map map;
+ map[Toolkit::ImageVisual::Property::URL] = path;
+ map[Toolkit::ImageVisual::Property::DESIRED_WIDTH] = imageSize.x;
+ map[Toolkit::ImageVisual::Property::DESIRED_HEIGHT] = imageSize.y;
+ map[Toolkit::ImageVisual::Property::FITTING_MODE] = mFittingMode;
+ map[Toolkit::ImageVisual::Property::SAMPLING_MODE] = mSamplingMode;
- // If the image was cached, the load has already occured, bypass hooking the signal.
- if( image.GetLoadingState() )
- {
- OnImageLoaded( image );
- }
- else
- {
- image.LoadingFinishedSignal().Connect( this, &ImageScalingAndFilteringController::OnImageLoaded );
- }
+ mImageView.SetProperty( Toolkit::ImageView::Property::IMAGE, map );
- mNextImage = image;
}
void ResizeImage()
Stage stage = Stage::GetCurrent();
Size imageSize = stage.GetSize() * mImageStageScale;
- // If an image is already loading, queue another load when it has finished.
- // This way we get continuous updates instead of constantly re-requesting loads.
- if( mImageLoading )
- {
- mQueuedImageLoad = true;
- }
- else
- {
- LoadImage();
- }
+ LoadImage();
// Border size needs to be modified to take into account the width of the frame.
Vector2 borderScale( ( imageSize + Vector2( BORDER_WIDTH * 2.0f, BORDER_WIDTH * 2.0f ) ) / stage.GetSize() );
Toolkit::ImageView mGrabCorner;
PanGestureDetector mPanGestureDetector;
Toolkit::ImageView mImageView;
- ResourceImage mNextImage; //< Currently-loading image
Vector2 mImageStageScale;
int mCurrentPath;
FittingMode::Type mFittingMode;
const unsigned NUM_IMAGE_PATHS = sizeof(IMAGE_PATHS) / sizeof(IMAGE_PATHS[0]) - 1u;
-/**
- * Creates an Image
- *
- * @param[in] filename The path of the image.
- * @param[in] width The width of the image in pixels.
- * @param[in] height The height of the image in pixels.
- * @param[in] fittingMode The mode to use when scaling the image to fit the desired dimensions.
- */
-Image CreateImage(const std::string& filename, unsigned int width, unsigned int height, Dali::FittingMode::Type fittingMode )
-{
-#ifdef DEBUG_PRINT_DIAGNOSTICS
- fprintf( stderr, "CreateImage(%s, %u, %u, fittingMode=%u)\n", filename.c_str(), width, height, unsigned( fittingMode ) );
-#endif
- Image image = ResourceImage::New( filename, ImageDimensions( width, height ), fittingMode, Dali::SamplingMode::BOX_THEN_LINEAR );
-
- return image;
-}
/**
* Creates an ImageView
* @param[in] height The height of the image in pixels.
* @param[in] fittingMode The mode to use when scaling the image to fit the desired dimensions.
*/
-ImageView CreateImageView(const std::string& filename, unsigned int width, unsigned int height, Dali::FittingMode::Type fittingMode )
+ImageView CreateImageView(const std::string& filename, int width, int height, Dali::FittingMode::Type fittingMode )
{
- Image img = CreateImage( filename, width, height, fittingMode );
- ImageView actor = ImageView::New( img );
- actor.SetName( filename );
- actor.SetParentOrigin(ParentOrigin::CENTER);
- actor.SetAnchorPoint(AnchorPoint::CENTER);
- return actor;
+ ImageView imageView = ImageView::New();
+
+ Property::Map map;
+ map[Toolkit::ImageVisual::Property::URL] = filename;
+ map[Toolkit::ImageVisual::Property::DESIRED_WIDTH] = width;
+ map[Toolkit::ImageVisual::Property::DESIRED_HEIGHT] = height;
+ map[Toolkit::ImageVisual::Property::FITTING_MODE] = fittingMode;
+ imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, map );
+
+ imageView.SetName( filename );
+ imageView.SetParentOrigin(ParentOrigin::CENTER);
+ imageView.SetAnchorPoint(AnchorPoint::CENTER);
+
+ return imageView;
}
/** Cycle the scaling mode options. */
Dali::FittingMode::Type newMode = NextMode( mFittingModes[id] );
const Vector2 imageSize = mSizes[actor.GetId()];
- const std::string& url = mResourceUrls[id];
- Image newImage = CreateImage( url, imageSize.width + 0.5f, imageSize.height + 0.5f, newMode );
ImageView imageView = ImageView::DownCast( actor );
- if(imageView)
+ if( imageView)
{
- imageView.SetImage( newImage );
+ Property::Map map;
+ map[Visual::Property::TYPE] = Visual::IMAGE;
+ map[ImageVisual::Property::URL] = mResourceUrls[id];
+ map[ImageVisual::Property::DESIRED_WIDTH] = imageSize.width + 0.5f;
+ map[ImageVisual::Property::DESIRED_HEIGHT] = imageSize.height + 0.5f;
+ map[ImageVisual::Property::FITTING_MODE] = newMode;
+ imageView.SetProperty( ImageView::Property::IMAGE, map );
}
+
mFittingModes[id] = newMode;
}
}
const Vector2 imageSize = mSizes[ id ];
Dali::FittingMode::Type newMode = NextMode( mFittingModes[ id ] );
- Image newImage = CreateImage( mResourceUrls[ id ], imageSize.width, imageSize.height, newMode );
- gridImageView.SetImage( newImage );
+
+ Property::Map map;
+ map[Visual::Property::TYPE] = Visual::IMAGE;
+ map[ImageVisual::Property::URL] = mResourceUrls[id];
+ map[ImageVisual::Property::DESIRED_WIDTH] = imageSize.width;
+ map[ImageVisual::Property::DESIRED_HEIGHT] = imageSize.height;
+ map[ImageVisual::Property::FITTING_MODE] = newMode;
+ gridImageView.SetProperty( ImageView::Property::IMAGE, map );
+
+
mFittingModes[ id ] = newMode;
namespace
{
- //Keeps information about each model for access.
- struct Model
- {
- Control control; // Control housing the mesh visual of the model.
- Vector2 rotation; // Keeps track of rotation about x and y axis for manual rotation.
- Animation rotationAnimation; // Automatically rotates when left alone.
- };
+// Keeps information about each model for access.
+struct Model
+{
+ Control control; // Control housing the mesh visual of the model.
+ Vector2 rotation; // Keeps track of rotation about x and y axis for manual rotation.
+ Animation rotationAnimation; // Automatically rotates when left alone.
+};
- //Files for meshes
- const char * const MODEL_FILE_TABLE[] =
- {
- DEMO_MODEL_DIR "Dino.obj",
- DEMO_MODEL_DIR "ToyRobot-Metal.obj",
- DEMO_MODEL_DIR "Toyrobot-Plastic.obj"
- };
+// Files for meshes
+const char * const MODEL_FILE_TABLE[] =
+{
+ DEMO_MODEL_DIR "Dino.obj",
+ DEMO_MODEL_DIR "ToyRobot-Metal.obj",
+ DEMO_MODEL_DIR "Toyrobot-Plastic.obj"
+};
- const char * const MATERIAL_FILE_TABLE[] =
- {
- DEMO_MODEL_DIR "Dino.mtl",
- DEMO_MODEL_DIR "ToyRobot-Metal.mtl",
- DEMO_MODEL_DIR "Toyrobot-Plastic.mtl"
- };
+const char * const MATERIAL_FILE_TABLE[] =
+{
+ DEMO_MODEL_DIR "Dino.mtl",
+ DEMO_MODEL_DIR "ToyRobot-Metal.mtl",
+ DEMO_MODEL_DIR "Toyrobot-Plastic.mtl"
+};
- const char * const TEXTURES_PATH( DEMO_IMAGE_DIR "" );
+const char * const TEXTURES_PATH( DEMO_IMAGE_DIR "" );
- //Possible shading modes.
- MeshVisual::ShadingMode::Value SHADING_MODE_TABLE[] =
- {
- MeshVisual::ShadingMode::TEXTURED_WITH_DETAILED_SPECULAR_LIGHTING,
- MeshVisual::ShadingMode::TEXTURED_WITH_SPECULAR_LIGHTING,
- MeshVisual::ShadingMode::TEXTURELESS_WITH_DIFFUSE_LIGHTING
- };
-
- //Button labels.
- const char * const PAUSE = " || ";
- const char * const PLAY = " > ";
- const char * const FIXED = "FIXED";
- const char * const MANUAL = "MANUAL";
- const char * const FRONT = "FRONT";
- const char * const BACK = "BACK";
-
- //Image urls for the light.
- const char * const LIGHT_URL_FRONT = DEMO_IMAGE_DIR "light-icon-front.png";
- const char * const LIGHT_URL_BACK = DEMO_IMAGE_DIR "light-icon-back.png";
-
- const float X_ROTATION_DISPLACEMENT_FACTOR = 60.0f;
- const float Y_ROTATION_DISPLACEMENT_FACTOR = 60.0f;
- const float MODEL_SCALE = 0.75f;
- const float LIGHT_SCALE = 0.15f;
- const float BUTTONS_OFFSET_BOTTOM = 0.08f;
- const float BUTTONS_OFFSET_SIDE = 0.2f;
- const int NUM_MESHES = 2;
-
- //Used to identify actors.
- const int MODEL_TAG = 0;
- const int LIGHT_TAG = 1;
- const int LAYER_TAG = 2;
-
-} //End namespace
+// Possible shading modes.
+MeshVisual::ShadingMode::Value SHADING_MODE_TABLE[] =
+{
+ MeshVisual::ShadingMode::TEXTURED_WITH_DETAILED_SPECULAR_LIGHTING,
+ MeshVisual::ShadingMode::TEXTURED_WITH_SPECULAR_LIGHTING,
+ MeshVisual::ShadingMode::TEXTURELESS_WITH_DIFFUSE_LIGHTING
+};
+
+// Button labels.
+const char * const PAUSE = " || ";
+const char * const PLAY = " > ";
+const char * const FIXED = "FIXED";
+const char * const MANUAL = "MANUAL";
+const char * const FRONT = "FRONT";
+const char * const BACK = "BACK";
+
+// Image urls for the light.
+const char * const LIGHT_URL_FRONT = DEMO_IMAGE_DIR "light-icon-front.png";
+const char * const LIGHT_URL_BACK = DEMO_IMAGE_DIR "light-icon-back.png";
+
+const float X_ROTATION_DISPLACEMENT_FACTOR = 60.0f;
+const float Y_ROTATION_DISPLACEMENT_FACTOR = 60.0f;
+const float MODEL_SCALE = 0.75f;
+const float LIGHT_SCALE = 0.15f;
+const float BUTTONS_OFFSET_BOTTOM = 0.08f;
+const float BUTTONS_OFFSET_SIDE = 0.2f;
+const int NUM_MESHES = 2;
+
+// Used to identify actors.
+const int MODEL_TAG = 0;
+const int LIGHT_TAG = 1;
+const int LAYER_TAG = 2;
+
+const Vector4 STAGE_COLOR( 211.0f / 255.0f, 211.0f / 255.0f, 211.0f / 255.0f, 1.0f ); ///< The color of the stage
+
+} // unnamed namespace
class MeshVisualController : public ConnectionTracker
{
{
// Get a handle to the stage
Stage stage = Stage::GetCurrent();
- stage.SetBackgroundColor( Vector4( 0.0, 0.5, 1.0, 1.0 ) );
+ stage.SetBackgroundColor( STAGE_COLOR );
//Set up root layer to receive touch gestures.
Layer rootLayer = stage.GetRootLayer();
+++ /dev/null
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <cstdio>
-#include <string>
-#include <dali/dali.h>
-#include <dali/devel-api/images/texture-set-image.h>
-#include <dali/public-api/rendering/renderer.h>
-#include <dali-toolkit/dali-toolkit.h>
-#include <dali-toolkit/devel-api/controls/gaussian-blur-view/gaussian-blur-view.h>
-
-// INTERNAL INCLUDES
-#include "shared/view.h"
-#include "shared/utility.h"
-
-using namespace Dali;
-using namespace Dali::Toolkit;
-
-namespace
-{
-const char * const BACKGROUND_IMAGE( DEMO_IMAGE_DIR "background-2.jpg" );
-const char * const TOOLBAR_IMAGE( DEMO_IMAGE_DIR "top-bar.png" );
-
-const float GRAVITY_X(0);
-const float GRAVITY_Y(-0.09);
-}
-
-#define METABALL_NUMBER 6
-
-
-const char*const METABALL_VERTEX_SHADER = DALI_COMPOSE_SHADER (
- attribute mediump vec2 aPosition;\n
- attribute mediump vec2 aTexture;\n
- uniform mediump mat4 uMvpMatrix;\n
- uniform mediump vec3 uSize;\n
- uniform lowp vec4 uColor;\n
- varying mediump vec2 vTexCoord;\n
-
- void main()\n
- {\n
- vTexCoord = aTexture;\n
- mediump vec4 vertexPosition = vec4(aPosition.x, aPosition.y, 0.0, 1.0);\n
- gl_Position = uMvpMatrix * vertexPosition;\n
- }\n
-);
-
-
-const char*const METABALL_FRAG_SHADER = DALI_COMPOSE_SHADER (
- precision mediump float;\n
- varying vec2 vTexCoord;\n
- uniform vec2 uPositionMetaball;\n
- uniform vec2 uPositionVar;\n
- uniform vec2 uGravityVector;\n
- uniform float uRadius;\n
- uniform float uRadiusVar;\n
- void main()\n
- {\n
- vec2 adjustedCoords = vTexCoord * 2.0 - 1.0;\n
- vec2 finalMetaballPosition = uPositionMetaball + uGravityVector + uPositionVar;\n
- \n
- float finalRadius = uRadius + uRadiusVar;\n
- vec2 distanceVec = adjustedCoords - finalMetaballPosition;\n
- float result = dot(distanceVec, distanceVec);\n
- float color = inversesqrt(result) * finalRadius;\n
- \n
- gl_FragColor = vec4(color,color,color,1.0);\n
- }\n
-);
-
-const char*const REFRACTION_FRAG_SHADER = DALI_COMPOSE_SHADER (
- precision highp float;\n
- varying vec2 vTexCoord;\n
- uniform sampler2D sTexture;\n
- uniform sampler2D sEffect;\n
- uniform vec2 uPositionMetaball;\n
- void main()\n
- {\n
- vec2 zoomCoords;\n
- vec3 normal = vec3(0.0,0.0,1.0);\n
- vec2 fakePos = vec2(0.0,0.0);\n
- vec3 color = vec3(1.0, 1.0, 1.0);
- float ambient = 0.2;
- \n
- vec4 metaColor = texture2D(sEffect, vTexCoord);\n
- \n
- vec2 adjustedCoords = vTexCoord.xy * vec2(2.0) - vec2(1.0);\n
- fakePos = adjustedCoords.xy - vec2(uPositionMetaball.x, -uPositionMetaball.y);
- float len = length(fakePos) + 0.01;\n
- vec3 colorPos = vec3(0,0,1);
- \n
- if (metaColor.r > 0.85)\n
- {\n
- zoomCoords = ((vTexCoord - 0.5) * 0.9);\n
- zoomCoords = zoomCoords + 0.5;\n
- \n
- float interpNormal = mix(0.7, 1.0, (metaColor.r - 0.85) * 4.);\n
- normal.xyz = vec3(fakePos.x * (1.0 - interpNormal) / len, fakePos.y * (1.0 - interpNormal) / len, interpNormal);\n
- normal.xyz = normalize(normal.xyz);\n
- color = vec3(0.65, 1.0, 0);\n
- colorPos = vec3(fakePos.x,fakePos.y,0);
- }\n
- else if (metaColor.r > 0.75)\n
- {\n
- float interpolation = mix(0.9, 1.15, (0.85 - metaColor.r) * 10.0);\n
- zoomCoords = ((vTexCoord - 0.5) * interpolation);\n
- zoomCoords = zoomCoords + 0.5;\n
- \n
- float interpNormal = mix(0.7, 0.0, (0.85 - metaColor.r) * 10.0);\n
- normal.xyz = vec3(fakePos.x * (1.0 - interpNormal) / len, fakePos.y * (1.0 - interpNormal) / len, interpNormal);\n
- normal.xyz = normalize(normal.xyz);\n
- color = vec3(0.65, 1.0, 0);\n
- colorPos = vec3(fakePos.x,fakePos.y,0);
- }\n
- else\n
- {\n
- zoomCoords = vTexCoord;\n
- normal = vec3(0,0,0);\n
- ambient = 0.5;\n
- }\n
- \n
- vec3 lightPosition = vec3(-750.0,-1000.0,2000.0);\n
- vec3 vertex = vec3(adjustedCoords.x,adjustedCoords.y,0.0);\n
- \n
- vec3 vecToLight = normalize( lightPosition - vertex );\n
- \n
- float lightDiffuse = dot( vecToLight, normal );\n
- lightDiffuse = max(0.0,lightDiffuse);\n
- lightDiffuse = lightDiffuse * 0.5 + 0.5;
- \n
- vec3 vertexToEye = vec3(0,0,1) - vertex;\n
- vertexToEye = normalize(vertexToEye);
- vec3 lightReflect = normalize(reflect(-vecToLight, normal));\n
- float specularFactor = max(0.0,dot(vertexToEye, lightReflect));\n
- specularFactor = pow(specularFactor, 32.0) * 0.7;
- \n
- vec4 texColor = texture2D(sTexture, zoomCoords);\n
- gl_FragColor.rgb = texColor.rgb * ambient + color.rgb * texColor.rgb * lightDiffuse + vec3(specularFactor);\n
- gl_FragColor.a = 1.0;
- }\n
- );
-
-const char*const FRAG_SHADER = DALI_COMPOSE_SHADER (
- precision mediump float;\n
- void main()\n
- {\n
- gl_FragColor = texture2D(sTexture, vTexCoord);\n
- }\n
-);
-
-
-struct MetaballInfo
-{
- Actor actor;
- Vector2 position;
- float radius;
- float initRadius;
-
- //new shader stuff
- Property::Index positionIndex;
- Property::Index positionVarIndex;
-};
-
-
-/**************************************************************************/
-/* Demo using Metaballs ***********/
-/* When the metaball is clicked it explodes in different balls ***********/
-/**************************************************************************/
-class MetaballExplosionController : public ConnectionTracker
-{
-public:
- MetaballExplosionController( Application& application );
- ~MetaballExplosionController();
-
- /**
- * Main create function, it creates the metaballs and all the related data
- */
- void Create( Application& app );
-
- /**
- * Touch event function
- */
- bool OnTouch( Actor actor, const TouchData& touch );
-
- /**
- * Key event function
- */
- void OnKeyEvent(const KeyEvent& event);
-
-
-private:
- Application& mApplication;
- Vector2 mScreenSize;
-
- Layer mContentLayer;
-
- Image mBackImage;
- FrameBufferImage mMetaballFBO;
-
- Actor mMetaballRoot;
- MetaballInfo mMetaballs[METABALL_NUMBER];
-
- Property::Index mPositionIndex;
- Actor mCompositionActor;
-
- //Motion
- Vector2 mCurrentTouchPosition;
- Vector2 mMetaballPosVariation;
- Vector2 mMetaballPosVariationFrom;
- Vector2 mMetaballPosVariationTo;
- Vector2 mMetaballCenter;
-
- //Animations
- Animation mPositionVarAnimation[METABALL_NUMBER];
-
- int mDispersion;
- Animation mDispersionAnimation[METABALL_NUMBER];
-
- Timer mTimerDispersion;
-
- float mTimeMult;
-
- //Private functions
-
- /**
- * Create a mesh data with the geometry for the metaball rendering
- */
- Geometry CreateGeometry();
-
- /**
- * Create a mesh data with the geometry for the final composition
- */
- Geometry CreateGeometryComposition();
-
- /**
- * Create a mesh actor for the metaballs
- */
- void CreateMetaballActors();
-
- /**
- * Create the render task and FBO to render the metaballs into a texture
- */
- void CreateMetaballImage();
-
- /**
- * Create a mesh image to render the final composition
- */
- void AddRefractionImage();
-
- /**
- * Function to create animations for the small variations of position inside the metaball
- */
- void CreateAnimations();
-
- /**
- * Function to reset metaball state
- */
- void ResetMetaballs(bool resetAnims);
-
- /**
- * Function to create disperse each of the ball that compose the metaball when exploding
- */
- void DisperseBallAnimation(int ball);
-
- /**
- * Function to make metaballs come back to reset position
- */
- void LaunchResetMetaballPosition(Animation &source);
-
- /**
- * Function to set things at the end of the animation
- */
- void EndDisperseAnimation(Animation &source);
-
- /**
- * Function to init dispersion of the metaballs one by one using a timer
- * (so not all the balls begin moving at the same time)
- */
- bool OnTimerDispersionTick();
-
- /**
- * Function to set the actual position of the metaballs when the user clicks the screen
- */
- void SetPositionToMetaballs(Vector2 & metaballCenter);
-};
-
-
-//-----------------------------------------------------------------------------------------------
-//
-// IMPLEMENTATION
-//
-//----------------
-
-MetaballExplosionController::MetaballExplosionController( Application& application )
-: mApplication( application ),
- mScreenSize(),
- mContentLayer(),
- mBackImage(),
- mMetaballFBO(),
- mMetaballRoot(),
- mMetaballs(),
- mPositionIndex(),
- mCompositionActor(),
- mCurrentTouchPosition(),
- mMetaballPosVariation(),
- mMetaballPosVariationFrom(),
- mMetaballPosVariationTo(),
- mMetaballCenter(),
- mPositionVarAnimation(),
- mDispersion( 0 ),
- mDispersionAnimation(),
- mTimerDispersion(),
- mTimeMult( 1.0f )
-{
- // Connect to the Application's Init signal
- mApplication.InitSignal().Connect( this, &MetaballExplosionController::Create );
-}
-
-MetaballExplosionController::~MetaballExplosionController()
-{
- // Nothing to do here;
-}
-
-void MetaballExplosionController::Create( Application& app )
-{
- Stage stage = Stage::GetCurrent();
-
- stage.KeyEventSignal().Connect(this, &MetaballExplosionController::OnKeyEvent);
-
- mScreenSize = stage.GetSize();
-
- mTimeMult = 1.0f;
-
- stage.SetBackgroundColor(Color::BLACK);
-
- //Set background image for the view
- mBackImage = DemoHelper::LoadImage( BACKGROUND_IMAGE );
-
- srand((unsigned)time(0));
-
- //Create internal data
- CreateMetaballActors();
- CreateMetaballImage();
- AddRefractionImage();
-
- CreateAnimations();
-
- mDispersion = 0;
- mTimerDispersion = Timer::New( 150 );
- mTimerDispersion.TickSignal().Connect(this, &MetaballExplosionController::OnTimerDispersionTick);
-
- // Connect the callback to the touch signal on the mesh actor
- stage.GetRootLayer().TouchSignal().Connect( this, &MetaballExplosionController::OnTouch );
-}
-
-Geometry MetaballExplosionController::CreateGeometry()
-{
- float aspect = (float)mScreenSize.y / (float)mScreenSize.x;
-
- // Create vertices and specify their color
- float xsize = mScreenSize.x * 0.5;
-
- //We create the meshdata for the metaballs
- struct VertexPosition { Vector2 position; };
- struct VertexTexture { Vector2 texture; };
- struct VertexNormal { Vector3 normal; };
-
- VertexPosition vertices[] = {
- { Vector2( -xsize, -xsize * aspect) },
- { Vector2( xsize, -xsize * aspect) },
- { Vector2( -xsize, xsize * aspect) },
- { Vector2( xsize, xsize * aspect) }
- };
-
- VertexTexture textures[] = {
- { Vector2(0.0f, 0.0f) },
- { Vector2(1.0f, 0.0f) },
- { Vector2(0.0f, 1.0f * aspect) },
- { Vector2(1.0f, 1.0f * aspect) }
- };
-
- unsigned int numberOfVertices = sizeof(vertices)/sizeof(VertexPosition);
-
- //Vertices
- Property::Map positionVertexFormat;
- positionVertexFormat["aPosition"] = Property::VECTOR2;
- PropertyBuffer positionVertices = PropertyBuffer::New( positionVertexFormat );
- positionVertices.SetData( vertices, numberOfVertices );
-
- //Textures
- Property::Map textureVertexFormat;
- textureVertexFormat["aTexture"] = Property::VECTOR2;
- PropertyBuffer textureVertices = PropertyBuffer::New( textureVertexFormat );
- textureVertices.SetData( textures, numberOfVertices );
-
- //Indices
- unsigned short indices[] = { 0, 3, 1, 0, 2, 3 };
-
- // Create the geometry object
- Geometry texturedQuadGeometry = Geometry::New();
- texturedQuadGeometry.AddVertexBuffer( positionVertices );
- texturedQuadGeometry.AddVertexBuffer( textureVertices );
-
- texturedQuadGeometry.SetIndexBuffer ( &indices[0], sizeof( indices )/ sizeof( indices[0] ) );
-
- return texturedQuadGeometry;
-}
-
-Geometry MetaballExplosionController::CreateGeometryComposition()
-{
- float aspect = (float)mScreenSize.y / (float)mScreenSize.x;
-
- // Create vertices and specify their color
- float xsize = mScreenSize.x * 0.5;
-
- //We create the meshdata for the metaballs
- struct VertexPosition { Vector2 position; };
- struct VertexTexture { Vector2 texture; };
- struct VertexNormal { Vector3 normal; };
-
- VertexPosition vertices[] = {
- { Vector2( -xsize, -xsize * aspect) },
- { Vector2( xsize, -xsize * aspect) },
- { Vector2( -xsize, xsize * aspect) },
- { Vector2( xsize, xsize * aspect) }
- };
-
- VertexTexture textures[] = {
- { Vector2(0.0f, 0.0f) },
- { Vector2(1.0f, 0.0f) },
- { Vector2(0.0f, 1.0f) },
- { Vector2(1.0f, 1.0f) }
- };
-
- unsigned int numberOfVertices = sizeof(vertices)/sizeof(VertexPosition);
-
- //Vertices
- Property::Map positionVertexFormat;
- positionVertexFormat["aPosition"] = Property::VECTOR2;
- PropertyBuffer positionVertices = PropertyBuffer::New( positionVertexFormat );
- positionVertices.SetData( vertices, numberOfVertices );
-
- //Textures
- Property::Map textureVertexFormat;
- textureVertexFormat["aTexture"] = Property::VECTOR2;
- PropertyBuffer textureVertices = PropertyBuffer::New( textureVertexFormat );
- textureVertices.SetData( textures, numberOfVertices );
-
- //Indices
- unsigned short indices[] = { 0, 3, 1, 0, 2, 3 };
-
- // Create the geometry object
- Geometry texturedQuadGeometry = Geometry::New();
- texturedQuadGeometry.AddVertexBuffer( positionVertices );
- texturedQuadGeometry.AddVertexBuffer( textureVertices );
-
- texturedQuadGeometry.SetIndexBuffer ( &indices[0], sizeof( indices )/ sizeof( indices[0] ) );
-
- return texturedQuadGeometry;
-}
-
-float randomNumber(float lowest, float highest)
-{
- float range=(highest-lowest);
- return lowest+range*rand()/RAND_MAX;
-}
-
-void MetaballExplosionController::CreateMetaballActors()
-{
- //Create the shader for the metaballs
- Shader shader = Shader::New( METABALL_VERTEX_SHADER, METABALL_FRAG_SHADER );
-
- Geometry metaballGeom = CreateGeometry();
- Renderer renderer = Renderer::New( metaballGeom, shader );
- renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON );
- renderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_RGB, BlendFactor::ONE );
- renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::ONE );
- renderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::ONE );
- renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::ONE );
-
- //Initialization of each of the metaballs
- for( int i = 0; i < METABALL_NUMBER; i++ )
- {
- mMetaballs[i].position = Vector2(0.0f, 0.0f);
- mMetaballs[i].radius = mMetaballs[i].initRadius = randomNumber(0.05f,0.07f);
-
- mMetaballs[i].actor = Actor::New( );
- mMetaballs[i].actor.SetName("Metaball");
- mMetaballs[i].actor.SetScale( 1.0f );
- mMetaballs[i].actor.SetParentOrigin( ParentOrigin::CENTER );
- mMetaballs[i].actor.AddRenderer( renderer );
-
- mMetaballs[i].positionIndex = mMetaballs[i].actor.RegisterProperty( "uPositionMetaball", mMetaballs[i].position );
-
- mMetaballs[i].positionVarIndex = mMetaballs[i].actor.RegisterProperty( "uPositionVar", Vector2(0.f,0.f) );
-
- mMetaballs[i].actor.RegisterProperty( "uGravityVector", Vector2(randomNumber(-0.2,0.2),randomNumber(-0.2,0.2)) );
-
- mMetaballs[i].actor.RegisterProperty( "uRadius", mMetaballs[i].radius );
-
- mMetaballs[i].actor.RegisterProperty( "uRadiusVar", 0.f );
-
- mMetaballs[i].actor.SetSize(400, 400);
- }
-
- //Root creation
- mMetaballRoot = Actor::New();
- mMetaballRoot.SetParentOrigin( ParentOrigin::CENTER );
- for( int i = 0; i < METABALL_NUMBER; i++ )
- {
- mMetaballRoot.Add( mMetaballs[i].actor );
- }
-
- //Initialization of variables related to metaballs
- mMetaballPosVariation = Vector2(0,0);
- mMetaballPosVariationFrom = Vector2(0,0);
- mMetaballPosVariationTo = Vector2(0,0);
- mCurrentTouchPosition = Vector2(0,0);
-}
-
-void MetaballExplosionController::CreateMetaballImage()
-{
- //We create an FBO and a render task to create to render the metaballs with a fragment shader
- Stage stage = Stage::GetCurrent();
- mMetaballFBO = FrameBufferImage::New(mScreenSize.x, mScreenSize.y, Pixel::RGBA8888, RenderBuffer::COLOR_DEPTH);
-
-
- stage.Add(mMetaballRoot);
-
- //Creation of the render task used to render the metaballs
- RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
- RenderTask task = taskList.CreateTask();
- task.SetRefreshRate( RenderTask::REFRESH_ALWAYS );
- task.SetSourceActor( mMetaballRoot );
- task.SetExclusive(true);
- task.SetClearColor( Color::BLACK );
- task.SetClearEnabled( true );
- task.SetTargetFrameBuffer( mMetaballFBO );
-}
-
-void MetaballExplosionController::AddRefractionImage()
-{
- //Create Gaussian blur for the rendered image
- FrameBufferImage fbo;
- fbo = FrameBufferImage::New( mScreenSize.x, mScreenSize.y, Pixel::RGBA8888, RenderBuffer::COLOR_DEPTH);
-
- GaussianBlurView gbv = GaussianBlurView::New(5, 2.0f, Pixel::RGBA8888, 0.5f, 0.5f, true);
- gbv.SetBackgroundColor(Color::TRANSPARENT);
- gbv.SetUserImageAndOutputRenderTarget( mMetaballFBO, fbo );
- gbv.SetSize(mScreenSize.x, mScreenSize.y);
- Stage::GetCurrent().Add(gbv);
- gbv.Activate();
-
- //Create new shader
- Shader shader = Shader::New( METABALL_VERTEX_SHADER, REFRACTION_FRAG_SHADER );
-
- //Create new texture set
- TextureSet textureSet = TextureSet::New();
- TextureSetImage( textureSet, 0u, mBackImage );
- TextureSetImage( textureSet, 1u, fbo );
-
- //Create geometry
- Geometry metaballGeom = CreateGeometryComposition();
-
- Renderer mRenderer = Renderer::New( metaballGeom, shader );
- mRenderer.SetTextures( textureSet );
-
- mCompositionActor = Actor::New( );
- mCompositionActor.SetParentOrigin(ParentOrigin::CENTER);
- mCompositionActor.SetPosition(Vector3(0.0f, 0.0f, 0.0f));
- mCompositionActor.SetSize(mScreenSize.x, mScreenSize.y);
-
- mCompositionActor.AddRenderer( mRenderer );
-
- Vector2 metaballCenter(0.0,0);
- metaballCenter.x = metaballCenter.x * 0.5;
- metaballCenter.y = metaballCenter.y * 0.5;
-
- mPositionIndex = mCompositionActor.RegisterProperty( "uPositionMetaball", metaballCenter );
-
- SetPositionToMetaballs(metaballCenter);
-
- mCompositionActor.SetSize(mScreenSize.x, mScreenSize.y);
-
- Stage stage = Stage::GetCurrent();
- stage.Add( mCompositionActor );
-}
-
-void MetaballExplosionController::CreateAnimations()
-{
- Vector2 direction;
-
- for( int i = 0; i < METABALL_NUMBER; i++ )
- {
- float key;
- KeyFrames keySinCosVariation = KeyFrames::New();
- Vector2 sinCosVariation(0,0);
-
- direction.x = randomNumber(-100.f,100.f);
- direction.y = randomNumber(-100.f,100.f);
-
- direction.Normalize();
- direction *= 0.1f;
-
- for( int j = 0; j < 360; j++ )
- {
- sinCosVariation.x = sin(j * Math::PI/180.f) * direction.x;
- sinCosVariation.y = cos(j * Math::PI/180.f) * direction.y;
- key = j/360.f;
- keySinCosVariation.Add(key, sinCosVariation);
- }
-
- mPositionVarAnimation[i] = Animation::New(3.f);
- mPositionVarAnimation[i].AnimateBetween(Property( mMetaballs[i].actor, mMetaballs[i].positionVarIndex ), keySinCosVariation);
- mPositionVarAnimation[i].SetLooping( true );
- mPositionVarAnimation[i].Play();
- }
-}
-
-void MetaballExplosionController::ResetMetaballs(bool resetAnims)
-{
- for( int i = 0; i < METABALL_NUMBER; i++ )
- {
- if (mDispersionAnimation[i])
- mDispersionAnimation[i].Clear();
-
- mMetaballs[i].position = Vector2(0.0f, 0.0f);
- mMetaballs[i].actor.SetProperty(mMetaballs[i].positionIndex, mMetaballs[i].position);
- }
- mTimerDispersion.Stop();
- mDispersion = 0;
-
- mCompositionActor.SetProperty( mPositionIndex, Vector2(0,0) );
-}
-
-void MetaballExplosionController::DisperseBallAnimation(int ball)
-{
- Vector2 position;
- position.x = randomNumber(-1.5f,1.5f);
- position.y = randomNumber(-1.5f,1.5f);
-
- mDispersionAnimation[ball] = Animation::New(2.0f * mTimeMult);
- mDispersionAnimation[ball].AnimateTo( Property(mMetaballs[ball].actor, mMetaballs[ball].positionIndex), position);
- mDispersionAnimation[ball].Play();
-
- if( ball == METABALL_NUMBER - 1 )
- mDispersionAnimation[ball].FinishedSignal().Connect( this, &MetaballExplosionController::LaunchResetMetaballPosition );
-}
-
-void MetaballExplosionController::LaunchResetMetaballPosition(Animation &source)
-{
- for( int i = 0; i < METABALL_NUMBER; i++ )
- {
- mDispersionAnimation[i] = Animation::New(1.5f + i*0.25f*mTimeMult);
- mDispersionAnimation[i].AnimateTo(Property(mMetaballs[i].actor, mMetaballs[i].positionIndex), Vector2(0,0));
- mDispersionAnimation[i].Play();
-
- if( i == METABALL_NUMBER - 1 )
- mDispersionAnimation[i].FinishedSignal().Connect( this, &MetaballExplosionController::EndDisperseAnimation );
- }
-}
-
-void MetaballExplosionController::EndDisperseAnimation(Animation &source)
-{
- mCompositionActor.SetProperty( mPositionIndex, Vector2(0,0) );
-}
-
-bool MetaballExplosionController::OnTimerDispersionTick()
-{
- if( mDispersion < METABALL_NUMBER )
- {
- DisperseBallAnimation(mDispersion);
- mDispersion++;
- }
- return true;
-}
-
-void MetaballExplosionController::SetPositionToMetaballs(Vector2 & metaballCenter)
-{
- //We set the position for the metaballs based on click position
- for( int i = 0; i < METABALL_NUMBER; i++ )
- {
- mMetaballs[i].position = metaballCenter;
- mMetaballs[i].actor.SetProperty(mMetaballs[i].positionIndex, mMetaballs[i].position);
- }
-
- mCompositionActor.SetProperty( mPositionIndex, metaballCenter );
-}
-
-bool MetaballExplosionController::OnTouch( Actor actor, const TouchData& touch )
-{
- float aspectR = mScreenSize.y / mScreenSize.x;
-
- switch( touch.GetState( 0 ) )
- {
- case PointState::DOWN:
- {
- ResetMetaballs(true);
-
- const Vector2 screen = touch.GetScreenPosition( 0 );
- Vector2 metaballCenter = Vector2((screen.x / mScreenSize.x) - 0.5, (aspectR * (mScreenSize.y - screen.y) / mScreenSize.y) - 0.5) * 2.0;
- SetPositionToMetaballs(metaballCenter);
-
- break;
- }
- case PointState::MOTION:
- {
- const Vector2 screen = touch.GetScreenPosition( 0 );
- Vector2 metaballCenter = Vector2((screen.x / mScreenSize.x) - 0.5, (aspectR * (mScreenSize.y - screen.y) / mScreenSize.y) - 0.5) * 2.0;
- SetPositionToMetaballs(metaballCenter);
- break;
- }
- case PointState::UP:
- case PointState::LEAVE:
- case PointState::INTERRUPTED:
- {
- mTimerDispersion.Start();
- break;
- }
- default:
- break;
- }
- return true;
-}
-
-void MetaballExplosionController::OnKeyEvent(const KeyEvent& event)
-{
- if(event.state == KeyEvent::Down)
- {
- if( IsKey( event, Dali::DALI_KEY_ESCAPE) || IsKey( event, Dali::DALI_KEY_BACK) )
- {
- mApplication.Quit();
- }
- }
-}
-
-
-//-----------------------------------------------------------------------------------------------
-//
-// Main functions
-//
-//-----------------------------------------------------------------------------------------------
-
-void RunTest( Application& application )
-{
- MetaballExplosionController test( application );
-
- application.MainLoop();
-}
-
-// Entry point for Linux & Tizen applications
-//
-int DALI_EXPORT_API main( int argc, char **argv )
-{
- Application application = Application::New( &argc, &argv );
-
- RunTest( application );
-
- return 0;
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <dali/dali.h>
-#include <dali/devel-api/images/texture-set-image.h>
-#include <dali/public-api/rendering/renderer.h>
-#include <dali-toolkit/dali-toolkit.h>
-
-#include <cstdio>
-#include <string>
-#include "shared/utility.h"
-
-using namespace Dali;
-using namespace Dali::Toolkit;
-
-namespace
-{
-const char * const BACKGROUND_IMAGE( DEMO_IMAGE_DIR "background-2.jpg" );
-const char * const TOOLBAR_IMAGE( DEMO_IMAGE_DIR "top-bar.png" );
-
-const float GRAVITY_X(0);
-const float GRAVITY_Y(-0.09);
-}
-
-#define METABALL_NUMBER 4
-
-const char*const METABALL_VERTEX_SHADER = DALI_COMPOSE_SHADER (
- attribute mediump vec2 aPosition;\n
- attribute mediump vec2 aTexture;\n
- attribute mediump vec3 aNormal;\n
- uniform mediump mat4 uMvpMatrix;\n
- uniform mediump vec3 uSize;\n
- uniform lowp vec4 uColor;\n
- varying mediump vec2 vTexCoord;\n
-
- void main()\n
- {\n
- mediump vec4 vertexPosition = vec4(aPosition.x, aPosition.y, 0.0, 1.0);\n
- vertexPosition = uMvpMatrix * vertexPosition;\n
- gl_Position = vertexPosition;\n
- vTexCoord = aTexture;\n
- }\n
-);
-
-
-const char*const METABALL_FRAG_SHADER = DALI_COMPOSE_SHADER (
- precision mediump float;\n
- varying vec2 vTexCoord;\n
- uniform vec2 uPositionMetaball;\n
- uniform vec2 uPositionVar;\n
- uniform vec2 uGravityVector;\n
- uniform float uRadius;\n
- uniform float uRadiusVar;\n
- uniform float uAspect;\n
- void main()\n
- {\n
- vec2 adjustedCoords = vTexCoord * 2.0 - 1.0;\n
- vec2 finalMetaballPosition = uPositionMetaball + uGravityVector + uPositionVar;\n
-
- float distance = (adjustedCoords.x - finalMetaballPosition.x) * (adjustedCoords.x - finalMetaballPosition.x) +
- (adjustedCoords.y - finalMetaballPosition.y) * (adjustedCoords.y - finalMetaballPosition.y);\n
- float finalRadius = uRadius + uRadiusVar;\n
- float color = finalRadius / sqrt( distance );\n
- vec2 bordercolor = vec2(0.0,0.0);\n
- if (vTexCoord.x < 0.1)\n
- {\n
- bordercolor.x = (0.1 - vTexCoord.x) * 0.8;\n
- }\n
- if (vTexCoord.x > 0.9)\n
- {\n
- bordercolor.x = (vTexCoord.x - 0.9) * 0.8;\n
- }\n
- if (vTexCoord.y < 0.1)\n
- {\n
- bordercolor.y = (0.1 - vTexCoord.y) * 0.8;\n
- }\n
- if (vTexCoord.y > (0.9 * uAspect))\n
- {\n
- bordercolor.y = (vTexCoord.y - (0.9 * uAspect)) * 0.8;\n
- }\n
- float border = (bordercolor.x + bordercolor.y) * 0.5;\n
- gl_FragColor = vec4(color + border,color + border,color + border,1.0);\n
- }\n
-);
-
-const char*const REFRACTION_FRAG_SHADER = DALI_COMPOSE_SHADER (
- precision mediump float;\n
- varying vec2 vTexCoord;\n
- uniform sampler2D sTexture;\n
- uniform sampler2D sEffect;\n
- void main()\n
- {\n
- vec4 metaColor = texture2D(sEffect, vTexCoord);\n
- vec2 zoomCoords;\n
- float bright = 1.0;\n
- if (metaColor.r > 0.85)\n
- {\n
- zoomCoords = ((vTexCoord - 0.5) * 0.95) + 0.5;\n
- }\n
- else if (metaColor.r > 0.81)\n
- {\n
- float interpolation = mix(0.95, 1.05, (0.85 - metaColor.r) * 50.0);\n
- zoomCoords = ((vTexCoord - 0.5) * interpolation) + 0.5;\n
- bright = 1.2;\n
- }\n
- else\n
- {\n
- zoomCoords = vTexCoord;\n
- }\n
-
- gl_FragColor = texture2D(sTexture, zoomCoords) * bright;\n
- }\n
- );
-
-const char*const FRAG_SHADER = DALI_COMPOSE_SHADER (
- precision mediump float;\n
- varying vec2 vTexCoord;\n
- uniform sampler2D sTexture;\n
- void main()\n
- {\n
- gl_FragColor = texture2D(sTexture, vTexCoord);\n
- }\n
-);
-
-
-struct MetaballInfo
-{
- Actor actor;
- Vector2 position;
- float radius;
- float initRadius;
-
- //Properties needed for animations
- Property::Index positionIndex;
- Property::Index positionVarIndex;
- Property::Index gravityIndex;
- Property::Index radiusIndex;
- Property::Index radiusVarIndex;
- Property::Index aspectIndex;
-};
-
-
-/***************************************************************************/
-/* Demo using Metaballs for Refraction when clicking the screen ************/
-/* The concept is similar to the Note 5 ScreenLock ************/
-/***************************************************************************/
-class MetaballRefracController : public ConnectionTracker
-{
-public:
- MetaballRefracController( Application& application );
- ~MetaballRefracController();
-
- void Create( Application& app );
- bool OnTouch( Actor actor, const TouchData& touch );
- void OnKeyEvent(const KeyEvent& event);
-
- void SetGravity(const Vector2 & gravity);
-
-
-private:
- Application& mApplication;
- Vector2 mScreenSize;
-
- Layer mContentLayer;
-
- Image mBackImage;
- FrameBufferImage mMetaballFBO;
-
- Actor mMetaballRoot;
- MetaballInfo mMetaballs[METABALL_NUMBER];
-
- Actor mCompositionActor;
-
- //Motion
- Vector2 mCurrentTouchPosition;
- Vector2 mMetaballPosVariation;
- Vector2 mMetaballPosVariationFrom;
- Vector2 mMetaballPosVariationTo;
- Vector2 mMetaballCenter;
-
- Vector2 mGravity;
- Vector2 mGravityVar;
-
- Renderer mRendererRefraction;
- TextureSet mTextureSetRefraction;
- Shader mShaderRefraction;
- TextureSet mTextureSetNormal;
- Shader mShaderNormal;
-
- //Animations
- Animation mGravityAnimation[METABALL_NUMBER];
- Animation mRadiusDecAnimation[METABALL_NUMBER];
- Animation mRadiusIncFastAnimation[METABALL_NUMBER];
- Animation mRadiusIncSlowAnimation[METABALL_NUMBER];
- Animation mRadiusVarAnimation[METABALL_NUMBER];
- Animation mPositionVarAnimation[METABALL_NUMBER];
-
- //Private functions
- Geometry CreateGeometry();
- Geometry CreateGeometryComposition();
-
- void CreateMetaballActors();
- void CreateMetaballImage();
- void AddRefractionImage();
- void CreateAnimations();
-
- void LaunchRadiusIncSlowAnimations(Animation &source);
- void LaunchGetBackToPositionAnimation(Animation &source);
-
- void StopClickAnimations();
- void StopAfterClickAnimations();
-
- void ResetMetaballsState();
-
- void SetPositionToMetaballs(Vector2 & metaballCenter);
-};
-
-
-//-----------------------------------------------------------------------------------------------
-//
-// IMPLEMENTATION
-//
-//----------------
-
-MetaballRefracController::MetaballRefracController( Application& application )
- : mApplication( application )
-{
- // Connect to the Application's Init signal
- mApplication.InitSignal().Connect( this, &MetaballRefracController::Create );
-}
-
-MetaballRefracController::~MetaballRefracController()
-{
- // Nothing to do here;
-}
-
-/*
- * Setter function for gravity
- */
-void MetaballRefracController::SetGravity(const Vector2 & gravity)
-{
- mGravity = gravity;
-}
-
-/**
- * Main create function, it creates the metaballs and all the
- */
-void MetaballRefracController::Create( Application& app )
-{
- Stage stage = Stage::GetCurrent();
-
- stage.KeyEventSignal().Connect(this, &MetaballRefracController::OnKeyEvent);
-
- mScreenSize = stage.GetSize();
-
- stage.SetBackgroundColor(Color::BLACK);
-
- //Set background image for the view
- mBackImage = DemoHelper::LoadImage( BACKGROUND_IMAGE );
-
- mGravity = Vector2(GRAVITY_X,GRAVITY_Y);
- mGravityVar = Vector2(0,0);
-
- //Create internal data
- CreateMetaballActors();
- CreateMetaballImage();
- AddRefractionImage();
-
- CreateAnimations();
-
- // Connect the callback to the touch signal on the mesh actor
- stage.GetRootLayer().TouchSignal().Connect( this, &MetaballRefracController::OnTouch );
-}
-
-/**
- * Create a mesh data with the geometry for the metaball rendering
- */
-Geometry MetaballRefracController::CreateGeometry()
-{
- float aspect = (float)mScreenSize.y / (float)mScreenSize.x;
-
- // Create vertices and specify their color
- float xsize = mScreenSize.x * 0.5;
-
- //We create the meshdata for the metaballs
- struct VertexPosition { Vector2 position; };
- struct VertexTexture { Vector2 texture; };
- struct VertexNormal { Vector3 normal; };
-
- VertexPosition vertices[] = {
- { Vector2( -xsize, -xsize * aspect) },
- { Vector2( xsize, -xsize * aspect) },
- { Vector2( -xsize, xsize * aspect) },
- { Vector2( xsize, xsize * aspect) }
- };
-
- VertexTexture textures[] = {
- { Vector2(0.0f, 0.0f) },
- { Vector2(1.0f, 0.0f) },
- { Vector2(0.0f, 1.0f * aspect) },
- { Vector2(1.0f, 1.0f * aspect) }
- };
-
- VertexNormal normals [] = {
- { Vector3(0.0f, 0.0f, 1.0f) },
- { Vector3(0.0f, 0.0f, 1.0f) },
- { Vector3(0.0f, 0.0f, 1.0f) },
- { Vector3(0.0f, 0.0f, 1.0f) }
- };
-
- unsigned int numberOfVertices = sizeof(vertices)/sizeof(VertexPosition);
-
- //Vertices
- Property::Map positionVertexFormat;
- positionVertexFormat["aPosition"] = Property::VECTOR2;
- PropertyBuffer positionVertices = PropertyBuffer::New( positionVertexFormat );
- positionVertices.SetData( vertices, numberOfVertices );
-
- //Textures
- Property::Map textureVertexFormat;
- textureVertexFormat["aTexture"] = Property::VECTOR2;
- PropertyBuffer textureVertices = PropertyBuffer::New( textureVertexFormat );
- textureVertices.SetData( textures, numberOfVertices );
-
- //Normals
- Property::Map normalVertexFormat;
- normalVertexFormat["aNormal"] = Property::VECTOR3;
- PropertyBuffer normalVertices = PropertyBuffer::New( normalVertexFormat );
- normalVertices.SetData( normals, numberOfVertices );
-
- //Indices
- unsigned short indices[] = { 0, 3, 1, 0, 2, 3 };
-
- // Create the geometry object
- Geometry texturedQuadGeometry = Geometry::New();
- texturedQuadGeometry.AddVertexBuffer( positionVertices );
- texturedQuadGeometry.AddVertexBuffer( textureVertices );
- texturedQuadGeometry.AddVertexBuffer( normalVertices );
-
- texturedQuadGeometry.SetIndexBuffer ( &indices[0], 6 );
-
- return texturedQuadGeometry;
-}
-
-/**
- * Create a mesh data with the geometry for the metaball rendering
- */
-Geometry MetaballRefracController::CreateGeometryComposition()
-{
- float aspect = (float)mScreenSize.y / (float)mScreenSize.x;
-
- // Create vertices and specify their color
- float xsize = mScreenSize.x * 0.5;
-
- //We create the meshdata for the metaballs
- struct VertexPosition { Vector2 position; };
- struct VertexTexture { Vector2 texture; };
- struct VertexNormal { Vector3 normal; };
-
- VertexPosition vertices[] = {
- { Vector2( -xsize, -xsize * aspect) },
- { Vector2( xsize, -xsize * aspect) },
- { Vector2( -xsize, xsize * aspect) },
- { Vector2( xsize, xsize * aspect) }
- };
-
- VertexTexture textures[] = {
- { Vector2(0.0f, 0.0f) },
- { Vector2(1.0f, 0.0f) },
- { Vector2(0.0f, 1.0f) },
- { Vector2(1.0f, 1.0f) }
- };
-
- VertexNormal normals [] = {
- { Vector3(0.0f, 0.0f, 1.0f) },
- { Vector3(0.0f, 0.0f, 1.0f) },
- { Vector3(0.0f, 0.0f, 1.0f) },
- { Vector3(0.0f, 0.0f, 1.0f) }
- };
-
- unsigned int numberOfVertices = sizeof(vertices)/sizeof(VertexPosition);
-
- //Vertices
- Property::Map positionVertexFormat;
- positionVertexFormat["aPosition"] = Property::VECTOR2;
- PropertyBuffer positionVertices = PropertyBuffer::New( positionVertexFormat );
- positionVertices.SetData( vertices, numberOfVertices );
-
- //Textures
- Property::Map textureVertexFormat;
- textureVertexFormat["aTexture"] = Property::VECTOR2;
- PropertyBuffer textureVertices = PropertyBuffer::New( textureVertexFormat );
- textureVertices.SetData( textures, numberOfVertices );
-
- //Normals
- Property::Map normalVertexFormat;
- normalVertexFormat["aNormal"] = Property::VECTOR3;
- PropertyBuffer normalVertices = PropertyBuffer::New( normalVertexFormat );
- normalVertices.SetData( normals, numberOfVertices );
-
- //Indices
- unsigned short indices[] = { 0, 3, 1, 0, 2, 3 };
-
- // Create the geometry object
- Geometry texturedQuadGeometry = Geometry::New();
- texturedQuadGeometry.AddVertexBuffer( positionVertices );
- texturedQuadGeometry.AddVertexBuffer( textureVertices );
- texturedQuadGeometry.AddVertexBuffer( normalVertices );
-
- texturedQuadGeometry.SetIndexBuffer ( &indices[0], sizeof( indices )/ sizeof( indices[0] ) );
-
- return texturedQuadGeometry;
-}
-
-/**
- * Create a mesh actor for the metaballs
- */
-void MetaballRefracController::CreateMetaballActors()
-{
- //We create metaball structures
- //With MeshData Textured
- float aspect = (float)mScreenSize.y / (float)mScreenSize.x;
-
- //Create the renderer for the metaballs
- Shader shader = Shader::New( METABALL_VERTEX_SHADER, METABALL_FRAG_SHADER );
- Geometry metaballGeom = CreateGeometry();
- Renderer renderer = Renderer::New( metaballGeom, shader );
- renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON );
- renderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_RGB, BlendFactor::ONE );
- renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::ONE );
- renderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::ONE );
- renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::ONE );
-
- //Each metaball has a different radius
- mMetaballs[0].radius = mMetaballs[0].initRadius = 0.0145f;
- mMetaballs[1].radius = mMetaballs[1].initRadius = 0.012f;
- mMetaballs[2].radius = mMetaballs[2].initRadius = 0.0135f;
- mMetaballs[3].radius = mMetaballs[3].initRadius = 0.0135f;
-
- //Initialization of each of the metaballs
- for (int i = 0 ; i < METABALL_NUMBER ; i++)
- {
- mMetaballs[i].position = Vector2(0.0f, 0.0f);
-
- mMetaballs[i].actor = Actor::New( );
- mMetaballs[i].actor.SetName("Metaball");
- mMetaballs[i].actor.SetScale( 1.0f );
- mMetaballs[i].actor.SetParentOrigin( ParentOrigin::CENTER );
-
-
- mMetaballs[i].actor.AddRenderer( renderer );
-
- mMetaballs[i].positionIndex = mMetaballs[i].actor.RegisterProperty( "uPositionMetaball", mMetaballs[i].position );
-
- mMetaballs[i].positionVarIndex = mMetaballs[i].actor.RegisterProperty( "uPositionVar", Vector2(0.f,0.f) );
-
- mMetaballs[i].gravityIndex = mMetaballs[i].actor.RegisterProperty( "uGravityVector", Vector2(0.f,0.f) );
-
- mMetaballs[i].radiusIndex = mMetaballs[i].actor.RegisterProperty( "uRadius", mMetaballs[i].radius );
-
- mMetaballs[i].radiusVarIndex = mMetaballs[i].actor.RegisterProperty( "uRadiusVar", 0.f );
-
- mMetaballs[i].aspectIndex = mMetaballs[i].actor.RegisterProperty( "uAspect", aspect );
-
- mMetaballs[i].actor.SetSize(400, 400);
- }
-
- //Root creation
- mMetaballRoot = Actor::New();
- mMetaballRoot.SetParentOrigin( ParentOrigin::CENTER );
- for (int i = 0 ; i < METABALL_NUMBER ; i++)
- {
- mMetaballRoot.Add( mMetaballs[i].actor );
- }
-
- //Initialization of variables related to metaballs
- mMetaballPosVariation = Vector2(0,0);
- mMetaballPosVariationFrom = Vector2(0,0);
- mMetaballPosVariationTo = Vector2(0,0);
- mCurrentTouchPosition = Vector2(0,0);
-}
-
-/**
- * Create the render task and FBO to render the metaballs into a texture
- */
-void MetaballRefracController::CreateMetaballImage()
-{
- //We create an FBO and a render task to create to render the metaballs with a fragment shader
- Stage stage = Stage::GetCurrent();
- mMetaballFBO = FrameBufferImage::New(mScreenSize.x, mScreenSize.y );
-
- stage.Add(mMetaballRoot);
-
- //Creation of the render task used to render the metaballs
- RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
- RenderTask task = taskList.CreateTask();
- task.SetRefreshRate( RenderTask::REFRESH_ALWAYS );
- task.SetSourceActor( mMetaballRoot );
- task.SetExclusive(true);
- task.SetClearColor( Color::BLACK );
- task.SetClearEnabled( true );
- task.SetTargetFrameBuffer( mMetaballFBO );
-}
-
-/**
- * Create a mesh image to render the final composition
- */
-void MetaballRefracController::AddRefractionImage()
-{
- //Creation of the composition image
-
- //Create geometry
- Geometry metaballGeom = CreateGeometryComposition();
-
- //Create Refraction shader and renderer
- mShaderRefraction = Shader::New( METABALL_VERTEX_SHADER, REFRACTION_FRAG_SHADER );
-
- //Create new texture set
- mTextureSetRefraction = TextureSet::New();
- TextureSetImage( mTextureSetRefraction, 0u, mBackImage );
- TextureSetImage( mTextureSetRefraction, 1u, mMetaballFBO );
-
- //Create normal shader
- mShaderNormal = Shader::New( METABALL_VERTEX_SHADER, FRAG_SHADER );
-
- //Create new texture set
- mTextureSetNormal = TextureSet::New();
- TextureSetImage( mTextureSetNormal, 0u, mBackImage );
-
- //Create actor
- mCompositionActor = Actor::New( );
- mCompositionActor.SetParentOrigin(ParentOrigin::CENTER);
- mCompositionActor.SetPosition(Vector3(0.0f, 0.0f, 0.0f));
- mCompositionActor.SetSize(mScreenSize.x, mScreenSize.y);
-
- mRendererRefraction = Renderer::New( metaballGeom, mShaderNormal );
- mRendererRefraction.SetTextures( mTextureSetNormal );
- mCompositionActor.AddRenderer( mRendererRefraction );
-
- Stage stage = Stage::GetCurrent();
- stage.Add( mCompositionActor );
-}
-
-/**
- * Creation of all the metaballs animations (gravity, movement, size, etc.)
- */
-void MetaballRefracController::CreateAnimations()
-{
- int i = 0;
- float key;
-
- mPositionVarAnimation[1] = Animation::New(2.f);
- mPositionVarAnimation[1].SetLooping( false );
- mPositionVarAnimation[1].Pause();
- mPositionVarAnimation[1].FinishedSignal().Connect( this, &MetaballRefracController::LaunchGetBackToPositionAnimation );
-
- KeyFrames keySinCosVariation = KeyFrames::New();
- Vector2 sinCosVariation(0,0);
- for ( i = 0 ; i < 360 ; i++)
- {
- sinCosVariation.x = 0.05f * (-sin(i * Math::PI/180.f) + cos(i * Math::PI/180.f));
- sinCosVariation.y = 0.05f * (sin(i * Math::PI/180.f) - cos(i * Math::PI/180.f));
- key = i/360.f;
- keySinCosVariation.Add(key, sinCosVariation);
- }
-
- mPositionVarAnimation[2] = Animation::New(6.f);
- mPositionVarAnimation[2].AnimateBetween(Property( mMetaballs[2].actor, mMetaballs[2].positionVarIndex ), keySinCosVariation);
- mPositionVarAnimation[2].SetLooping( true );
- mPositionVarAnimation[2].Pause();
-
- KeyFrames keyCosSinVariation = KeyFrames::New();
- Vector2 cosSinVariation(0,0);
- for ( i = 0 ; i < 360 ; i++)
- {
- cosSinVariation.x = 0.05f * (-sin(i * Math::PI/180.f) - cos(i * Math::PI/180.f));
- cosSinVariation.y = 0.05f * (sin(i * Math::PI/180.f) + cos(i * Math::PI/180.f));
- key = i/360.f;
- keyCosSinVariation.Add(key, cosSinVariation);
- }
-
- mPositionVarAnimation[3] = Animation::New(6.f);
- mPositionVarAnimation[3].AnimateBetween(Property( mMetaballs[3].actor, mMetaballs[3].positionVarIndex ), keyCosSinVariation);
- mPositionVarAnimation[3].SetLooping( true );
- mPositionVarAnimation[3].Pause();
-
- //Animations for gravity
- for ( i = 0 ; i < METABALL_NUMBER ; i++)
- {
- mGravityAnimation[i] = Animation::New(25.f);
- mGravityAnimation[i].AnimateBy( Property( mMetaballs[i].actor, mMetaballs[i].gravityIndex ), mGravity * 25.f * 3.f);
- mGravityAnimation[i].SetLooping( false );
- mGravityAnimation[i].Pause();
- }
-
- //Animation to decrease size of metaballs when there is no click
- for ( i = 0 ; i < METABALL_NUMBER ; i++)
- {
- mRadiusDecAnimation[i] = Animation::New(25.f);
- mRadiusDecAnimation[i].AnimateBy( Property( mMetaballs[i].actor, mMetaballs[i].radiusIndex ), -0.004f * 25.f * 3.f);
- mRadiusDecAnimation[i].SetLooping( false );
- mRadiusDecAnimation[i].Pause();
- }
-
- //Animation to grow the size of the metaballs the first second of the click
- for ( i = 0 ; i < METABALL_NUMBER ; i++)
- {
- mRadiusIncFastAnimation[i] = Animation::New(0.3f);
- mRadiusIncFastAnimation[i].AnimateBy( Property( mMetaballs[i].actor, mMetaballs[i].radiusIndex ), 0.06f);
- mRadiusIncFastAnimation[i].SetLooping( false );
- mRadiusIncFastAnimation[i].Pause();
- }
- mRadiusIncFastAnimation[0].FinishedSignal().Connect( this, &MetaballRefracController::LaunchRadiusIncSlowAnimations );
-
- //Animation to grow the size of the metaballs afterwards
- for ( i = 0 ; i < METABALL_NUMBER ; i++)
- {
- mRadiusIncSlowAnimation[i] = Animation::New(20.f);
- mRadiusIncSlowAnimation[i].AnimateBy( Property( mMetaballs[i].actor, mMetaballs[i].radiusIndex ), 0.04f);
- mRadiusIncSlowAnimation[i].SetLooping( false );
- mRadiusIncSlowAnimation[i].Pause();
- }
-
- //keyframes of a sin function
- KeyFrames keySin = KeyFrames::New();
- float val;
- for ( i = 0 ; i < 360 ; i++)
- {
- val = 0.01f * sin(i * Math::PI/180.f);
- key = i/360.f;
- keySin.Add(key, val);
- }
-
- //Animation to change the size of the metaball
- mRadiusVarAnimation[2] = Animation::New(8.f);
- mRadiusVarAnimation[2].AnimateBetween(Property( mMetaballs[2].actor, mMetaballs[2].radiusVarIndex ), keySin);
- mRadiusVarAnimation[2].SetLooping( true );
-
- //keyframes of a cos function
- KeyFrames keyCos = KeyFrames::New();
- for ( i = 0 ; i < 360 ; i++)
- {
- val = 0.01f * cos(i * Math::PI/180.f);
- key = i/360.f;
- keyCos.Add(key, val);
- }
-
- //Animation to change the size of the metaball
- mRadiusVarAnimation[3] = Animation::New(8.f);
- mRadiusVarAnimation[3].AnimateBetween(Property( mMetaballs[3].actor, mMetaballs[3].radiusVarIndex ), keyCos);
- mRadiusVarAnimation[3].SetLooping( true );
-}
-
-/**
- * Function to launch the animation to get the metaball[1] back to the center
- */
-void MetaballRefracController::LaunchGetBackToPositionAnimation(Animation &source)
-{
- mMetaballPosVariationTo = Vector2(0,0);
-
- mPositionVarAnimation[1] = Animation::New(1.f);
- mPositionVarAnimation[1].SetLooping( false );
- mPositionVarAnimation[1].AnimateTo(Property( mMetaballs[1].actor, mMetaballs[1].positionVarIndex ), Vector2(0,0));
- mPositionVarAnimation[1].Play();
-}
-
-/**
- * Function to launch the gro slow radius for the metaballs, and also the small variations for metaball[2] and [3]
- */
-void MetaballRefracController::LaunchRadiusIncSlowAnimations(Animation &source)
-{
- for (int i = 0 ; i < METABALL_NUMBER ; i++)
- {
- mRadiusIncSlowAnimation[i].Play();
- }
- mPositionVarAnimation[2].Play();
- mPositionVarAnimation[3].Play();
-}
-
-/**
- * Function to stop all animations related to the click of the user in the screen
- */
-void MetaballRefracController::StopClickAnimations()
-{
- for (int i = 0 ; i < METABALL_NUMBER ; i++)
- {
- mRadiusIncSlowAnimation[i].Stop();
- mRadiusIncFastAnimation[i].Stop();
- }
- mPositionVarAnimation[1].Stop();
- mPositionVarAnimation[2].Stop();
- mPositionVarAnimation[3].Stop();
-}
-
-/**
- * Function to stop all animations related to the after click of the user in the screen
- */
-void MetaballRefracController::StopAfterClickAnimations()
-{
- for (int i = 0 ; i < METABALL_NUMBER ; i++)
- {
- mGravityAnimation[i].Stop();
- mRadiusDecAnimation[i].Stop();
-
- mMetaballs[i].radius = mMetaballs[i].initRadius;
-
- mMetaballs[i].actor.SetProperty(mMetaballs[i].gravityIndex, Vector2(0,0));
- mMetaballs[i].actor.SetProperty(mMetaballs[i].radiusIndex, mMetaballs[i].radius);
- mMetaballs[i].actor.SetProperty(mMetaballs[i].radiusVarIndex, 0.f);
- }
- mRadiusVarAnimation[2].Stop();
- mRadiusVarAnimation[3].Stop();
-}
-
-/*
- * Function that resets the sate of the different Metaballs
- */
-void MetaballRefracController::ResetMetaballsState()
-{
- mRendererRefraction.SetTextures(mTextureSetNormal);
- mRendererRefraction.SetShader( mShaderNormal );
-
- for (int i = 0 ; i < METABALL_NUMBER ; i++)
- {
- mMetaballs[i].radius = mMetaballs[i].initRadius;
- }
-
- mMetaballPosVariationTo = Vector2(0,0);
- mMetaballPosVariationFrom = Vector2(0,0);
- mMetaballPosVariation = Vector2(0,0);
-
- mGravityVar = Vector2(0,0);
-}
-
-/**
- * Function to set the actual position of the metaballs when the user clicks the screen
- */
-void MetaballRefracController::SetPositionToMetaballs(Vector2 & metaballCenter)
-{
- //We set the position for the metaballs based on click position
- for (int i = 0 ; i < METABALL_NUMBER ; i++)
- {
- mMetaballs[i].position = metaballCenter;
- mMetaballs[i].actor.SetProperty(mMetaballs[i].positionIndex, mMetaballs[0].position); // 0 y no i ?!?!?!
- }
-}
-
-bool MetaballRefracController::OnTouch( Actor actor, const TouchData& touch )
-{
- float aspectR = mScreenSize.y / mScreenSize.x;
- switch( touch.GetState( 0 ) )
- {
- case PointState::DOWN:
- {
- StopAfterClickAnimations();
- for (int i = 0 ; i < METABALL_NUMBER ; i++)
- mRadiusIncFastAnimation[i].Play();
- mRadiusVarAnimation[2].Play();
- mRadiusVarAnimation[3].Play();
-
- //We draw with the refraction-composition shader
- mRendererRefraction.SetTextures(mTextureSetRefraction);
- mRendererRefraction.SetShader( mShaderRefraction );
- mCurrentTouchPosition = touch.GetScreenPosition( 0 );
-
- //we use the click position for the metaballs
- Vector2 metaballCenter = Vector2((mCurrentTouchPosition.x / mScreenSize.x) - 0.5, (aspectR * (mScreenSize.y - mCurrentTouchPosition.y) / mScreenSize.y) - 0.5) * 2.0;
- SetPositionToMetaballs(metaballCenter);
- break;
- }
- case PointState::MOTION:
- {
- Vector2 screen = touch.GetScreenPosition( 0 );
- Vector2 displacement = screen - mCurrentTouchPosition;
- mCurrentTouchPosition = screen;
-
- mMetaballPosVariationTo.x += (displacement.x / mScreenSize.x) * 2.2;
- mMetaballPosVariationTo.y += (- displacement.y / mScreenSize.y) * 2.2;
-
- if (mPositionVarAnimation[1])
- {
- mPositionVarAnimation[1].FinishedSignal().Disconnect( this, &MetaballRefracController::LaunchGetBackToPositionAnimation );
- mPositionVarAnimation[1].Stop();
- }
- mPositionVarAnimation[1] = Animation::New(1.f);
- mPositionVarAnimation[1].SetLooping( false );
- mPositionVarAnimation[1].AnimateTo(Property( mMetaballs[1].actor, mMetaballs[1].positionVarIndex ), mMetaballPosVariationTo);
- mPositionVarAnimation[1].FinishedSignal().Connect( this, &MetaballRefracController::LaunchGetBackToPositionAnimation );
- mPositionVarAnimation[1].Play();
-
- //we use the click position for the metaballs
- Vector2 metaballCenter = Vector2((screen.x / mScreenSize.x) - 0.5, (aspectR * (mScreenSize.y - screen.y) / mScreenSize.y) - 0.5) * 2.0;
- SetPositionToMetaballs(metaballCenter);
- break;
- }
- case PointState::UP:
- case PointState::LEAVE:
- case PointState::INTERRUPTED:
- {
- //Stop click animations
- StopClickAnimations();
-
- //Launch out of screen animations
- for (int i = 0 ; i < METABALL_NUMBER ; i++)
- mGravityAnimation[i].Play();
-
- for (int i = 0 ; i < METABALL_NUMBER ; i++)
- mRadiusDecAnimation[i].Play();
-
- break;
- }
- default:
- break;
- }
- return true;
-}
-
-
-void MetaballRefracController::OnKeyEvent(const KeyEvent& event)
-{
- if(event.state == KeyEvent::Down)
- {
- if( IsKey( event, Dali::DALI_KEY_ESCAPE) || IsKey( event, Dali::DALI_KEY_BACK) )
- {
- mApplication.Quit();
- }
- }
-}
-
-
-//
-//
-//-----------------------------------------------------------------------------------------------
-
-void RunTest( Application& application )
-{
- MetaballRefracController test( application );
-
- application.MainLoop();
-}
-
-// Entry point for Linux & Tizen applications
-//
-int DALI_EXPORT_API main( int argc, char **argv )
-{
- Application application = Application::New( &argc, &argv );
-
- RunTest( application );
-
- return 0;
-}
// Demo setup parameters
//
-//#define MULTIPLE_MOTION_BLURRED_ACTORS
-#ifndef MULTIPLE_MOTION_BLURRED_ACTORS
-
const float MOTION_BLUR_ACTOR_WIDTH = 256; // actor size on screen
const float MOTION_BLUR_ACTOR_HEIGHT = 256; // ""
-
-#else //#ifndef MULTIPLE_MOTION_BLURRED_ACTORS
-
-const float MOTION_BLUR_ACTOR_WIDTH = 150; // actor size on screen
-const float MOTION_BLUR_ACTOR_HEIGHT = 112; // ""
-
-#endif //#ifndef MULTIPLE_MOTION_BLURRED_ACTORS
-
-
const unsigned int MOTION_BLUR_NUM_SAMPLES = 8;
const int MOTION_BLUR_NUM_ACTOR_IMAGES = 5;
// set actor shader to the blur one
Toolkit::SetMotionBlurProperties( mMotionBlurImageView, MOTION_BLUR_NUM_SAMPLES );
-
-#ifdef MULTIPLE_MOTION_BLURRED_ACTORS
-
- ///////////////////////////////////////////////////////
- //
- // Motion blurred actor 2
- //
-
- mMotionBlurImageView2 = ImageView::New(image);
- mMotionBlurImageView2.SetParentOrigin( ParentOrigin::CENTER );
- mMotionBlurImageView2.SetSize(mMotionBlurActorSize.x, mMotionBlurActorSize.y);
- mMotionBlurImageView2.SetPosition(mMotionBlurActorSize.x * 1.1f, 0.0f);
- mMotionBlurImageView.Add( mMotionBlurImageView2 );
-
- // set actor shader to the blur one
- Toolkit::SetMotionBlurProperties( mMotionBlurImageView2, MOTION_BLUR_NUM_SAMPLES );
- mMotionBlurImageView2.SetProperty( Toolkit::ImageView::Property::IMAGE, mMotionBlurEffect );
-
-
- ///////////////////////////////////////////////////////
- //
- // Motion blurred actor 3
- //
-
- mMotionBlurImageView3 = ImageView::New(image);
- mMotionBlurImageView3.SetParentOrigin( ParentOrigin::CENTER );
- mMotionBlurImageView3.SetSize(mMotionBlurActorSize.x, mMotionBlurActorSize.y);
- mMotionBlurImageView3.SetPosition(-mMotionBlurActorSize.x * 1.1f, 0.0f);
- mMotionBlurImageView.Add( mMotionBlurImageView3 );
-
- // set actor shader to the blur one
- Toolkit::SetMotionBlurProperties( mMotionBlurImageView3, MOTION_BLUR_NUM_SAMPLES );
- mMotionBlurImageView3.SetProperty( Toolkit::ImageView::Property::IMAGE, mMotionBlurEffect );
-
-
- ///////////////////////////////////////////////////////
- //
- // Motion blurred actor 4
- //
-
- mMotionBlurImageView4 = ImageView::New(image);
- mMotionBlurImageView4.SetParentOrigin( ParentOrigin::CENTER );
- mMotionBlurImageView4.SetSize(mMotionBlurActorSize.x, mMotionBlurActorSize.y);
- mMotionBlurImageView4.SetPosition(0.0f, mMotionBlurActorSize.y * 1.1f);
- mMotionBlurImageView.Add( mMotionBlurImageView4 );
-
- // set actor shader to the blur one
- Toolkit::SetMotionBlurProperties( mMotionBlurImageView4, MOTION_BLUR_NUM_SAMPLES );
- mMotionBlurImageView4.SetProperty( Toolkit::ImageView::Property::IMAGE, mMotionBlurEffect );
-
- ///////////////////////////////////////////////////////
- //
- // Motion blurred actor 5
- //
-
- mMotionBlurImageView5 = ImageView::New(image);
- mMotionBlurImageView5.SetParentOrigin( ParentOrigin::CENTER );
- mMotionBlurImageView5.SetSize(mMotionBlurActorSize.x, mMotionBlurActorSize.y);
- mMotionBlurImageView5.SetPosition(0.0f, -mMotionBlurActorSize.y * 1.1f);
- mMotionBlurImageView.Add( mMotionBlurImageView5 );
-
- // set actor shader to the blur one
- Toolkit::SetMotionBlurProperties( mMotionBlurImageView5, MOTION_BLUR_NUM_SAMPLES );
- mMotionBlurImageView5.SetProperty( Toolkit::ImageView::Property::IMAGE, mMotionBlurEffect );
-#endif //#ifdef MULTIPLE_MOTION_BLURRED_ACTORS
}
void Rotate( DeviceOrientation orientation )
}
SetImageFittedInBox( mMotionBlurImageView, mMotionBlurEffect, MOTION_BLUR_ACTOR_IMAGES[mCurrentImage], mMotionBlurActorSize.x, mMotionBlurActorSize.y );
-#ifdef MULTIPLE_MOTION_BLURRED_ACTORS
- mMotionBlurImageView2.SetImage(blurImage);
- mMotionBlurImageView3.SetImage(blurImage);
- mMotionBlurImageView4.SetImage(blurImage);
- mMotionBlurImageView5.SetImage(blurImage);
-#endif
}
ImageView mMotionBlurImageView;
Size mMotionBlurActorSize;
-#ifdef MULTIPLE_MOTION_BLURRED_ACTORS
- ImageView mMotionBlurImageView2;
- ImageView mMotionBlurImageView3;
- ImageView mMotionBlurImageView4;
- ImageView mMotionBlurImageView5;
-#endif //#ifdef MULTIPLE_MOTION_BLURRED_ACTORS
-
// animate actor to position where user taps screen
Animation mActorTapMovementAnimation;
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// EXTERNAL INCLUDES
-#include <dali/devel-api/images/texture-set-image.h>
-#include <dali/public-api/rendering/renderer.h>
-#include <dali-toolkit/dali-toolkit.h>
-#include <dali-toolkit/devel-api/controls/bubble-effect/bubble-emitter.h>
-#include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
-#include <dali-toolkit/devel-api/controls/gaussian-blur-view/gaussian-blur-view.h>
-
-#include <cstdio>
-#include <iostream>
-
-// INTERNAL INCLUDES
-#include "shared/view.h"
-#include "shared/utility.h"
-
-using namespace Dali;
-using namespace Dali::Toolkit;
-
-class NewWindowController;
-
-namespace
-{
-const char * const BACKGROUND_IMAGE( DEMO_IMAGE_DIR "background-2.jpg" );
-const char * const TOOLBAR_IMAGE( DEMO_IMAGE_DIR "top-bar.png" );
-const char * const LOSE_CONTEXT_IMAGE( DEMO_IMAGE_DIR "icon-cluster-wobble.png" );
-const char * const LOSE_CONTEXT_IMAGE_SELECTED( DEMO_IMAGE_DIR "icon-cluster-wobble-selected.png" );
-const char * const BASE_IMAGE( DEMO_IMAGE_DIR "gallery-large-14.jpg" );
-const char * const EFFECT_IMAGE( DEMO_IMAGE_DIR "gallery-large-18.jpg" );
-const char * const LOGO_IMAGE(DEMO_IMAGE_DIR "dali-logo.png");
-
-const float EXPLOSION_DURATION(1.2f);
-const unsigned int EMIT_INTERVAL_IN_MS(40);
-const float TRACK_DURATION_IN_MS(970);
-
-Application gApplication;
-NewWindowController* gNewWindowController(NULL);
-
-#define MAKE_SHADER(A)#A
-
-const char* VERTEX_COLOR_MESH = MAKE_SHADER(
-attribute mediump vec3 aPosition;\n
-attribute lowp vec3 aColor;\n
-uniform mediump mat4 uMvpMatrix;\n
-uniform mediump vec3 uSize;\n
-varying lowp vec3 vColor;\n
-\n
-void main()\n
-{\n
- gl_Position = uMvpMatrix * vec4( aPosition*uSize, 1.0 );\n
- vColor = aColor;\n
-}\n
-);
-
-const char* FRAGMENT_COLOR_MESH = MAKE_SHADER(
-uniform lowp vec4 uColor;\n
-varying lowp vec3 vColor;\n
-\n
-void main()\n
-{\n
- gl_FragColor = vec4(vColor,1.0)*uColor;
-}\n
-);
-
-const char* VERTEX_TEXTURE_MESH = MAKE_SHADER(
-attribute mediump vec3 aPosition;\n
-attribute highp vec2 aTexCoord;\n
-uniform mediump mat4 uMvpMatrix;\n
-uniform mediump vec3 uSize;\n
-varying mediump vec2 vTexCoord;\n
-\n
-void main()\n
-{\n
- gl_Position = uMvpMatrix * vec4( aPosition*uSize, 1.0 );\n
- vTexCoord = aTexCoord;\n
-}\n
-);
-
-const char* FRAGMENT_TEXTURE_MESH = MAKE_SHADER(
-varying mediump vec2 vTexCoord;\n
-uniform lowp vec4 uColor;\n
-uniform sampler2D sTexture;\n
-\n
-void main()\n
-{\n
- gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;
-}\n
-);
-
-const char* FRAGMENT_BLEND_SHADER = MAKE_SHADER(
-varying mediump vec2 vTexCoord;\n
-uniform sampler2D sTexture;\n
-uniform sampler2D sEffect;\n
-uniform mediump float alpha;\n
-\n
-void main()\n
-{\n
- mediump vec4 fragColor = texture2D(sTexture, vTexCoord);\n
- mediump vec4 fxColor = texture2D(sEffect, vTexCoord);\n
- gl_FragColor = mix(fragColor,fxColor, alpha);\n
-}\n
-);
-
-}; // anonymous namespace
-
-
-class NewWindowController : public ConnectionTracker
-{
-public:
- NewWindowController( Application& app );
- void Create( Application& app );
- void Destroy( Application& app );
-
- void AddBubbles( Actor& parentActor, const Vector2& stageSize);
- void AddMeshActor( Actor& parentActor );
- void AddBlendingImageActor( Actor& parentActor );
- void AddTextLabel( Actor& parentActor );
-
- ImageView CreateBlurredMirrorImage(const char* imageName);
- FrameBufferImage CreateFrameBufferForImage( const char* imageName, Property::Map& shaderEffect, const Vector3& rgbDelta );
- void SetUpBubbleEmission( const Vector2& emitPosition, const Vector2& direction );
- Geometry CreateMeshGeometry();
- Dali::Property::Map CreateColorModifierer();
-
- static void NewWindow(void);
-
- bool OnTrackTimerTick();
- void OnKeyEvent(const KeyEvent& event);
- bool OnLoseContextButtonClicked( Toolkit::Button button );
- void OnContextLost();
- void OnContextRegained();
-
-private:
- Application mApplication;
- TextLabel mTextActor;
-
- Toolkit::Control mView; ///< The View instance.
- Toolkit::ToolBar mToolBar; ///< The View's Toolbar.
- TextLabel mTitleActor; ///< The Toolbar's Title.
- Layer mContentLayer; ///< Content layer (scrolling cluster content)
- Toolkit::PushButton mLoseContextButton;
-
- Toolkit::BubbleEmitter mEmitter;
- Timer mEmitTrackTimer;
- bool mNeedNewAnimation;
- unsigned int mAnimateComponentCount;
- Animation mEmitAnimation;
-};
-
-
-NewWindowController::NewWindowController( Application& application )
-: mApplication(application),
- mNeedNewAnimation(true),
- mAnimateComponentCount( 0 )
-{
- mApplication.InitSignal().Connect(this, &NewWindowController::Create);
- mApplication.TerminateSignal().Connect(this, &NewWindowController::Destroy);
-}
-
-void NewWindowController::Create( Application& app )
-{
- Stage stage = Stage::GetCurrent();
- stage.SetBackgroundColor(Color::YELLOW);
-
- stage.KeyEventSignal().Connect(this, &NewWindowController::OnKeyEvent);
-
- // The Init signal is received once (only) during the Application lifetime
-
- // Hide the indicator bar
- mApplication.GetWindow().ShowIndicator( Dali::Window::INVISIBLE );
-
- mContentLayer = DemoHelper::CreateView( app,
- mView,
- mToolBar,
- "",
- TOOLBAR_IMAGE,
- "Context recovery" );
-
- Size stageSize = stage.GetSize();
- ImageView backgroundActor = ImageView::New( BACKGROUND_IMAGE, Dali::ImageDimensions( stageSize.x, stageSize.y ) );
- backgroundActor.SetParentOrigin( ParentOrigin::CENTER );
- mContentLayer.Add(backgroundActor);
-
- // Point the default render task at the view
- RenderTaskList taskList = stage.GetRenderTaskList();
- RenderTask defaultTask = taskList.GetTask( 0u );
- if ( defaultTask )
- {
- defaultTask.SetSourceActor( mView );
- }
-
- mLoseContextButton = Toolkit::PushButton::New();
- mLoseContextButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, LOSE_CONTEXT_IMAGE );
- mLoseContextButton.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, LOSE_CONTEXT_IMAGE_SELECTED );
- mLoseContextButton.ClickedSignal().Connect( this, &NewWindowController::OnLoseContextButtonClicked );
- mToolBar.AddControl( mLoseContextButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalRight, DemoHelper::DEFAULT_MODE_SWITCH_PADDING );
-
- Actor logoLayoutActor = Actor::New();
- logoLayoutActor.SetParentOrigin(ParentOrigin::CENTER);
- logoLayoutActor.SetPosition(0.0f, -200.0f, 0.0f);
- logoLayoutActor.SetScale(0.5f);
- backgroundActor.Add(logoLayoutActor);
-
- ImageView imageView = ImageView::New( LOGO_IMAGE );
- imageView.SetName("daliLogo");
- imageView.SetParentOrigin(ParentOrigin::CENTER);
- imageView.SetAnchorPoint(AnchorPoint::BOTTOM_CENTER);
- logoLayoutActor.Add(imageView);
-
- ImageView mirrorImageView = CreateBlurredMirrorImage(LOGO_IMAGE);
- mirrorImageView.SetParentOrigin(ParentOrigin::TOP_CENTER);
- mirrorImageView.SetAnchorPoint(AnchorPoint::BOTTOM_CENTER);
- logoLayoutActor.Add(mirrorImageView);
-
- AddBubbles( backgroundActor, stage.GetSize());
- AddMeshActor( backgroundActor );
- AddBlendingImageActor( backgroundActor );
- AddTextLabel( backgroundActor );
-
- stage.ContextLostSignal().Connect(this, &NewWindowController::OnContextLost);
- stage.ContextRegainedSignal().Connect(this, &NewWindowController::OnContextRegained);
-}
-
-void NewWindowController::Destroy( Application& app )
-{
- UnparentAndReset(mTextActor);
-}
-
-void NewWindowController::AddBubbles( Actor& parentActor, const Vector2& stageSize)
-{
- mEmitter = Toolkit::BubbleEmitter::New( stageSize,
- DemoHelper::LoadTexture( DEMO_IMAGE_DIR "bubble-ball.png" ),
- 200, Vector2( 5.0f, 5.0f ) );
-
- Texture background = DemoHelper::LoadTexture(BACKGROUND_IMAGE);
- mEmitter.SetBackground( background, Vector3(0.5f, 0.f,0.5f) );
- mEmitter.SetBubbleDensity( 9.f );
- Actor bubbleRoot = mEmitter.GetRootActor();
- parentActor.Add( bubbleRoot );
- bubbleRoot.SetParentOrigin(ParentOrigin::CENTER);
- bubbleRoot.SetZ(0.1f);
-
- mEmitTrackTimer = Timer::New( EMIT_INTERVAL_IN_MS );
- mEmitTrackTimer.TickSignal().Connect(this, &NewWindowController::OnTrackTimerTick);
- mEmitTrackTimer.Start();
-}
-
-void NewWindowController::AddMeshActor( Actor& parentActor )
-{
- Geometry meshGeometry = CreateMeshGeometry();
-
- // Create a coloured mesh
- Shader shaderColorMesh = Shader::New( VERTEX_COLOR_MESH, FRAGMENT_COLOR_MESH );
- Renderer colorMeshRenderer = Renderer::New( meshGeometry, shaderColorMesh );
-
- Actor colorMeshActor = Actor::New();
- colorMeshActor.AddRenderer( colorMeshRenderer );
- colorMeshActor.SetSize( 175.f,175.f, 175.f );
- colorMeshActor.SetParentOrigin( ParentOrigin::CENTER );
- colorMeshActor.SetAnchorPoint(AnchorPoint::TOP_CENTER);
- colorMeshActor.SetPosition(Vector3(0.0f, 50.0f, 0.0f));
- colorMeshActor.SetOrientation( Degree(75.f), Vector3::XAXIS );
- colorMeshActor.SetName("ColorMeshActor");
-
- // Create a textured mesh
- Texture effectTexture = DemoHelper::LoadTexture(EFFECT_IMAGE);
- Shader shaderTextureMesh = Shader::New( VERTEX_TEXTURE_MESH, FRAGMENT_TEXTURE_MESH );
- TextureSet textureSet = TextureSet::New();
- textureSet.SetTexture( 0u, effectTexture );
- Renderer textureMeshRenderer = Renderer::New( meshGeometry, shaderTextureMesh );
- textureMeshRenderer.SetTextures( textureSet );
-
- Actor textureMeshActor = Actor::New();
- textureMeshActor.AddRenderer( textureMeshRenderer );
- textureMeshActor.SetSize( 175.f,175.f, 175.f );
- textureMeshActor.SetParentOrigin( ParentOrigin::CENTER );
- textureMeshActor.SetAnchorPoint(AnchorPoint::TOP_CENTER);
- textureMeshActor.SetPosition(Vector3(0.0f, 200.0f, 0.0f));
- textureMeshActor.SetOrientation( Degree(75.f), Vector3::XAXIS );
- textureMeshActor.SetName("TextureMeshActor");
-
- Layer layer3d = Layer::New();
- layer3d.SetParentOrigin( ParentOrigin::CENTER );
- layer3d.SetAnchorPoint( AnchorPoint::CENTER );
- layer3d.SetBehavior(Layer::LAYER_3D);
-
- layer3d.Add( colorMeshActor );
- layer3d.Add( textureMeshActor );
- parentActor.Add(layer3d);
-}
-
-void NewWindowController::AddBlendingImageActor( Actor& parentActor )
-{
- Property::Map colorModifier = CreateColorModifierer();
-
- FrameBufferImage fb2 = CreateFrameBufferForImage( EFFECT_IMAGE, colorModifier, Vector3( 0.5f, 0.5f, 0.5f ) );
-
- ImageView tmpActor = ImageView::New(fb2);
- parentActor.Add(tmpActor);
- tmpActor.SetParentOrigin(ParentOrigin::CENTER_RIGHT);
- tmpActor.SetAnchorPoint(AnchorPoint::TOP_RIGHT);
- tmpActor.SetPosition(Vector3(0.0f, 150.0f, 0.0f));
- tmpActor.SetScale(0.25f);
-
- // create blending shader effect
- Property::Map customShader;
- customShader[ "fragmentShader" ] = FRAGMENT_BLEND_SHADER;
- Property::Map map;
- map[ "shader" ] = customShader;
-
- ImageView blendActor = ImageView::New( BASE_IMAGE );
- blendActor.SetProperty( ImageView::Property::IMAGE, map );
- blendActor.RegisterProperty( "alpha", 0.5f );
-
- blendActor.SetParentOrigin(ParentOrigin::CENTER_RIGHT);
- blendActor.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT);
- blendActor.SetPosition(Vector3(0.0f, 100.0f, 0.0f));
- blendActor.SetSize(140, 140);
- parentActor.Add(blendActor);
-
- TextureSet textureSet = blendActor.GetRendererAt(0u).GetTextures();
- TextureSetImage( textureSet, 1u, fb2 );
-}
-
-void NewWindowController::AddTextLabel( Actor& parentActor )
-{
- mTextActor = TextLabel::New("Some text");
- mTextActor.SetParentOrigin(ParentOrigin::CENTER);
- mTextActor.SetColor(Color::RED);
- mTextActor.SetName("PushMe text");
- parentActor.Add( mTextActor );
-}
-
-ImageView NewWindowController::CreateBlurredMirrorImage(const char* imageName)
-{
- Image image = DemoHelper::LoadImage(imageName);
-
- Vector2 FBOSize = Vector2( image.GetWidth(), image.GetHeight() );
- FrameBufferImage fbo = FrameBufferImage::New( FBOSize.width, FBOSize.height, Pixel::RGBA8888);
-
- GaussianBlurView gbv = GaussianBlurView::New(5, 2.0f, Pixel::RGBA8888, 0.5f, 0.5f, true);
- gbv.SetBackgroundColor(Color::TRANSPARENT);
- gbv.SetUserImageAndOutputRenderTarget( image, fbo );
- gbv.SetSize(FBOSize);
- Stage::GetCurrent().Add(gbv);
- gbv.ActivateOnce();
-
- ImageView blurredActor = ImageView::New(fbo);
- blurredActor.SetSize(FBOSize);
- blurredActor.SetScale(1.0f, -1.0f, 1.0f);
- return blurredActor;
-}
-
-FrameBufferImage NewWindowController::CreateFrameBufferForImage(const char* imageName, Property::Map& shaderEffect, const Vector3& rgbDelta )
-{
- Stage stage = Stage::GetCurrent();
- Uint16Pair intFboSize = ResourceImage::GetImageSize( imageName );
- Vector2 FBOSize = Vector2(intFboSize.GetWidth(), intFboSize.GetHeight());
-
- FrameBufferImage framebuffer = FrameBufferImage::New(FBOSize.x, FBOSize.y );
-
- RenderTask renderTask = stage.GetRenderTaskList().CreateTask();
-
- ImageView imageView = ImageView::New( imageName );
- imageView.SetName("Source image actor");
- imageView.SetProperty( ImageView::Property::IMAGE, shaderEffect );
- imageView.RegisterProperty( "uRGBDelta", rgbDelta );
-
- imageView.SetParentOrigin(ParentOrigin::CENTER);
- imageView.SetAnchorPoint(AnchorPoint::CENTER);
- imageView.SetScale(1.0f, -1.0f, 1.0f);
- stage.Add(imageView); // Not in default image view
-
- CameraActor cameraActor = CameraActor::New(FBOSize);
- cameraActor.SetParentOrigin(ParentOrigin::CENTER);
- cameraActor.SetFieldOfView(Math::PI*0.25f);
- cameraActor.SetNearClippingPlane(1.0f);
- cameraActor.SetAspectRatio(FBOSize.width / FBOSize.height);
- cameraActor.SetType(Dali::Camera::FREE_LOOK); // camera orientation based solely on actor
- cameraActor.SetPosition(0.0f, 0.0f, ((FBOSize.height * 0.5f) / tanf(Math::PI * 0.125f)));
- stage.Add(cameraActor);
-
- renderTask.SetSourceActor(imageView);
- renderTask.SetInputEnabled(false);
- renderTask.SetTargetFrameBuffer(framebuffer);
- renderTask.SetCameraActor( cameraActor );
- renderTask.SetClearColor( Color::TRANSPARENT );
- renderTask.SetClearEnabled( true );
- renderTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
-
- return framebuffer;
-}
-
-void NewWindowController::SetUpBubbleEmission( const Vector2& emitPosition, const Vector2& direction)
-{
- if( mNeedNewAnimation )
- {
- float duration = Random::Range(1.f, 1.5f);
- mEmitAnimation = Animation::New( duration );
- mNeedNewAnimation = false;
- mAnimateComponentCount = 0;
- }
-
- mEmitter.EmitBubble( mEmitAnimation, emitPosition, direction, Vector2(10,10) );
-
- mAnimateComponentCount++;
-
- if( mAnimateComponentCount % 6 ==0 )
- {
- mEmitAnimation.Play();
- mNeedNewAnimation = true;
- }
-}
-
-Geometry NewWindowController::CreateMeshGeometry()
-{
- // Create vertices and specify their color
- struct Vertex
- {
- Vector3 position;
- Vector2 textureCoordinates;
- Vector3 color;
- };
-
- Vertex vertexData[5] = {
- { Vector3( 0.0f, 0.0f, 0.5f ), Vector2(0.5f, 0.5f), Vector3(1.0f, 1.0f, 1.0f) },
- { Vector3( -0.5f, -0.5f, 0.0f ), Vector2(0.0f, 0.0f), Vector3(1.0f, 0.0f, 0.0f) },
- { Vector3( 0.5f, -0.5f, 0.0f ), Vector2(1.0f, 0.0f), Vector3(1.0f, 1.0f, 0.0f) },
- { Vector3( -0.5f, 0.5f, 0.0f ), Vector2(0.0f, 1.0f), Vector3(0.0f, 1.0f, 0.0f) },
- { Vector3( 0.5f, 0.5f, 0.0f ), Vector2(1.0f, 1.0f), Vector3(0.0f, 0.0f, 1.0f) } };
-
- Property::Map vertexFormat;
- vertexFormat["aPosition"] = Property::VECTOR3;
- vertexFormat["aTexCoord"] = Property::VECTOR2;
- vertexFormat["aColor"] = Property::VECTOR3;
- PropertyBuffer vertices = PropertyBuffer::New( vertexFormat );
- vertices.SetData( vertexData, 5 );
-
- // Specify all the faces
- unsigned short indexData[12] = { 0,1,3,0,2,4,0,3,4,0,2,1 };
-
- // Create the geometry object
- Geometry geometry = Geometry::New();
- geometry.AddVertexBuffer( vertices );
- geometry.SetIndexBuffer( &indexData[0], 12 );
-
- return geometry;
-}
-
-Dali::Property::Map NewWindowController::CreateColorModifierer()
-{
- const char* fragmentShader ( DALI_COMPOSE_SHADER (
- precision highp float;\n
- uniform vec3 uRGBDelta;\n
- uniform float uIgnoreAlpha;\n
- \n
- varying mediump vec2 vTexCoord;\n
- uniform sampler2D sTexture;\n
- \n
- float rand(vec2 co) \n
- {\n
- return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); \n}
- \n
- void main() {\n
- vec4 color = texture2D(sTexture, vTexCoord); \n
- // modify the hsv Value
- color.rgb += uRGBDelta * rand(vTexCoord); \n
- // if the new vale exceeds one, then decrease it
- color.rgb -= max(color.rgb*2.0 - vec3(2.0), 0.0);\n
- // if the new vale drops below zero, then increase it
- color.rgb -= min(color.rgb*2.0, 0.0);\n
- gl_FragColor = color; \n
- }\n
- ) );
-
- Property::Map map;
- Property::Map customShader;
- customShader[ "fragmentShader" ] = fragmentShader;
- map[ "shader" ] = customShader;
-
- return map;
-}
-
-void NewWindowController::NewWindow(void)
-{
- PositionSize posSize(0, 0, 720, 1280);
- gApplication.ReplaceWindow(posSize, "NewWindow"); // Generates a new window
-}
-
-bool NewWindowController::OnLoseContextButtonClicked( Toolkit::Button button )
-{
- // Add as an idle callback to avoid ProcessEvents being recursively called.
- mApplication.AddIdle( MakeCallback( NewWindowController::NewWindow ) );
- return true;
-}
-
-bool NewWindowController::OnTrackTimerTick()
-{
- static int time=0;
- const float radius(250.0f);
-
- time += EMIT_INTERVAL_IN_MS;
- float modTime = time / TRACK_DURATION_IN_MS;
- float angle = 2.0f*Math::PI*modTime;
-
- Vector2 position(radius*cosf(angle), radius*-sinf(angle));
- Vector2 aimPos(radius*2*sinf(angle), radius*2*-cosf(angle));
- Vector2 direction = aimPos-position;
- Vector2 stageSize = Stage::GetCurrent().GetSize();
-
- SetUpBubbleEmission( stageSize*0.5f+position, direction );
- SetUpBubbleEmission( stageSize*0.5f+position*0.75f, direction );
- SetUpBubbleEmission( stageSize*0.5f+position*0.7f, direction );
-
- return true;
-}
-
-void NewWindowController::OnKeyEvent(const KeyEvent& event)
-{
- if(event.state == KeyEvent::Down)
- {
- if( IsKey( event, Dali::DALI_KEY_ESCAPE) || IsKey( event, Dali::DALI_KEY_BACK) )
- {
- mApplication.Quit();
- }
- }
-}
-
-void NewWindowController::OnContextLost()
-{
- printf("Stage reporting context loss\n");
-}
-
-void NewWindowController::OnContextRegained()
-{
- printf("Stage reporting context regain\n");
-}
-
-void RunTest(Application& app)
-{
- gNewWindowController = new NewWindowController(app);
- app.MainLoop(Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS);
-}
-
-// Entry point for Linux & Tizen applications
-//
-int DALI_EXPORT_API main(int argc, char **argv)
-{
- gApplication = Application::New(&argc, &argv, DEMO_THEME_PATH);
- RunTest(gApplication);
-
- return 0;
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <dali/dali.h>
-#include <dali-toolkit/dali-toolkit.h>
-#include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
-#include <dali-toolkit/devel-api/controls/page-turn-view/page-factory.h>
-#include <dali-toolkit/devel-api/controls/page-turn-view/page-turn-landscape-view.h>
-#include <dali-toolkit/devel-api/controls/page-turn-view/page-turn-portrait-view.h>
-#include <dali-toolkit/devel-api/controls/page-turn-view/page-turn-view.h>
-
-#include <assert.h>
-#include <cstdlib>
-#include <string.h>
-#include <iostream>
-
-#include "shared/view.h"
-#include "shared/utility.h"
-
-using namespace Dali;
-using namespace Dali::Toolkit;
-
-// LOCAL STUFF
-namespace
-{
-const char* const CHANGE_IMAGE_ICON(DEMO_IMAGE_DIR "icon-change.png");
-const char* const CHANGE_IMAGE_ICON_SELECTED( DEMO_IMAGE_DIR "icon-change-selected.png" );
-
-// The content amount of one page between portrait and landscape view are different
-// set a ratio to modify the current page number when the rotation is changed
-const float PAGE_NUMBER_CORRESPONDING_RATIO(1.25f);
-
-const char* BOOK_COVER_PORTRAIT( DEMO_IMAGE_DIR "book-portrait-cover.jpg" );
-const char* BOOK_COVER_LANDSCAPE( DEMO_IMAGE_DIR "book-landscape-cover.jpg" );
-const char* BOOK_COVER_BACK_LANDSCAPE( DEMO_IMAGE_DIR "book-landscape-cover-back.jpg" );
-
-const char* PAGE_IMAGES_PORTRAIT[] =
-{
- DEMO_IMAGE_DIR "book-portrait-p1.jpg",
- DEMO_IMAGE_DIR "book-portrait-p2.jpg",
- DEMO_IMAGE_DIR "book-portrait-p3.jpg",
- DEMO_IMAGE_DIR "book-portrait-p4.jpg",
- DEMO_IMAGE_DIR "book-portrait-p5.jpg"
-};
-const unsigned int NUMBER_OF_PORTRAIT_IMAGE( sizeof(PAGE_IMAGES_PORTRAIT) / sizeof(PAGE_IMAGES_PORTRAIT[0]) );
-
-const char* PAGE_IMAGES_LANDSCAPE[] =
-{
- DEMO_IMAGE_DIR "book-landscape-p1.jpg",
- DEMO_IMAGE_DIR "book-landscape-p2.jpg",
- DEMO_IMAGE_DIR "book-landscape-p3.jpg",
- DEMO_IMAGE_DIR "book-landscape-p4.jpg",
- DEMO_IMAGE_DIR "book-landscape-p5.jpg",
- DEMO_IMAGE_DIR "book-landscape-p6.jpg",
- DEMO_IMAGE_DIR "book-landscape-p7.jpg",
- DEMO_IMAGE_DIR "book-landscape-p8.jpg"
-};
-const unsigned int NUMBER_OF_LANDSCAPE_IMAGE( sizeof(PAGE_IMAGES_LANDSCAPE) / sizeof(PAGE_IMAGES_LANDSCAPE[0]) );
-
-Texture LoadTextures( const char* imagePath1, const char* imagePath2 )
-{
- PixelData pixelData1 = DemoHelper::LoadPixelData( imagePath1, ImageDimensions(), FittingMode::DEFAULT, SamplingMode::DEFAULT );
- PixelData pixelData2 = DemoHelper::LoadPixelData( imagePath2, ImageDimensions(), FittingMode::DEFAULT, SamplingMode::DEFAULT );
-
- unsigned int width = pixelData1.GetWidth() + pixelData2.GetWidth();
- unsigned int height = pixelData1.GetHeight() > pixelData2.GetHeight() ? pixelData1.GetHeight() : pixelData2.GetHeight();
-
- Texture texture = Texture::New( Dali::TextureType::TEXTURE_2D, Pixel::RGB888, width, height );
- texture.Upload( pixelData1 );
- texture.Upload( pixelData2, 0u, 0u, pixelData1.GetWidth(), 0u, pixelData2.GetWidth(), pixelData2.GetHeight() );
-
- return texture;
-}
-
-}// end LOCAL STUFF
-
-class PortraitPageFactory : public PageFactory
-{
- /**
- * Query the number of pages available from the factory.
- * The maximum available page has an ID of GetNumberOfPages()-1.
- */
- virtual unsigned int GetNumberOfPages()
- {
- return 10*NUMBER_OF_PORTRAIT_IMAGE + 1;
- }
- /**
- * Create an texture to represent a page.
- * @param[in] pageId The ID of the page to create.
- * @return A texture, or an uninitialized handle if the ID is out of range.
- */
- virtual Texture NewPage( unsigned int pageId )
- {
- Texture page;
-
- if( pageId == 0 )
- {
- page = DemoHelper::LoadTexture( BOOK_COVER_PORTRAIT );
- }
- else
- {
- page = DemoHelper::LoadTexture( PAGE_IMAGES_PORTRAIT[ (pageId-1) % NUMBER_OF_PORTRAIT_IMAGE ] );
- }
-
- return page;
- }
-};
-
-class LandscapePageFactory : public PageFactory
-{
-
- /**
- * Query the number of pages available from the factory.
- * The maximum available page has an ID of GetNumberOfPages()-1.
- */
- virtual unsigned int GetNumberOfPages()
- {
- return 10*NUMBER_OF_LANDSCAPE_IMAGE / 2 + 1;
- }
- /**
- * Create an texture to represent a page.
- * @param[in] pageId The ID of the page to create.
- * @return A texture, or an uninitialized handle if the ID is out of range.
- */
- virtual Texture NewPage( unsigned int pageId )
- {
- Texture page;
- if( pageId == 0 )
- {
- page = LoadTextures( BOOK_COVER_LANDSCAPE, BOOK_COVER_BACK_LANDSCAPE );
- }
- else
- {
- unsigned int imageId = (pageId-1)*2;
- page = LoadTextures( PAGE_IMAGES_LANDSCAPE[ imageId % NUMBER_OF_LANDSCAPE_IMAGE ], PAGE_IMAGES_LANDSCAPE[ (imageId+1) % NUMBER_OF_LANDSCAPE_IMAGE ] );
- }
-
- return page;
- }
-};
-
-/**
- * This example shows how to use the page turn UI control to implement the page-turn demo
- * The effect follows the pan gesture to animate the page
- * Pan the page inwards, the page will bent,
- * Depends on the distance of the panning, the page might turn over or slide back
- * Also, in portrait view, the pan gesture outwards from position near the spine could turn the previous page back
- * Allows to turn multiple pages one by one quickly towards the same direction, multiple animations are launched in this case
-*/
-class PageTurnController : public ConnectionTracker
-{
-public:
- PageTurnController( Application &app );
- ~PageTurnController();
-
- //This method gets called once the main loop of application is up and running
- void OnInit( Application& app );
-
-private:
-
- /**
- * This method gets called when the button is clicked, switch between portrait and landscape views
- */
- bool OnButtonClicked(Toolkit::Button button);
-
- /**
- * Main key event handler
- */
- void OnKeyEvent(const KeyEvent& event);
-
- /**
- * Callback function of page turned signal
- * @param[in] pageTurnView The handle of the PageTurnPortraitView or PageTurnLandscapeView
- * @param[in] pageIndex The index of the page turned over
- * @param[in] isTurningForward The turning direction, forwards or backwards
- */
- void OnPageStartedTurn( PageTurnView pageTurnView, unsigned int pageIndex, bool isTurningForward );
-
- /**
- * Callback function of page turned signal
- * @param[in] pageTurnView The handle of the PageTurnPortraitView or PageTurnLandscapeView
- * @param[in] pageIndex The index of the page turned over
- * @param[in] isTurningForward The turning direction, forwards or backwards
- */
- void OnPageFinishedTurn( PageTurnView pageTurnView, unsigned int pageIndex, bool isTurningForward );
-
- /**
- * Callback function of page started pan signal
- *
- * @param[in] pageTurnView The calling page turn view
- */
- void OnPageStartedPan( PageTurnView pageTurnView );
-
- /**
- * Callback function of page finished pan signal
- *
- * @param[in] pageTurnView The calling page turn view
- */
- void OnPageFinishedPan( PageTurnView pageTurnView );
-
-private:
-
- Application& mApplication;
- Layer mButtonLayer;
-
- PageTurnView mPageTurnPortraitView;
- PageTurnView mPageTurnLandscapeView;
- PortraitPageFactory mPortraitPageFactory;
- LandscapePageFactory mLandscapePageFactory;
-
- bool mIsPortrait;
-};
-
-PageTurnController::PageTurnController( Application &app )
-:mApplication( app ),
- mIsPortrait( true )
-{
- // Connect to the Application's Init signal
- app.InitSignal().Connect( this, &PageTurnController::OnInit );
-}
-
-PageTurnController::~PageTurnController()
-{
-}
-
-
-void PageTurnController::OnInit( Application& app )
-{
- // The Init signal is received once ( only ) during the Application lifetime
-
- Stage::GetCurrent().KeyEventSignal().Connect(this, &PageTurnController::OnKeyEvent);
-
- // Hide the indicator bar
- app.GetWindow().ShowIndicator( Dali::Window::INVISIBLE );
-
- Stage stage = Stage::GetCurrent();
- Vector2 stageSize = stage.GetSize();
-
- mButtonLayer = Layer::New();
- mButtonLayer.SetAnchorPoint( Dali::AnchorPoint::CENTER );
- mButtonLayer.SetParentOrigin( Dali::ParentOrigin::CENTER );
- mButtonLayer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
- Toolkit::PushButton button = Toolkit::PushButton::New();
- button.SetAnchorPoint( AnchorPoint::TOP_RIGHT );
- button.SetParentOrigin( ParentOrigin::TOP_RIGHT );
- button.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, CHANGE_IMAGE_ICON );
- button.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, CHANGE_IMAGE_ICON_SELECTED );
- button.SetLeaveRequired( true );
- button.SetScale(1.5f);
- button.PressedSignal().Connect( this, &PageTurnController::OnButtonClicked );
- stage.Add( mButtonLayer );
- mButtonLayer.Add(button);
-
- Vector2 bookSize( stageSize.x > stageSize.y ? stageSize.y : stageSize.x,
- stageSize.x > stageSize.y ? stageSize.x : stageSize.y );
-
- mPageTurnPortraitView = PageTurnPortraitView::New( mPortraitPageFactory, bookSize );
- mPageTurnPortraitView.SetParentOrigin( ParentOrigin::CENTER );
- mPageTurnPortraitView.SetAnchorPoint( AnchorPoint::CENTER );
- mPageTurnPortraitView.SetProperty( PageTurnView::Property::SPINE_SHADOW, Vector2(70.f, 30.f) );
- mPageTurnPortraitView.PageTurnStartedSignal().Connect( this, &PageTurnController::OnPageStartedTurn );
- mPageTurnPortraitView.PageTurnFinishedSignal().Connect( this, &PageTurnController::OnPageFinishedTurn );
- mPageTurnPortraitView.PagePanStartedSignal().Connect( this, &PageTurnController::OnPageStartedPan );
- mPageTurnPortraitView.PagePanFinishedSignal().Connect( this, &PageTurnController::OnPageFinishedPan );
-
- mPageTurnLandscapeView = PageTurnLandscapeView::New( mLandscapePageFactory, Vector2(bookSize.y*0.5f, bookSize.x) );
- mPageTurnLandscapeView.SetParentOrigin( ParentOrigin::CENTER );
- mPageTurnLandscapeView.SetAnchorPoint( AnchorPoint::CENTER );
- mPageTurnLandscapeView.PageTurnStartedSignal().Connect( this, &PageTurnController::OnPageStartedTurn );
- mPageTurnLandscapeView.PageTurnFinishedSignal().Connect( this, &PageTurnController::OnPageFinishedTurn );
- mPageTurnLandscapeView.PagePanStartedSignal().Connect( this, &PageTurnController::OnPageStartedPan );
- mPageTurnLandscapeView.PagePanFinishedSignal().Connect( this, &PageTurnController::OnPageFinishedPan );
-
- if( stageSize.x > stageSize.y )
- {
- stage.Add(mPageTurnLandscapeView);
- mPageTurnPortraitView.SetOrientation(Degree(90.f), Vector3::ZAXIS);
- mIsPortrait = false;
- }
- else
- {
- stage.Add(mPageTurnPortraitView);
- mPageTurnLandscapeView.SetOrientation(Degree(90.f), Vector3::ZAXIS);
- mIsPortrait = true;
- }
-
- mButtonLayer.RaiseToTop();
-}
-
-bool PageTurnController::OnButtonClicked(Toolkit::Button button)
-{
- if( mIsPortrait )
- {
- mPageTurnPortraitView.Unparent();
- Stage::GetCurrent().Add( mPageTurnLandscapeView );
- int pageId = mPageTurnPortraitView.GetProperty( PageTurnView::Property::CURRENT_PAGE_ID ).Get<int>();
- int currentPage = ceil( static_cast<float>(pageId) / PAGE_NUMBER_CORRESPONDING_RATIO );
- mPageTurnLandscapeView.SetProperty(PageTurnView::Property::CURRENT_PAGE_ID, currentPage );
- }
- else
- {
- mPageTurnLandscapeView.Unparent();
- Stage::GetCurrent().Add( mPageTurnPortraitView );
- int pageId = mPageTurnLandscapeView.GetProperty( PageTurnView::Property::CURRENT_PAGE_ID ).Get<int>();
- int currentPage = floor(pageId * PAGE_NUMBER_CORRESPONDING_RATIO );
- mPageTurnPortraitView.SetProperty(PageTurnView::Property::CURRENT_PAGE_ID, currentPage );
- }
-
- mIsPortrait = !mIsPortrait;
- mButtonLayer.RaiseToTop();
- return true;
-}
-
-/**
- * Main key event handler
- */
-void PageTurnController::OnKeyEvent(const KeyEvent& event)
-{
- if(event.state == KeyEvent::Down)
- {
- if( IsKey( event, Dali::DALI_KEY_ESCAPE) || IsKey( event, Dali::DALI_KEY_BACK) )
- {
- mApplication.Quit();
- }
- }
-}
-
-void PageTurnController::OnPageStartedTurn( PageTurnView pageTurnView, unsigned int pageIndex, bool isTurningForward )
-{
- std::cout<< ( ( pageTurnView == mPageTurnPortraitView ) ? " portrait: " : " Landscape: " )
- << " page " << pageIndex
- << ( isTurningForward ? " is starting to turn forward" : " is starting to turn backward" )
- << std::endl;
-}
-
-void PageTurnController::OnPageFinishedTurn( PageTurnView pageTurnView, unsigned int pageIndex, bool isTurningForward )
-{
- std::cout<< ( ( pageTurnView == mPageTurnPortraitView ) ? " portrait: " : " Landscape: " )
- << " page " << pageIndex
- << ( isTurningForward ? " has finished turning forward" : " has finished turning backward" )
- << std::endl;
-}
-
-void PageTurnController::OnPageStartedPan( PageTurnView pageTurnView )
-{
- std::cout<< "Starting to pan" << std::endl;
-}
-
-void PageTurnController::OnPageFinishedPan( PageTurnView pageTurnView )
-{
- std::cout<< "Finished panning" << std::endl;
-}
-
-// Entry point for applications
-int DALI_EXPORT_API main( int argc, char **argv )
-{
- Application app = Application::New(&argc, &argv, DEMO_THEME_PATH);
- PageTurnController test ( app );
-
- app.MainLoop();
-
- return 0;
-}
{
// Connect to the Application's Init signal
mProgressValue = 0.0f;
+ mSecondaryProgressValue = 0.1f;
+ isDefaultTheme = true;
mApplication.InitSignal().Connect( this, &ProgressBarExample::Create );
}
mProgressBarDefault.SetAnchorPoint(AnchorPoint::TOP_CENTER);
mProgressBarDefault.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH);
mProgressBarDefault.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT);
-
- mProgressBarCustomStyle1 = ProgressBar::New();
- mProgressBarCustomStyle1.SetStyleName( "ProgressBarCustomStyle1" );
- mProgressBarCustomStyle1.SetParentOrigin(ParentOrigin::TOP_CENTER);
- mProgressBarCustomStyle1.SetAnchorPoint(AnchorPoint::TOP_CENTER);
- mProgressBarCustomStyle1.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH);
- mProgressBarCustomStyle1.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT);
-
- mProgressBarCustomStyle2 = ProgressBar::New();
- mProgressBarCustomStyle2.SetStyleName( "ProgressBarCustomStyle2" );
- mProgressBarCustomStyle2.SetParentOrigin(ParentOrigin::TOP_CENTER);
- mProgressBarCustomStyle2.SetAnchorPoint(AnchorPoint::TOP_CENTER);
- mProgressBarCustomStyle2.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH);
- mProgressBarCustomStyle2.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT);
+ mProgressBarDefault.ValueChangedSignal().Connect( this, &ProgressBarExample::OnValueChanged );
Toolkit::TableView contentTable = Toolkit::TableView::New(2, 1);
contentTable.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH);
mContentLayer.Add( contentTable );
// Image selector for progress bar
- Toolkit::TableView progressBackground = Toolkit::TableView::New( 3, 1 );
+ Toolkit::TableView progressBackground = Toolkit::TableView::New( 1, 1 );
progressBackground.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
progressBackground.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT );
progressBackground.SetBackgroundColor( BACKGROUND_COLOUR );
contentTable.Add( progressBackground );
progressBackground.Add( mProgressBarDefault );
- progressBackground.Add( mProgressBarCustomStyle1 );
- progressBackground.Add( mProgressBarCustomStyle2 );
// Create buttons
- Toolkit::TableView buttonBackground = Toolkit::TableView::New( 1, 1 );
+ Toolkit::TableView buttonBackground = Toolkit::TableView::New( 3, 1 );
buttonBackground.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
buttonBackground.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT );
buttonBackground.SetBackgroundColor( BACKGROUND_COLOUR );
buttonBackground.Add( mResetProgressButton );
+ mSetIndeterminateButton = Toolkit::PushButton::New();
+ mSetIndeterminateButton.SetProperty( Toolkit::Button::Property::LABEL, "Toggle Indeterminate" );
+ mSetIndeterminateButton.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
+ mSetIndeterminateButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT );
+ mSetIndeterminateButton.ClickedSignal().Connect( this, &ProgressBarExample::OnSetIndeterminateButtonSelected );
+
+ buttonBackground.Add( mSetIndeterminateButton );
+
+ mChangeThemeButton = Toolkit::PushButton::New();
+ mChangeThemeButton.SetProperty( Toolkit::Button::Property::LABEL, "Change Theme" );
+ mChangeThemeButton.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
+ mChangeThemeButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT );
+ mChangeThemeButton.ClickedSignal().Connect( this, &ProgressBarExample::OnChangeThemeButtonSelected );
+
+ buttonBackground.Add( mChangeThemeButton );
+
// Create a timer to update the progress of all progress bars
mTimer = Timer::New( TIMER_TIMEOUT_TIME );
mTimer.TickSignal().Connect( this, &ProgressBarExample::OnTimerTick );
bool OnTimerTick()
{
mProgressValue += PROGRESS_INCREMENT_VALUE;
+ mSecondaryProgressValue = mProgressValue + 0.1f;
mProgressBarDefault.SetProperty(ProgressBar::Property::PROGRESS_VALUE, mProgressValue);
- mProgressBarCustomStyle1.SetProperty(ProgressBar::Property::PROGRESS_VALUE, mProgressValue);
- mProgressBarCustomStyle2.SetProperty(ProgressBar::Property::PROGRESS_VALUE, mProgressValue);
+ mProgressBarDefault.SetProperty(ProgressBar::Property::SECONDARY_PROGRESS_VALUE, mSecondaryProgressValue);
return ( mProgressValue < 1.0f ); // Only call again if progress has NOT got to the end
}
bool OnResetProgressButtonSelected( Toolkit::Button button )
{
mProgressValue = 0.0f;
+ mSecondaryProgressValue = 0.1f;
mProgressBarDefault.SetProperty(ProgressBar::Property::PROGRESS_VALUE, 0.0f);
- mProgressBarCustomStyle1.SetProperty(ProgressBar::Property::PROGRESS_VALUE, 0.0f);
- mProgressBarCustomStyle2.SetProperty(ProgressBar::Property::PROGRESS_VALUE, 0.0f);
+ mProgressBarDefault.SetProperty(ProgressBar::Property::SECONDARY_PROGRESS_VALUE, 0.1f);
mTimer.Start();
return true;
}
+ void OnValueChanged( ProgressBar progressBar, float value, float secondaryValue )
+ {
+ std::stringstream newLabel;
+ newLabel.precision( 2 );
+ newLabel << std::fixed << "current : " << value << " / loaded : " << secondaryValue;
+
+ mProgressBarDefault.SetProperty(ProgressBar::Property::LABEL_VISUAL, newLabel.str() );
+ }
+
+ bool OnSetIndeterminateButtonSelected( Toolkit::Button button )
+ {
+ if( mProgressBarDefault.GetProperty<bool>(ProgressBar::Property::INDETERMINATE))
+ {
+ mProgressBarDefault.SetProperty(ProgressBar::Property::INDETERMINATE, false);
+ }
+ else
+ {
+ mProgressBarDefault.SetProperty(ProgressBar::Property::INDETERMINATE, true);
+ }
+ return true;
+ }
+
+ bool OnChangeThemeButtonSelected( Toolkit::Button button )
+ {
+ StyleManager styleManager = StyleManager::Get();
+
+ if( isDefaultTheme )
+ {
+ styleManager.ApplyTheme( THEME_PATH );
+ isDefaultTheme = false;
+ }
+ else
+ {
+ styleManager.ApplyDefaultTheme();
+ isDefaultTheme = true;
+ }
+ return true;
+ }
void OnKeyEvent( const KeyEvent& event )
{
if( event.state == KeyEvent::Down )
Toolkit::ToolBar mToolBar; ///< The View's Toolbar.
Layer mContentLayer; ///< Content layer.
ProgressBar mProgressBarDefault;
- ProgressBar mProgressBarCustomStyle1;
- ProgressBar mProgressBarCustomStyle2;
Toolkit::PushButton mResetProgressButton;
+ Toolkit::PushButton mSetIndeterminateButton;
+ Toolkit::PushButton mChangeThemeButton;
float mProgressValue;
+ float mSecondaryProgressValue;
+ bool isDefaultTheme;
};
int DALI_EXPORT_API main( int argc, char **argv )
{
- Application application = Application::New( &argc, &argv, THEME_PATH );
+ Application application = Application::New( &argc, &argv );
ProgressBarExample test( application );
application.MainLoop();
return 0;
varying mediump vec2 vTexCoord;\n
uniform sampler2D sTexture;\n
uniform mediump vec4 uColor;\n
- uniform mediump vec4 mixColor;\n
+ uniform mediump vec3 mixColor;\n
+ uniform mediump float opacity;\n
uniform mediump vec3 uChannels;\n
\n
void main()\n
{\n
- gl_FragColor = texture2D( sTexture, vTexCoord ) * mixColor * uColor * vec4(uChannels, 1.0) ;\n
+ gl_FragColor = texture2D( sTexture, vTexCoord ) * vec4(mixColor,opacity) * uColor * vec4(uChannels, 1.0) ;\n
}\n
);
for( int i=0; i<3; ++i )
{
std::ostringstream thumbnailName; thumbnailName << "thumbnail" << i+1;
- ImageView image = ImageView::New( ResourceImage::New( images[i] ) );
+ ImageView image = ImageView::New( images[i] );
image.SetName( thumbnailName.str() );
image.SetSize( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) );
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-#include <dali/dali.h>
-#include <dali-toolkit/dali-toolkit.h>
-#include <dali-toolkit/devel-api/controls/bloom-view/bloom-view.h>
-#include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
-#include <dali-toolkit/devel-api/controls/super-blur-view/super-blur-view.h>
-#include "shared/view.h"
-#include "shared/utility.h"
-
-using namespace Dali;
-
-namespace
-{
-const char * const TOOLBAR_IMAGE( DEMO_IMAGE_DIR "top-bar.png" );
-const char * const TITLE_SUPER_BLUR( "Super Blur" );
-const char * const TITLE_BLOOM( "Bloom" );
-const char * const CHANGE_BACKGROUND_ICON( DEMO_IMAGE_DIR "icon-change.png" );
-const char * const CHANGE_BACKGROUND_ICON_SELECTED( DEMO_IMAGE_DIR "icon-change-selected.png" );
-const char * const CHANGE_BLUR_ICON( DEMO_IMAGE_DIR "icon-replace.png" );
-const char * const CHANGE_BLUR_ICON_SELECTED( DEMO_IMAGE_DIR "icon-replace-selected.png" );
-
-const char* BACKGROUND_IMAGES[]=
-{
- DEMO_IMAGE_DIR "background-1.jpg",
- DEMO_IMAGE_DIR "background-2.jpg",
- DEMO_IMAGE_DIR "background-3.jpg",
- DEMO_IMAGE_DIR "background-4.jpg",
- DEMO_IMAGE_DIR "background-5.jpg",
- DEMO_IMAGE_DIR "background-magnifier.jpg",
-};
-const unsigned int NUM_BACKGROUND_IMAGES( sizeof( BACKGROUND_IMAGES ) / sizeof( BACKGROUND_IMAGES[0] ) );
-
-}
-
-class BlurExample : public ConnectionTracker
-{
-public:
- BlurExample(Application &app)
- : mApp(app),
- mImageIndex( 0 ),
- mIsBlurring( false )
- {
- // Connect to the Application's Init signal
- app.InitSignal().Connect(this, &BlurExample::Create);
- }
-
- ~BlurExample()
- {
- }
-private:
- // The Init signal is received once (only) during the Application lifetime
- void Create(Application& app)
- {
- Stage stage = Stage::GetCurrent();
- Vector2 stageSize = stage.GetSize();
-
- stage.KeyEventSignal().Connect(this, &BlurExample::OnKeyEvent);
-
- // Creates a default view with a default tool bar.
- // The view is added to the stage.
- Layer content = DemoHelper::CreateView( app,
- mBackground,
- mToolBar,
- "",
- TOOLBAR_IMAGE,
- "" );
-
- // Add a button to change background. (right of toolbar)
- Toolkit::PushButton changeBackgroundButton = Toolkit::PushButton::New();
- changeBackgroundButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, CHANGE_BACKGROUND_ICON );
- changeBackgroundButton.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, CHANGE_BACKGROUND_ICON_SELECTED );
-
- changeBackgroundButton.ClickedSignal().Connect( this, &BlurExample::OnChangeBackgroundIconClicked );
- mToolBar.AddControl( changeBackgroundButton,
- DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage,
- Toolkit::Alignment::HorizontalRight,
- DemoHelper::DEFAULT_MODE_SWITCH_PADDING );
-
- // Add a button to change the blur view. (left of toolbar)
- Toolkit::PushButton changeBlurButton = Toolkit::PushButton::New();
- changeBlurButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, CHANGE_BLUR_ICON );
- changeBlurButton.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, CHANGE_BLUR_ICON_SELECTED );
-
- changeBlurButton.ClickedSignal().Connect( this, &BlurExample::OnChangeBlurIconClicked );
- mToolBar.AddControl( changeBlurButton,
- DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage,
- Toolkit::Alignment::HorizontalLeft,
- DemoHelper::DEFAULT_MODE_SWITCH_PADDING );
-
- mSuperBlurView = Toolkit::SuperBlurView::New( 5 );
- mSuperBlurView.SetSize( stageSize );
- mSuperBlurView.SetParentOrigin( ParentOrigin::CENTER );
- mSuperBlurView.SetAnchorPoint( AnchorPoint::CENTER );
- mSuperBlurView.BlurFinishedSignal().Connect(this, &BlurExample::OnBlurFinished);
- mCurrentImage = DemoHelper::LoadStageFillingImage( BACKGROUND_IMAGES[mImageIndex] );
- mSuperBlurView.SetImage( mCurrentImage );
- mBackground.Add( mSuperBlurView );
- mIsBlurring = true;
- SetTitle( TITLE_SUPER_BLUR );
-
- mBloomView = Toolkit::BloomView::New();
- mBloomView.SetParentOrigin(ParentOrigin::CENTER);
- mBloomView.SetSize(stageSize);
- mBloomActor = Toolkit::ImageView::New(mCurrentImage);
- mBloomActor.SetParentOrigin( ParentOrigin::CENTER );
- mBloomView.Add( mBloomActor );
-
- // Connect the callback to the touch signal on the background
- mSuperBlurView.TouchSignal().Connect( this, &BlurExample::OnTouch );
- mBloomView.TouchSignal().Connect( this, &BlurExample::OnTouch );
- }
-
- // Callback function of the touch signal on the background
- bool OnTouch(Dali::Actor actor, const Dali::TouchData& event)
- {
- switch( event.GetState( 0 ) )
- {
- case PointState::DOWN:
- {
- if( mAnimation )
- {
- mAnimation.Clear();
- }
-
- mAnimation = Animation::New( 2.f );
- if( mSuperBlurView.OnStage() )
- {
- mAnimation.AnimateTo( Property( mSuperBlurView, mSuperBlurView.GetBlurStrengthPropertyIndex() ), 1.f );
- }
- else
- {
- mAnimation.AnimateTo( Property( mBloomView, mBloomView.GetBloomIntensityPropertyIndex() ), 3.f );
- }
- mAnimation.Play();
- break;
- }
- case PointState::UP:
- case PointState::LEAVE:
- case PointState::INTERRUPTED:
- {
- if( mAnimation )
- {
- mAnimation.Clear();
- }
-
- mAnimation = Animation::New( 2.f );
- if( mSuperBlurView.OnStage() )
- {
- mAnimation.AnimateTo( Property( mSuperBlurView, mSuperBlurView.GetBlurStrengthPropertyIndex() ), 0.f );
- }
- else
- {
- mAnimation.AnimateTo( Property( mBloomView, mBloomView.GetBloomIntensityPropertyIndex() ), 0.f );
- }
- mAnimation.Play();
- break;
- }
- case PointState::MOTION:
- case PointState::STATIONARY:
- {
- break;
- }
- }
- return true;
- }
-
- /**
- * Main key event handler
- */
- void OnKeyEvent(const KeyEvent& event)
- {
- if(event.state == KeyEvent::Down)
- {
- if( IsKey( event, Dali::DALI_KEY_ESCAPE) || IsKey( event, Dali::DALI_KEY_BACK) )
- {
- mApp.Quit();
- }
- }
- }
-
- bool OnChangeBackgroundIconClicked( Toolkit::Button button )
- {
- if( mIsBlurring )
- {
- return true;
- }
-
- if( mAnimation )
- {
- mAnimation.Clear();
- }
-
- mImageIndex = (mImageIndex+1u)%NUM_BACKGROUND_IMAGES;
- mCurrentImage = DemoHelper::LoadStageFillingImage( BACKGROUND_IMAGES[mImageIndex] );
-
- if( mSuperBlurView.OnStage() )
- {
- mIsBlurring = true;
-
- mSuperBlurView.SetBlurStrength( 0.f );
- mSuperBlurView.SetImage( mCurrentImage );
- }
- else
- {
- mBloomView.SetProperty( mBloomView.GetBloomIntensityPropertyIndex(), 0.f );
- mBloomActor.SetImage( mCurrentImage );
- }
-
- return true;
- }
-
- bool OnChangeBlurIconClicked( Toolkit::Button button )
- {
- if( mSuperBlurView.OnStage() )
- {
- SetTitle( TITLE_BLOOM );
- mBackground.Remove( mSuperBlurView );
-
- mBloomActor.SetImage( mCurrentImage );
- mBloomView.SetProperty( mBloomView.GetBloomIntensityPropertyIndex(), 0.f );
- mBackground.Add( mBloomView );
- mBloomView.Activate();
-
- }
- else
- {
- SetTitle( TITLE_SUPER_BLUR );
- mBackground.Remove( mBloomView );
- mBloomView.Deactivate();
-
- mBackground.Add( mSuperBlurView );
- mSuperBlurView.SetBlurStrength( 0.f );
- mSuperBlurView.SetImage( mCurrentImage );
- mIsBlurring = true;
- }
-
- return true;
- }
-
- void OnBlurFinished( Toolkit::SuperBlurView blurView )
- {
- mIsBlurring = false;
- }
-
- /**
- * Sets/Updates the title of the View
- * @param[in] title The new title for the view.
- */
- void SetTitle(const std::string& title)
- {
- if(!mTitleActor)
- {
- mTitleActor = DemoHelper::CreateToolBarLabel( title );
- // Add title to the tool bar.
- mToolBar.AddControl( mTitleActor, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarTitlePercentage, Toolkit::Alignment::HorizontalCenter );
- }
-
- mTitleActor.SetProperty( Toolkit::TextLabel::Property::TEXT, title );
- }
-
-private:
-
- Application& mApp;
- Toolkit::ToolBar mToolBar;
- Toolkit::TextLabel mTitleActor; ///< The Toolbar's Title.
- Toolkit::Control mBackground;
- Toolkit::SuperBlurView mSuperBlurView;
- Toolkit::BloomView mBloomView;
- Animation mAnimation;
- Toolkit::ImageView mBloomActor;
- Image mCurrentImage;
- unsigned int mImageIndex;
- bool mIsBlurring;
-};
-
-/*****************************************************************************/
-
-static void
-RunTest(Application& app)
-{
- BlurExample theApp(app);
- app.MainLoop();
-}
-
-/*****************************************************************************/
-
-int DALI_EXPORT_API main(int argc, char **argv)
-{
- Application app = Application::New(&argc, &argv, DEMO_THEME_PATH);
-
- RunTest(app);
-
- return 0;
-}
{
}
- void operator()(Vector4& current, const PropertyInputContainer& inputs )
+ void operator()(Vector3& current, const PropertyInputContainer& inputs )
{
- current = hsv2rgb(Vector4(inputs[0]->GetFloat(), saturation, value, current.a));
+ current = hsv2rgb(Vector3(inputs[0]->GetFloat(), saturation, value));
}
- Vector4 hsv2rgb(Vector4 colorHSV)
+ Vector3 hsv2rgb(Vector3 colorHSV)
{
float r=colorHSV.z*(1+colorHSV.y*(cos(colorHSV.x)-1));
float g=colorHSV.z*(1+colorHSV.y*(cos(colorHSV.x-2.09439)-1));
float b=colorHSV.z*(1+colorHSV.y*(cos(colorHSV.x+2.09439)-1));
- return Vector4(r, g, b, colorHSV.a);
+ return Vector3(r, g, b);
}
float hue;
float saturation;
Renderer bgRenderer = mLabel.GetRendererAt(0);
mOverrideMixColorIndex = DevelHandle::GetPropertyIndex( bgRenderer, ColorVisual::Property::MIX_COLOR );
- Constraint constraint = Constraint::New<Vector4>( bgRenderer, mOverrideMixColorIndex, HSVColorConstraint(0.0f, 0.5f, 0.8f));
+ Constraint constraint = Constraint::New<Vector3>( bgRenderer, mOverrideMixColorIndex, HSVColorConstraint(0.0f, 0.5f, 0.8f));
constraint.AddSource( Source( mLabel, mHueAngleIndex ) );
constraint.SetRemoveAction( Constraint::Discard );
constraint.Apply();
// External includes
#include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/controls/control-devel.h>
#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/devel-api/visuals/text-visual-properties.h>
#include "shadow-button.h"
mTitle(),
mShadowButton(),
mActionButtons(),
+ mVisualIndex( Property::INVALID_INDEX ),
mActionIndex( Property::INVALID_INDEX )
{
application.InitSignal().Connect( this, &TransitionApplication::Create );
mShadowButton.SetAnchorPoint( AnchorPoint::CENTER );
mShadowButton.SetParentOrigin( ParentOrigin::CENTER );
mShadowButton.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+ mShadowButton.SetProperty( DevelControl::Property::STATE, DevelControl::DISABLED );
+ mShadowButton.SetProperty( DevelControl::Property::SUB_STATE, "UNCHECKED" );
+
buttonLayout.AddChild( mShadowButton, TableView::CellPosition(1, 1) );
TableView actionButtonLayout = TableView::New( 1, NUMBER_OF_ACTION_BUTTONS+1 );
mActionButtons[i].ClickedSignal().Connect( this, &TransitionApplication::OnActionButtonClicked );
actionButtonLayout.AddChild( mActionButtons[i], TableView::CellPosition( 0, 1+i ) );
}
- SetLabelText( mActionButtons[0], "Activate" );
+ SetLabelText( mActionButtons[0], "Enable" );
SetLabelText( mActionButtons[1], "Check" );
mActionButtons[1].SetProperty( Button::Property::DISABLED, true );
mShadowButton.SetActiveState( ! activeState );
if( activeState )
{
- SetLabelText( button, "Activate" );
+ SetLabelText( button, "Enable" );
+ mShadowButton.SetProperty( DevelControl::Property::STATE, DevelControl::DISABLED );
}
else
{
- SetLabelText( button, "Deactivate" );
+ SetLabelText( button, "Disable" );
+ mShadowButton.SetProperty( DevelControl::Property::STATE, DevelControl::NORMAL );
}
mActionButtons[1].SetProperty( Button::Property::DISABLED, activeState );
break;
if( checkState )
{
SetLabelText( button, "Check" );
+ mShadowButton.SetProperty( DevelControl::Property::SUB_STATE, "UNCHECKED" );
}
else
{
SetLabelText( button, "Uncheck" );
+ mShadowButton.SetProperty( DevelControl::Property::SUB_STATE, "CHECKED" );
}
break;
}
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "beat-control-impl.h"
+#include <dali-toolkit/dali-toolkit.h>
+#include <dali/public-api/object/type-registry-helper.h>
+#include <dali-toolkit/devel-api/align-enums.h>
+#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
+
+#include <cstdio>
+
+using namespace Dali; // Needed for macros
+using namespace Dali::Toolkit;
+
+namespace Demo
+{
+namespace Internal
+{
+
+namespace
+{
+
+const int BOUNCE_ANIMATION_RUNNING(0x0001);
+const int FADE_ANIMATION_RUNNING (0x0002);
+const int X_ANIMATION_RUNNING (0x0004);
+const int Y_ANIMATION_RUNNING (0x0008);
+
+
+Dali::BaseHandle Create()
+{
+ return Demo::BeatControl::New();
+}
+
+DALI_TYPE_REGISTRATION_BEGIN( BeatControl, Dali::Toolkit::Control, Create );
+
+DALI_PROPERTY_REGISTRATION( Demo, BeatControl, "bounceTransition", STRING, BOUNCE_TRANSITION );
+DALI_PROPERTY_REGISTRATION( Demo, BeatControl, "leftTransition", STRING, LEFT_TRANSITION );
+DALI_PROPERTY_REGISTRATION( Demo, BeatControl, "upTransition", STRING, UP_TRANSITION );
+DALI_PROPERTY_REGISTRATION( Demo, BeatControl, "fadeTransition", STRING, FADE_TRANSITION );
+DALI_PROPERTY_REGISTRATION( Demo, BeatControl, "beatVisual", MAP, BEAT_VISUAL );
+DALI_TYPE_REGISTRATION_END();
+
+
+Toolkit::TransitionData ConvertPropertyToTransition( const Property::Value& value )
+{
+ Toolkit::TransitionData transitionData;
+
+ if( value.GetType() == Property::ARRAY )
+ {
+ transitionData = Toolkit::TransitionData::New( *value.GetArray());
+ }
+ else if( value.GetType() == Property::MAP )
+ {
+ transitionData = Toolkit::TransitionData::New( *value.GetMap() );
+ }
+ return transitionData;
+}
+
+} // anonymous namespace
+
+
+Internal::BeatControl::BeatControl()
+: Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ),
+ mTransformSize(1.0f, 1.0f),
+ mAnimationPlaying(0)
+{
+}
+
+Internal::BeatControl::~BeatControl()
+{
+}
+
+Demo::BeatControl Internal::BeatControl::New()
+{
+ IntrusivePtr<Internal::BeatControl> impl = new Internal::BeatControl();
+ Demo::BeatControl handle = Demo::BeatControl( *impl );
+ impl->Initialize();
+ return handle;
+}
+
+
+void BeatControl::StartBounceAnimation()
+{
+ if( mAnimation )
+ {
+ mAnimation.Stop();
+ mAnimation.FinishedSignal().Disconnect( this, &BeatControl::OnBounceAnimationFinished );
+ OnBounceAnimationFinished(mAnimation);
+ }
+
+ mAnimation = CreateTransition( mBounceTransition );
+ mAnimation.FinishedSignal().Connect( this, &BeatControl::OnBounceAnimationFinished );
+ mAnimation.Play();
+ mAnimationPlaying |= BOUNCE_ANIMATION_RUNNING;
+}
+
+
+void BeatControl::StartXAnimation()
+{
+ if( mXAnimation )
+ {
+ mXAnimation.Stop();
+ mXAnimation.FinishedSignal().Disconnect( this, &BeatControl::OnXAnimationFinished );
+ OnXAnimationFinished(mXAnimation);
+ }
+
+ mXAnimation = CreateTransition( mLeftTransition );
+ mXAnimation.FinishedSignal().Connect( this, &BeatControl::OnXAnimationFinished );
+ mXAnimation.Play();
+ mAnimationPlaying |= X_ANIMATION_RUNNING;
+}
+
+void BeatControl::StartYAnimation()
+{
+ if( mYAnimation )
+ {
+ mYAnimation.Stop();
+ mYAnimation.FinishedSignal().Disconnect( this, &BeatControl::OnYAnimationFinished );
+ OnYAnimationFinished(mYAnimation);
+ }
+
+ mYAnimation = CreateTransition( mUpTransition );
+ mYAnimation.FinishedSignal().Connect( this, &BeatControl::OnYAnimationFinished );
+ mYAnimation.Play();
+ mAnimationPlaying |= Y_ANIMATION_RUNNING;
+}
+
+void BeatControl::StartFadeAnimation()
+{
+ if( mFadeAnimation )
+ {
+ mFadeAnimation.Stop();
+ mFadeAnimation.FinishedSignal().Disconnect( this, &BeatControl::OnFadeAnimationFinished );
+ OnFadeAnimationFinished(mFadeAnimation);
+ }
+
+ mFadeAnimation = CreateTransition( mFadeTransition );
+ mFadeAnimation.FinishedSignal().Connect( this, &BeatControl::OnFadeAnimationFinished );
+ mFadeAnimation.Play();
+ mAnimationPlaying |= FADE_ANIMATION_RUNNING;
+}
+
+void BeatControl::OnBounceAnimationFinished( Animation& src )
+{
+ mAnimationPlaying &= ~BOUNCE_ANIMATION_RUNNING;
+}
+void BeatControl::OnXAnimationFinished( Animation& src )
+{
+ mAnimationPlaying &= ~X_ANIMATION_RUNNING;
+}
+void BeatControl::OnYAnimationFinished( Animation& src )
+{
+ mAnimationPlaying &= ~Y_ANIMATION_RUNNING;
+}
+void BeatControl::OnFadeAnimationFinished( Animation& src )
+{
+ mAnimationPlaying &= ~FADE_ANIMATION_RUNNING;
+}
+
+void BeatControl::OnInitialize()
+{
+ Actor self = Self();
+}
+
+void BeatControl::OnStageConnection( int depth )
+{
+ Control::OnStageConnection( depth );
+}
+
+void BeatControl::OnStageDisconnection()
+{
+ Control::OnStageDisconnection();
+}
+
+void BeatControl::OnSizeSet( const Vector3& targetSize )
+{
+ Control::OnSizeSet( targetSize );
+ RelayoutVisuals( Vector2( targetSize ) );
+}
+
+void BeatControl::OnRelayout( const Vector2& targetSize, RelayoutContainer& container )
+{
+ RelayoutVisuals( targetSize );
+}
+
+void BeatControl::RelayoutVisuals( const Vector2& targetSize )
+{
+ if( mVisual )
+ {
+ if( (mAnimationPlaying & (X_ANIMATION_RUNNING | Y_ANIMATION_RUNNING)) == 0)
+ {
+ Vector2 size( targetSize );
+ Property::Map transformMap;
+ // Make the visual half the size of the control, but leave
+ // origin and anchor point at center, position is relative, but Zer0
+ transformMap[ DevelVisual::Transform::Property::SIZE ] = mTransformSize;
+ mVisual.SetTransformAndSize( transformMap, size );
+ }
+ }
+}
+
+Vector3 BeatControl::GetNaturalSize()
+{
+ if( mVisual )
+ {
+ Vector2 naturalSize;
+ mVisual.GetNaturalSize(naturalSize);
+ return Vector3(naturalSize);
+ }
+ return Vector3::ZERO;
+}
+
+void BeatControl::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change )
+{
+ // Chain up.
+ Control::OnStyleChange( styleManager, change );
+}
+
+
+///////////////////////////////////////////////////////////
+//
+// Properties
+//
+
+void BeatControl::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
+{
+ Demo::BeatControl beatControl = Demo::BeatControl::DownCast( Dali::BaseHandle( object ) );
+
+ if( beatControl )
+ {
+ BeatControl& impl = GetImpl( beatControl );
+ Actor self = impl.Self();
+ switch ( index )
+ {
+ case Demo::BeatControl::Property::BEAT_VISUAL:
+ {
+ bool sizeOnly = false;
+
+ // Determine if a transform.size property exists in the map, and
+ // save it.
+ Property::Map* map = value.GetMap();
+ if( map )
+ {
+ Property::Value* value = map->Find( DevelVisual::Property::TRANSFORM, "transform" );
+ if( value )
+ {
+ Property::Map* transformMap = value->GetMap();
+ if( transformMap )
+ {
+ Property::Value* sizeValue = transformMap->Find( DevelVisual::Transform::Property::SIZE, "size" );
+ if( sizeValue )
+ {
+ sizeValue->Get( impl.mTransformSize );
+ if( map->Count() == 1 && transformMap->Count() == 1 )
+ {
+ sizeOnly = true;
+ }
+ }
+ }
+ }
+ if( ! sizeOnly )
+ {
+ // Only register a visual if there is more than just a size setting
+ impl.mVisual = Toolkit::VisualFactory::Get().CreateVisual( *map );
+ impl.RegisterVisual( Demo::BeatControl::Property::BEAT_VISUAL, impl.mVisual );
+
+ // We have registered a new visual: must trigger size negotiation
+ // in order to call SetTransformAndSize on the visual with the right size:
+ impl.RelayoutRequest();
+ }
+ }
+ break;
+ }
+ case Demo::BeatControl::Property::BOUNCE_TRANSITION:
+ {
+ impl.mBounceTransition = ConvertPropertyToTransition( value );
+ break;
+ }
+ case Demo::BeatControl::Property::LEFT_TRANSITION:
+ {
+ impl.mLeftTransition = ConvertPropertyToTransition( value );
+ break;
+ }
+ case Demo::BeatControl::Property::UP_TRANSITION:
+ {
+ impl.mUpTransition = ConvertPropertyToTransition( value );
+ break;
+ }
+ case Demo::BeatControl::Property::FADE_TRANSITION:
+ {
+ impl.mFadeTransition = ConvertPropertyToTransition( value );
+ break;
+ }
+ }
+ }
+}
+
+Property::Value BeatControl::GetProperty( BaseObject* object, Property::Index propertyIndex )
+{
+ Property::Value value;
+
+ Demo::BeatControl beatControl = Demo::BeatControl::DownCast( Dali::BaseHandle( object ) );
+
+ if ( beatControl )
+ {
+ BeatControl& impl = GetImpl( beatControl );
+ switch ( propertyIndex )
+ {
+ case Demo::BeatControl::Property::BEAT_VISUAL:
+ {
+ if( impl.mVisual )
+ {
+ Property::Map map;
+ impl.mVisual.CreatePropertyMap(map);
+ value = map;
+ }
+ break;
+ }
+ case Demo::BeatControl::Property::BOUNCE_TRANSITION:
+ case Demo::BeatControl::Property::LEFT_TRANSITION:
+ case Demo::BeatControl::Property::UP_TRANSITION:
+ case Demo::BeatControl::Property::FADE_TRANSITION:
+ default:
+ break;
+ }
+ }
+
+ return value;
+}
+
+
+} // Internal
+} // Demo
--- /dev/null
+#ifndef DALI_DEMO_INTERNAL_BEAT_CONTROL_IMPL_H
+#define DALI_DEMO_INTERNAL_BEAT_CONTROL_IMPL_H
+
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "beat-control.h"
+#include <dali/public-api/animation/animation.h>
+#include <dali-toolkit/public-api/controls/control-impl.h>
+#include <dali-toolkit/devel-api/visual-factory/visual-base.h>
+#include <dali-toolkit/devel-api/visual-factory/transition-data.h>
+
+namespace Demo
+{
+
+namespace Internal // To use TypeRegistry, handle and body classes need the same name
+{
+
+class BeatControl : public Dali::Toolkit::Internal::Control
+{
+public:
+ /**
+ * Instantiate a new BeatControl object
+ */
+ static Demo::BeatControl New();
+ BeatControl();
+ ~BeatControl();
+
+public: // API
+ void StartBounceAnimation();
+
+ void StartXAnimation();
+
+ void StartYAnimation();
+
+ void StartFadeAnimation();
+
+public: // Properties
+ /**
+ * Called when a property of an object of this type is set.
+ * @param[in] object The object whose property is set.
+ * @param[in] index The property index.
+ * @param[in] value The new property value.
+ */
+ static void SetProperty( Dali::BaseObject* object, Dali::Property::Index index, const Dali::Property::Value& value );
+
+ /**
+ * Called to retrieve a property of an object of this type.
+ * @param[in] object The object whose property is to be retrieved.
+ * @param[in] index The property index.
+ * @return The current value of the property.
+ */
+ static Dali::Property::Value GetProperty( Dali::BaseObject* object, Dali::Property::Index propertyIndex );
+
+private: // From Control
+ /**
+ * @copydoc Toolkit::Control::OnInitialize()
+ */
+ virtual void OnInitialize();
+
+ /**
+ * @copydoc Toolkit::Control::OnStageConnect()
+ */
+ virtual void OnStageConnection( int depth );
+
+ /**
+ * @copydoc Toolkit::Control::OnStageDisconnection()
+ */
+ virtual void OnStageDisconnection();
+
+ /**
+ * @copydoc Toolkit::Control::OnSizeSet()
+ */
+ virtual void OnSizeSet( const Dali::Vector3& targetSize );
+
+ /**
+ * @copydoc Toolkit::Control::OnRelayout()
+ */
+ virtual void OnRelayout( const Dali::Vector2& targetSize, Dali::RelayoutContainer& container );
+ /**
+ * @copydoc Toolkit::Control::GetNaturalSize
+ */
+ virtual Dali::Vector3 GetNaturalSize();
+
+ /**
+ * @copydoc Toolkit::Control::OnStyleChange
+ */
+ virtual void OnStyleChange( Dali::Toolkit::StyleManager styleManager, Dali::StyleChange::Type change );
+
+private:
+ void OnBounceAnimationFinished( Dali::Animation& handle );
+ void OnXAnimationFinished( Dali::Animation& src );
+ void OnYAnimationFinished( Dali::Animation& src );
+ void OnFadeAnimationFinished( Dali::Animation& src );
+
+ /**
+ * Relayout the visuals as a result of size negotiation
+ */
+ void RelayoutVisuals( const Dali::Vector2& targetSize );
+
+private:
+ //undefined
+ BeatControl( const BeatControl& );
+ BeatControl& operator=( const BeatControl& );
+
+private:
+ // Implementation details
+ Dali::Toolkit::Visual::Base mVisual;
+ Dali::Toolkit::TransitionData mBounceTransition;
+ Dali::Toolkit::TransitionData mLeftTransition;
+ Dali::Toolkit::TransitionData mUpTransition;
+ Dali::Toolkit::TransitionData mFadeTransition;
+ Dali::Animation mAnimation;
+ Dali::Animation mXAnimation;
+ Dali::Animation mYAnimation;
+ Dali::Animation mFadeAnimation;
+ Dali::Vector2 mTransformSize;
+ int mAnimationPlaying;
+};
+
+} // Internal
+
+inline Internal::BeatControl& GetImpl( Demo::BeatControl& handle )
+{
+ DALI_ASSERT_ALWAYS( handle );
+ Dali::RefObject& object = handle.GetImplementation();
+ return static_cast<Internal::BeatControl&>(object);
+}
+
+inline const Internal::BeatControl& GetImpl( const Demo::BeatControl& handle )
+{
+ DALI_ASSERT_ALWAYS( handle );
+ const Dali::RefObject& object = handle.GetImplementation();
+ return static_cast<const Internal::BeatControl&>(object);
+}
+
+} // Demo
+
+#endif // DALI_DEMO_BEAT_CONTROL_IMPL_H
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "beat-control.h"
+#include "beat-control-impl.h"
+
+namespace Demo
+{
+
+BeatControl::BeatControl()
+{
+}
+
+BeatControl::BeatControl( const BeatControl& beatControl )
+: Control( beatControl )
+{
+}
+
+BeatControl& BeatControl::operator= ( const BeatControl& rhs )
+{
+ if( &rhs != this )
+ {
+ Control::operator=( rhs );
+ }
+ return *this;
+}
+
+BeatControl::~BeatControl()
+{
+}
+
+BeatControl BeatControl::New()
+{
+ BeatControl beatControl = Internal::BeatControl::New();
+ return beatControl;
+}
+
+BeatControl BeatControl::New( const std::string& url )
+{
+ BeatControl beatControl = Internal::BeatControl::New();
+ return beatControl;
+}
+
+BeatControl BeatControl::DownCast( BaseHandle handle )
+{
+ return Control::DownCast< BeatControl, Internal::BeatControl > ( handle );
+}
+
+void BeatControl::StartBounceAnimation()
+{
+ GetImpl(*this).StartBounceAnimation();
+}
+
+void BeatControl::StartXAnimation()
+{
+ GetImpl(*this).StartXAnimation();
+}
+void BeatControl::StartYAnimation()
+{
+ GetImpl(*this).StartYAnimation();
+}
+void BeatControl::StartFadeAnimation()
+{
+ GetImpl(*this).StartFadeAnimation();
+}
+
+BeatControl::BeatControl( Internal::BeatControl& implementation )
+: Control( implementation )
+{
+}
+
+BeatControl::BeatControl( Dali::Internal::CustomActor* internal )
+: Control( internal )
+{
+ VerifyCustomActorPointer< Internal::BeatControl >( internal ) ;
+}
+
+
+} //namespace Demo
--- /dev/null
+#ifndef DALI_DEMO_BEAT_CONTROL_H
+#define DALI_DEMO_BEAT_CONTROL_H
+
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dali-toolkit/dali-toolkit.h>
+#include <string>
+
+namespace Demo
+{
+
+namespace Internal
+{
+// All type registered types need to have the same name for the body and the handle
+class BeatControl;
+}
+
+/**
+ * Control that allows the RGB channels of an image to be altered.
+ */
+class BeatControl : public Dali::Toolkit::Control
+{
+public:
+ /**
+ * The start and end property ranges for this control
+ */
+ enum PropertyRange
+ {
+ PROPERTY_START_INDEX = Dali::Toolkit::Control::CONTROL_PROPERTY_END_INDEX + 1,
+ PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000,
+ ANIMATABLE_PROPERTY_START_INDEX = Dali::ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX,
+ ANIMATABLE_PROPERTY_END_INDEX = ANIMATABLE_PROPERTY_START_INDEX+1000
+ };
+
+ struct Property
+ {
+ enum
+ {
+ BOUNCE_TRANSITION = PROPERTY_START_INDEX,
+ LEFT_TRANSITION,
+ UP_TRANSITION,
+ FADE_TRANSITION,
+ BEAT_VISUAL
+ };
+ };
+
+public: // Construction / destruction
+
+ /**
+ * Create an uninitialized handle
+ */
+ BeatControl();
+
+ /**
+ * Create a new image channel control without an image. Use
+ * SetImage to give this control an image
+ */
+ static BeatControl New();
+
+ /**
+ * Create a new image channel control from a given URL
+ */
+ static BeatControl New( const std::string& url );
+
+ /**
+ * Destructor. This is non-virtual since derived Handle types must not
+ * contain data or virtual methods
+ */
+ ~BeatControl();
+
+ /**
+ * Copy Constructor
+ */
+ BeatControl( const BeatControl& beatControl );
+
+ /**
+ * Assignment Operator
+ */
+ BeatControl& operator=( const BeatControl& beatControl );
+
+ /**
+ * Downcast
+ */
+ static BeatControl DownCast( BaseHandle handle );
+
+public: // API
+
+ void StartBounceAnimation();
+
+ void StartXAnimation();
+
+ void StartYAnimation();
+
+ void StartFadeAnimation();
+
+public: // Not for public use
+ /**
+ * Create a handle from an implementation
+ */
+ BeatControl( Internal::BeatControl& implementation );
+
+ /**
+ * Allow the creation of an BeatControl handle from an internal CustomActor pointer
+ */
+ BeatControl( Dali::Internal::CustomActor* internal );
+};
+
+} // namespace Demo
+
+#endif // DALI_DEMO_BEAT_CONTROL_H
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file transition-application.cpp
+ * @brief Application class for showing stylable transitions
+ */
+
+// Class include
+#include "transition-application.h"
+
+// External includes
+#include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
+#include <dali-toolkit/devel-api/visuals/text-visual-properties.h>
+#include "beat-control.h"
+#include <cstdio>
+#include <sstream>
+
+// Internal includes
+
+using namespace Dali;
+using namespace Dali::Toolkit;
+
+namespace Demo
+{
+
+const char* TransitionApplication::DEMO_THEME_ONE_PATH( DEMO_STYLE_DIR "style-example-theme-one.json" );
+const char* DALI_LOGO_PATH( DEMO_IMAGE_DIR "Logo-for-demo.png" );
+const char* DALI_ROBOT_MODEL_PATH( DEMO_MODEL_DIR "ToyRobot-Metal.obj" );
+const char* DALI_ROBOT_MATERIAL_PATH( DEMO_MODEL_DIR "ToyRobot-Metal.mtl" );
+
+
+TransitionApplication::TransitionApplication( Application& application )
+: mApplication( application ),
+ mTitle(),
+ mBeatControl(),
+ mActionButtons(),
+ mActionIndex( Property::INVALID_INDEX )
+{
+ application.InitSignal().Connect( this, &TransitionApplication::Create );
+}
+
+TransitionApplication::~TransitionApplication()
+{
+}
+
+void TransitionApplication::Create( Application& application )
+{
+ Stage stage = Stage::GetCurrent();
+ stage.KeyEventSignal().Connect(this, &TransitionApplication::OnKeyEvent);
+ stage.SetBackgroundColor( Vector4( 0.1f, 0.1f, 0.1f, 1.0f ) );
+
+ // Hide the indicator bar
+ application.GetWindow().ShowIndicator( Dali::Window::INVISIBLE );
+
+ // Content panes:
+ TableView contentLayout = TableView::New( 4, 1 );
+ contentLayout.SetName("ContentLayout");
+ contentLayout.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+ contentLayout.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ contentLayout.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ contentLayout.SetCellPadding( Vector2( 0.0f, 5.0f ) );
+
+ // Assign all rows the size negotiation property of fitting to children
+
+ stage.Add( contentLayout );
+
+ mTitle = TextLabel::New( "Custom Control Transition Example" );
+ mTitle.SetName( "Title" );
+ mTitle.SetStyleName("Title");
+ mTitle.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
+ mTitle.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT );
+ mTitle.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
+ contentLayout.Add( mTitle );
+ contentLayout.SetFitHeight(0); // Fill width
+
+ mBeatControl = BeatControl::New();
+ mBeatControl.SetName("BeatControl");
+ mBeatControl.SetProperty( BeatControl::Property::BEAT_VISUAL, Property::Map()
+ .Add( DevelVisual::Property::TRANSFORM, Property::Map()
+ .Add( DevelVisual::Transform::Property::SIZE, Vector2(0.5f, 0.5f) ) ) );
+
+ mBeatControl.SetAnchorPoint( AnchorPoint::CENTER );
+ mBeatControl.SetParentOrigin( ParentOrigin::CENTER );
+ mBeatControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+ contentLayout.Add( mBeatControl );
+ // beat control should fill the tableview cell, so no change to default parameters
+
+ TableView visualTypeLayout = TableView::New( 1, NUMBER_OF_VISUAL_BUTTONS );
+ visualTypeLayout.SetName("VisualTypeLayout");
+ visualTypeLayout.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
+ visualTypeLayout.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::HEIGHT );
+ visualTypeLayout.SetFitHeight( 0 );
+
+ contentLayout.Add( visualTypeLayout );
+ contentLayout.SetFitHeight(2);
+
+ for( int i=0; i<NUMBER_OF_VISUAL_BUTTONS; ++i )
+ {
+ Property::Map map;
+ CreateVisualMap( i, map );
+ map.Add( DevelVisual::Property::TRANSFORM, Property::Map()
+ .Add( DevelVisual::Transform::Property::SIZE, Vector2(0.8f, 0.8f) ) );
+ mVisualButtons[i] = BeatControl::New();
+ mVisualButtons[i].SetProperty( BeatControl::Property::BEAT_VISUAL, map );
+ mVisualButtons[i].SetName("VisualButton");
+ mVisualButtons[i].SetStyleName("VisualButton");
+ mVisualButtons[i].SetSize(0, 50);
+ mVisualButtons[i].SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
+ mVisualButtons[i].SetResizePolicy( ResizePolicy::FIXED, Dimension::HEIGHT );
+ mVisualIndex = mVisualButtons[i].RegisterProperty( "visualId", i, Property::READ_WRITE );
+ mVisualButtons[i].TouchSignal().Connect( this, &TransitionApplication::OnVisualButtonClicked );
+ visualTypeLayout.AddChild( mVisualButtons[i], TableView::CellPosition( 0, i ) );
+ }
+
+ TableView actionButtonLayout = TableView::New( 1, NUMBER_OF_ACTION_BUTTONS+1 );
+ actionButtonLayout.SetName("ThemeButtonsLayout");
+ actionButtonLayout.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
+ actionButtonLayout.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::HEIGHT );
+ actionButtonLayout.SetFitHeight( 0 );
+
+ TextLabel label = TextLabel::New( "Action: ");
+ label.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
+ label.SetStyleName("ActionLabel");
+ actionButtonLayout.AddChild( label, TableView::CellPosition( 0, 0 ) );
+ actionButtonLayout.SetCellAlignment( TableView::CellPosition( 0, 0 ), HorizontalAlignment::LEFT, VerticalAlignment::CENTER );
+
+ for( int i=0; i<NUMBER_OF_ACTION_BUTTONS; ++i )
+ {
+ mActionButtons[i] = PushButton::New();
+ mActionButtons[i].SetName("ActionButton");
+ mActionButtons[i].SetStyleName("ActionButton");
+ mActionButtons[i].SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
+ mActionButtons[i].SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT );
+ mActionIndex = mActionButtons[i].RegisterProperty( "actionId", i, Property::READ_WRITE );
+ mActionButtons[i].ClickedSignal().Connect( this, &TransitionApplication::OnActionButtonClicked );
+ actionButtonLayout.AddChild( mActionButtons[i], TableView::CellPosition( 0, 1+i ) );
+ }
+ mActionButtons[0].SetLabelText( "Bounce" );
+ mActionButtons[1].SetLabelText( "X" );
+ mActionButtons[2].SetLabelText( "Y" );
+ mActionButtons[3].SetLabelText( "Fade" );
+
+ contentLayout.Add( actionButtonLayout );
+ contentLayout.SetFitHeight(3);
+}
+
+void TransitionApplication::CreateVisualMap( int index, Property::Map& map )
+{
+ switch(index)
+ {
+ case 0:
+ {
+ map[ Visual::Property::TYPE ] = Visual::COLOR;
+ map[ ColorVisual::Property::MIX_COLOR ] = Color::YELLOW;
+ break;
+ }
+ case 1:
+ {
+ map[ Visual::Property::TYPE ] = Visual::BORDER;
+ map[ BorderVisual::Property::COLOR ] = Color::GREEN;
+ map[ BorderVisual::Property::SIZE ] = 5;
+ break;
+ }
+ case 2:
+ {
+ map[ Visual::Property::TYPE ] = Visual::GRADIENT;
+
+ Property::Array stopOffsets;
+ stopOffsets.PushBack( 0.0f );
+ stopOffsets.PushBack( 0.3f );
+ stopOffsets.PushBack( 0.6f );
+ stopOffsets.PushBack( 0.8f );
+ stopOffsets.PushBack( 1.0f );
+ map[ GradientVisual::Property::STOP_OFFSET ] = stopOffsets;
+
+ Property::Array stopColors;
+ stopColors.PushBack( Vector4( 129.f, 198.f, 193.f, 255.f )/255.f );
+ stopColors.PushBack( Vector4( 196.f, 198.f, 71.f, 122.f )/255.f );
+ stopColors.PushBack( Vector4( 214.f, 37.f, 139.f, 191.f )/255.f );
+ stopColors.PushBack( Vector4( 129.f, 198.f, 193.f, 150.f )/255.f );
+ stopColors.PushBack( Color::YELLOW );
+ map[ GradientVisual::Property::STOP_COLOR ] = stopColors;
+ map[ GradientVisual::Property::START_POSITION ] = Vector2(-0.5f, -0.5f );
+ map[ GradientVisual::Property::END_POSITION ] = Vector2( 0.5f, 0.5f );
+ break;
+ }
+ case 3:
+ {
+ map[ Visual::Property::TYPE ] = Visual::IMAGE;
+ map[ ImageVisual::Property::URL ] = DALI_LOGO_PATH;
+ break;
+ }
+ case 4:
+ {
+ map[ Visual::Property::TYPE ] = Visual::IMAGE;
+ map[ ImageVisual::Property::URL ] = DEMO_IMAGE_DIR "preMultAlpha.png";
+ map[ DevelVisual::Property::PREMULTIPLIED_ALPHA ] = true;
+ break;
+ }
+
+ case 5:
+ {
+ map[ Visual::Property::TYPE ] = Visual::MESH;
+ map[ MeshVisual::Property::OBJECT_URL ] = DALI_ROBOT_MODEL_PATH;
+ map[ MeshVisual::Property::MATERIAL_URL ] = DALI_ROBOT_MATERIAL_PATH;
+ map[ MeshVisual::Property::TEXTURES_PATH ] = DEMO_IMAGE_DIR;
+ map[ MeshVisual::Property::SHADING_MODE ] = MeshVisual::ShadingMode::TEXTURED_WITH_DETAILED_SPECULAR_LIGHTING;
+ break;
+ }
+
+ case 6:
+ {
+ map[ Visual::Property::TYPE ] = Visual::PRIMITIVE;
+
+ map[ PrimitiveVisual::Property::SHAPE ] = PrimitiveVisual::Shape::BEVELLED_CUBE;
+ map[ PrimitiveVisual::Property::BEVEL_PERCENTAGE ] = 0.3f;
+ map[ PrimitiveVisual::Property::BEVEL_SMOOTHNESS ] = 0.0f;
+ map[ PrimitiveVisual::Property::SCALE_DIMENSIONS ] = Vector3(1.0f,1.0f,0.3f);
+ map[ PrimitiveVisual::Property::MIX_COLOR ] = Vector4(0.7f, 0.5f, 0.05f, 1.0f);
+
+ break;
+ }
+
+ case 7:
+ {
+ // NPatch
+ map[ Visual::Property::TYPE ] = Visual::IMAGE;
+ map[ ImageVisual::Property::URL ] = DEMO_IMAGE_DIR "button-up-16.9.png";
+ break;
+ }
+ case 8:
+ {
+ // SVG
+ map[ Visual::Property::TYPE ] = Visual::IMAGE;
+ map[ ImageVisual::Property::URL ] = DEMO_IMAGE_DIR "Kid1.svg";
+ break;
+ }
+
+ case 9:
+ {
+ map[ Visual::Property::TYPE ] = DevelVisual::TEXT;
+ map[ TextVisual::Property::TEXT ] = "Text";
+ map[ TextVisual::Property::TEXT_COLOR ] = Color::CYAN;
+ map[ TextVisual::Property::POINT_SIZE ] = 10;
+ break;
+ }
+
+ default:
+ {
+ map[ Visual::Property::TYPE ] = Visual::COLOR;
+ map[ ColorVisual::Property::MIX_COLOR ] = Color::MAGENTA;
+ break;
+ }
+ }
+}
+
+bool TransitionApplication::OnVisualButtonClicked( Actor actor, const TouchData& touchData )
+{
+ if( touchData.GetState(0) == PointState::FINISHED )
+ {
+ int visual = actor.GetProperty<int>( mVisualIndex );
+ Property::Map map;
+ CreateVisualMap( visual, map );
+ map.Add( DevelVisual::Property::TRANSFORM, Property::Map()
+ .Add( DevelVisual::Transform::Property::SIZE, Vector2( 0.5f, 0.5f ) ) );
+ mBeatControl.SetProperty( BeatControl::Property::BEAT_VISUAL, map );
+ }
+ return true;
+}
+
+bool TransitionApplication::OnActionButtonClicked( Button button )
+{
+ int action = button.GetProperty<int>( mActionIndex );
+ switch( action )
+ {
+ case 0:
+ {
+ mBeatControl.StartBounceAnimation();
+ break;
+ }
+ case 1:
+ {
+ mBeatControl.StartXAnimation();
+ break;
+ }
+ case 2:
+ {
+ mBeatControl.StartYAnimation();
+ break;
+ }
+ case 3:
+ {
+ mBeatControl.StartFadeAnimation();
+ break;
+ }
+ }
+
+ return true;
+}
+
+void TransitionApplication::OnKeyEvent( const KeyEvent& keyEvent )
+{
+ static int keyPressed = 0;
+
+ if( keyEvent.state == KeyEvent::Down)
+ {
+ if( keyPressed == 0 ) // Is this the first down event?
+ {
+ printf("Key pressed: %s %d\n", keyEvent.keyPressedName.c_str(), keyEvent.keyCode );
+
+ if( IsKey( keyEvent, DALI_KEY_ESCAPE) || IsKey( keyEvent, DALI_KEY_BACK ) )
+ {
+ mApplication.Quit();
+ }
+ else if( keyEvent.keyPressedName.compare("Return") == 0 )
+ {
+ }
+ }
+ keyPressed = 1;
+ }
+ else if( keyEvent.state == KeyEvent::Up )
+ {
+ keyPressed = 0;
+ }
+}
+
+} // namespace Demo
--- /dev/null
+#ifndef DALI_DEMO_TRANSITION_APPLICATION_H
+#define DALI_DEMO_TRANSITION_APPLICATION_H
+
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// External includes
+#include <dali-toolkit/dali-toolkit.h>
+//#include <dali-toolkit/devel-api/controls/slider/slider.h>
+#include <dali-toolkit/devel-api/controls/popup/popup.h>
+#include "beat-control.h"
+#include <cstdio>
+#include <sstream>
+
+// Internal includes
+
+using namespace Dali;
+using namespace Dali::Toolkit;
+
+namespace Demo
+{
+
+class TransitionApplication : public ConnectionTracker
+{
+public:
+ static const int NUMBER_OF_ACTION_BUTTONS=4;
+ static const int NUMBER_OF_VISUAL_BUTTONS=10;
+
+public:
+ // Constructor
+ TransitionApplication( Application& application );
+
+ // Destructor
+ ~TransitionApplication();
+
+ // Init signal handler
+ void Create( Application& application );
+
+ // Create the GUI components
+ Toolkit::TextLabel CreateTitle( std::string title );
+ Actor CreateContentPane();
+
+ // Key event handler
+ void OnKeyEvent( const KeyEvent& event );
+
+ bool OnActionButtonClicked( Button button );
+ bool OnVisualButtonClicked( Actor actor, const TouchData& touchData );
+
+ static const char* DEMO_THEME_ONE_PATH;
+
+private:
+
+ /** Create a visual map
+ *
+ * @param[in] index The index of the visual to create
+ * @param[out] map The map to generate
+ */
+ void CreateVisualMap( int index, Property::Map& map );
+
+ Application& mApplication;
+ TextLabel mTitle;
+ BeatControl mBeatControl;
+ PushButton mActionButtons[NUMBER_OF_ACTION_BUTTONS];
+ BeatControl mVisualButtons[NUMBER_OF_VISUAL_BUTTONS];
+ Property::Index mVisualIndex;
+ Property::Index mActionIndex;
+};
+
+} // Namespace Demo
+
+
+#endif // DALI_DEMO_TRANSITION_APPLICATION_H
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file transition-example.cpp
+ * @brief Example of stylable transitions.
+ */
+
+// External includes
+#include <dali/dali.h>
+
+// Internal includes
+#include "transition-application.h"
+
+
+/// Entry point for applications
+int DALI_EXPORT_API main( int argc, char** argv )
+{
+ const char* themeName = Demo::TransitionApplication::DEMO_THEME_ONE_PATH;
+
+ Application application = Application::New( &argc, &argv, themeName );
+ Demo::TransitionApplication transitionApplication( application );
+ application.MainLoop();
+ return 0;
+}
Name: com.samsung.dali-demo
Summary: The OpenGLES Canvas Core Demo
-Version: 1.2.25
+Version: 1.2.28
Release: 1
Group: System/Libraries
License: Apache-2.0
BuildRequires: pkgconfig(dali-toolkit)
#need libtzplatform-config for directory if tizen version is 3.x
-%if "%{tizen_version_major}" == "3"
+%if 0%{?tizen_version_major} >= 3
BuildRequires: pkgconfig(libtzplatform-config)
%endif
mkdir -p %{buildroot}%{dali_icon_dir}
mv %{buildroot}/%{dali_app_res_dir}/images/%{name}.png %{buildroot}%{dali_icon_dir}
+mv %{buildroot}/%{dali_app_res_dir}/images/dali-examples.png %{buildroot}%{dali_icon_dir}
%if 0%{?enable_dali_smack_rules} && !%{with wayland}
mkdir -p %{buildroot}%{smack_rule_dir}
%endif
%defattr(-,root,root,-)
%{dali_app_exe_dir}/dali-demo
+%{dali_app_exe_dir}/dali-examples
%{dali_app_exe_dir}/*.example
%{dali_app_exe_dir}/dali-builder
%{dali_app_res_dir}/images/*
msgid "DALI_DEMO_STR_TITLE_MESH_VISUAL"
msgstr "3D অনুগামী"
-msgid "DALI_DEMO_STR_TITLE_METABALL_EXPLOSION"
-msgstr "মেটাবল মহা-বিস্ফোৰণবাদ"
-
-msgid "DALI_DEMO_STR_TITLE_METABALL_REFRAC"
-msgstr "মেটাবল প্ৰতিসৰিত"
-
msgid "DALI_DEMO_STR_TITLE_MOTION_BLUR"
msgstr "অস্পষ্ট"
msgid "DALI_DEMO_STR_TITLE_NEGOTIATE_SIZE"
msgstr "অকণমান আপোচ কৰ্"
-msgid "DALI_DEMO_STR_TITLE_PAGE_TURN_VIEW"
-msgstr "পৃষ্ঠা লেআউট"
-
msgid "DALI_DEMO_STR_TITLE_POPUP"
msgstr "পোপা মেনু"
msgid "DALI_DEMO_STR_TITLE_STYLING"
msgstr "শৈলী"
-msgid "DALI_DEMO_STR_TITLE_SUPER_BLUR_BLOOM"
-msgstr "অস্পষ্টকৈ অপুষ্পক"
-
msgid "DALI_DEMO_STR_TITLE_TEXTURED_MESH"
msgstr "টেক্সটারেদ মেশ"
msgid "DALI_DEMO_STR_TITLE_MESH_VISUAL"
msgstr "3D-Modelle"
-msgid "DALI_DEMO_STR_TITLE_METABALL_EXPLOSION"
-msgstr "Metaball Explosion"
-
-msgid "DALI_DEMO_STR_TITLE_METABALL_REFRAC"
-msgstr "Metaball Brechung"
-
msgid "DALI_DEMO_STR_TITLE_MOTION_BLUR"
msgstr "Bewegungsunschärfe"
msgid "DALI_DEMO_STR_TITLE_NEGOTIATE_SIZE"
msgstr "Größe Verhandlung"
-msgid "DALI_DEMO_STR_TITLE_PAGE_TURN_VIEW"
-msgstr "Seite wechseln"
-
msgid "DALI_DEMO_STR_TITLE_POPUP"
msgstr "Popup-Menü"
msgid "DALI_DEMO_STR_TITLE_STYLING"
msgstr "Styling"
-msgid "DALI_DEMO_STR_TITLE_SUPER_BLUR_BLOOM"
-msgstr "Unschärfe und blühen"
-
msgid "DALI_DEMO_STR_TITLE_TEXTURED_MESH"
msgstr "Strukturiertem Mesh"
msgid "DALI_DEMO_STR_TITLE_MESH_VISUAL"
msgstr "Mesh Visual"
-msgid "DALI_DEMO_STR_TITLE_METABALL_EXPLOSION"
-msgstr "Metaball Explosion"
-
-msgid "DALI_DEMO_STR_TITLE_METABALL_REFRAC"
-msgstr "Metaball Refraction"
-
msgid "DALI_DEMO_STR_TITLE_MOTION_BLUR"
msgstr "Motion Blur"
msgid "DALI_DEMO_STR_TITLE_NEGOTIATE_SIZE"
msgstr "Negotiate Size"
-msgid "DALI_DEMO_STR_TITLE_PAGE_TURN_VIEW"
-msgstr "Page Turn View"
-
msgid "DALI_DEMO_STR_TITLE_POPUP"
msgstr "Popup"
msgid "DALI_DEMO_STR_TITLE_STYLING"
msgstr "Styling"
-msgid "DALI_DEMO_STR_TITLE_SUPER_BLUR_BLOOM"
-msgstr "Super Blur and Bloom"
-
msgid "DALI_DEMO_STR_TITLE_TEXTURED_MESH"
msgstr "Mesh Texture"
msgid "DALI_DEMO_STR_TITLE_MESH_VISUAL"
msgstr "Mesh Visual"
-msgid "DALI_DEMO_STR_TITLE_METABALL_EXPLOSION"
-msgstr "Metaball Explosion"
-
-msgid "DALI_DEMO_STR_TITLE_METABALL_REFRAC"
-msgstr "Metaball Refraction"
-
msgid "DALI_DEMO_STR_TITLE_MOTION_BLUR"
msgstr "Motion Blur"
msgid "DALI_DEMO_STR_TITLE_NEGOTIATE_SIZE"
msgstr "Negotiate Size"
-msgid "DALI_DEMO_STR_TITLE_PAGE_TURN_VIEW"
-msgstr "Page Turn View"
-
msgid "DALI_DEMO_STR_TITLE_POPUP"
msgstr "Popup"
msgid "DALI_DEMO_STR_TITLE_STYLING"
msgstr "Styling"
-msgid "DALI_DEMO_STR_TITLE_SUPER_BLUR_BLOOM"
-msgstr "Super Blur and Bloom"
-
msgid "DALI_DEMO_STR_TITLE_TEXTURED_MESH"
msgstr "Mesh Texture"
msgid "DALI_DEMO_STR_TITLE_MESH_VISUAL"
msgstr "Gemeotria 3D"
-msgid "DALI_DEMO_STR_TITLE_METABALL_EXPLOSION"
-msgstr "Explosion de metabolas"
-
-msgid "DALI_DEMO_STR_TITLE_METABALL_REFRAC"
-msgstr "Refraccion de metabolas"
-
msgid "DALI_DEMO_STR_TITLE_MOTION_BLUR"
msgstr "Desenfoque de movimiento"
msgid "DALI_DEMO_STR_TITLE_NEGOTIATE_SIZE"
msgstr "Negociacion de tamaño"
-msgid "DALI_DEMO_STR_TITLE_PAGE_TURN_VIEW"
-msgstr "Vista de páginas"
-
msgid "DALI_DEMO_STR_TITLE_POPUP"
msgstr "Popup"
msgid "DALI_DEMO_STR_TITLE_STYLING"
msgstr "Estilo"
-msgid "DALI_DEMO_STR_TITLE_SUPER_BLUR_BLOOM"
-msgstr "Efecto blur y bloom"
-
msgid "DALI_DEMO_STR_TITLE_TEXTURED_MESH"
msgstr "Geometria con texturas"
msgid "DALI_DEMO_STR_TITLE_MESH_VISUAL"
msgstr "Polygoniverkkovisuaali"
-msgid "DALI_DEMO_STR_TITLE_METABALL_EXPLOSION"
-msgstr "Metaball Räjähdys"
-
-msgid "DALI_DEMO_STR_TITLE_METABALL_REFRAC"
-msgstr "Metaball Valon Taittumisella"
-
msgid "DALI_DEMO_STR_TITLE_MOTION_BLUR"
msgstr "Liikesumennus"
msgid "DALI_DEMO_STR_TITLE_NEGOTIATE_SIZE"
msgstr "Kokoneuvottelu"
-msgid "DALI_DEMO_STR_TITLE_PAGE_TURN_VIEW"
-msgstr "Sivunkääntönäkymä"
-
msgid "DALI_DEMO_STR_TITLE_POPUP"
msgstr "Ponnahdusikkuna"
msgid "DALI_DEMO_STR_TITLE_STYLING"
msgstr "UI Tyyli"
-msgid "DALI_DEMO_STR_TITLE_SUPER_BLUR_BLOOM"
-msgstr "Erikoissumennus ja Hehku efekti"
-
msgid "DALI_DEMO_STR_TITLE_TEXTURED_MESH"
msgstr "Teksturoitu Polygoniverkko"
msgid "DALI_DEMO_STR_TITLE_MESH_VISUAL"
msgstr "메쉬 비주얼"
-msgid "DALI_DEMO_STR_TITLE_METABALL_EXPLOSION"
-msgstr "메타볼 폭발"
-
-msgid "DALI_DEMO_STR_TITLE_METABALL_REFRAC"
-msgstr "메타볼 굴절"
-
msgid "DALI_DEMO_STR_TITLE_MOTION_BLUR"
msgstr "모션 블러"
msgid "DALI_DEMO_STR_TITLE_NEGOTIATE_SIZE"
msgstr "사이즈 조절"
-msgid "DALI_DEMO_STR_TITLE_PAGE_TURN_VIEW"
-msgstr "책장 넘기기"
-
msgid "DALI_DEMO_STR_TITLE_POPUP"
msgstr "팝업"
msgid "DALI_DEMO_STR_TITLE_STYLING"
msgstr "스타일링"
-msgid "DALI_DEMO_STR_TITLE_SUPER_BLUR_BLOOM"
-msgstr "블러링 이펙트"
-
msgid "DALI_DEMO_STR_TITLE_TEXTURED_MESH"
msgstr "텍스쳐 메쉬"
msgid "DALI_DEMO_STR_TITLE_MESH_VISUAL"
msgstr "3D മോഡലിങ്"
-msgid "DALI_DEMO_STR_TITLE_METABALL_EXPLOSION"
-msgstr "മെറ്റാ പന്ത് സ്ഫോടനം"
-
-msgid "DALI_DEMO_STR_TITLE_METABALL_REFRAC"
-msgstr "മെറ്റാ പന്ത് അപവർത്തനം"
-
msgid "DALI_DEMO_STR_TITLE_MOTION_BLUR"
msgstr "അവ്യക്തമാക്കല്"
msgid "DALI_DEMO_STR_TITLE_NEGOTIATE_SIZE"
msgstr "വലുപ്പം കൂടിയാലോചന"
-msgid "DALI_DEMO_STR_TITLE_PAGE_TURN_VIEW"
-msgstr "പേജ് ലേഔട്ട്"
-
msgid "DALI_DEMO_STR_TITLE_POPUP"
msgstr "പോപപ്പ് മെനുവിൽ"
msgid "DALI_DEMO_STR_TITLE_STYLING"
msgstr "ശൈലി"
-msgid "DALI_DEMO_STR_TITLE_SUPER_BLUR_BLOOM"
-msgstr "മങ്ങൽ പൂക്കൽ"
-
msgid "DALI_DEMO_STR_TITLE_TEXTURED_MESH"
msgstr "ടെക്സ്ചർ mesh"
msgid "DALI_DEMO_STR_TITLE_MESH_VISUAL"
msgstr "3D میش"
-msgid "DALI_DEMO_STR_TITLE_METABALL_EXPLOSION"
-msgstr "میٹابال دھماکہ"
-
-msgid "DALI_DEMO_STR_TITLE_METABALL_REFRAC"
-msgstr "میٹابال اپورتن"
-
msgid "DALI_DEMO_STR_TITLE_MOTION_BLUR"
msgstr "دھندلانے کی حرکت"
msgid "DALI_DEMO_STR_TITLE_NEGOTIATE_SIZE"
msgstr "سائز مذاکرات"
-msgid "DALI_DEMO_STR_TITLE_PAGE_TURN_VIEW"
-msgstr "کتاب"
-
msgid "DALI_DEMO_STR_TITLE_POPUP"
msgstr "پاپ اپ"
msgid "DALI_DEMO_STR_TITLE_STYLING"
msgstr "سٹائل"
-msgid "DALI_DEMO_STR_TITLE_SUPER_BLUR_BLOOM"
-msgstr "دھندلاپن اور بلوم"
-
msgid "DALI_DEMO_STR_TITLE_TEXTURED_MESH"
msgstr "ٹیکسچرد میش"
msgid "DALI_DEMO_STR_TITLE_MESH_VISUAL"
msgstr "3D模型"
-msgid "DALI_DEMO_STR_TITLE_METABALL_EXPLOSION"
-msgstr "元球爆炸"
-
-msgid "DALI_DEMO_STR_TITLE_METABALL_REFRAC"
-msgstr "元球折射"
-
msgid "DALI_DEMO_STR_TITLE_MOTION_BLUR"
msgstr "动作模糊"
msgid "DALI_DEMO_STR_TITLE_NEGOTIATE_SIZE"
msgstr "尺寸协商"
-msgid "DALI_DEMO_STR_TITLE_PAGE_TURN_VIEW"
-msgstr "翻页"
-
msgid "DALI_DEMO_STR_TITLE_POPUP"
msgstr "弹窗"
msgid "DALI_DEMO_STR_TITLE_STYLING"
msgstr "样式"
-msgid "DALI_DEMO_STR_TITLE_SUPER_BLUR_BLOOM"
-msgstr "模糊及泛光"
-
msgid "DALI_DEMO_STR_TITLE_TEXTURED_MESH"
msgstr "纹理网格"
"desiredWidth": 400,
"desiredHeight": 400,
"shader": {
- "fragmentShader": "precision mediump float;\nuniform sampler2D sTexture;\nuniform vec4 uColor;\nuniform float uAmplitude;\nuniform float uTime;\nvarying vec2 vTexCoord;\nvoid main()\n{\n highp vec2 pos = -1.0 + 2.0 * vTexCoord;\n highp float len = length(pos);\n highp vec2 texCoord = vTexCoord + pos/len * sin( len * 12.0 - uTime * 4.0 ) * uAmplitude;\n gl_FragColor = texture2D(sTexture, texCoord) * uColor;}\n\n"
+ "fragmentShader": [
+ "precision mediump float;",
+ "uniform sampler2D sTexture;",
+ "uniform vec4 uColor;",
+ "uniform float uAmplitude;",
+ "uniform float uTime;",
+ "varying vec2 vTexCoord;",
+ "void main()",
+ "{",
+ " highp vec2 pos = -1.0 + 2.0 * vTexCoord;",
+ " highp float len = length(pos);",
+ " highp vec2 texCoord = vTexCoord + pos/len * sin( len * 12.0 - uTime * 4.0 ) * uAmplitude;",
+ " gl_FragColor = texture2D(sTexture, texCoord) * uColor;",
+ "}"
+ ]
}
},
"animatableProperties": {
"position": [0, 0, 0],
"size": [200, 100, 0],
"labelText": "Blur",
+ "siblingOrder": 1,
"signals": [{
"name": "pressed",
"action": "play",
"tailRightImage":"{APPLICATION_RESOURCE_PATH}/images/popup-tail-right.png"
},
+ "DemoTile":
+ {
+ "states":
+ {
+ "NORMAL":
+ {
+ "color":[0.4, 0.6, 0.9, 0.6],
+ "visuals":
+ {
+ "image":
+ {
+ "url":"{APPLICATION_RESOURCE_PATH}/images/demo-tile-texture.9.png",
+// TILE_BACKGROUND_ALPHA
+// This shader takes a texture.
+// An alpha discard is performed.
+// The shader uses the tiles position within the scroll-view page and the scroll-views rotation position to create a parallax effect.
+ "shader":
+ {
+ "fragmentShader":[
+ " varying mediump vec2 vTexCoord;",
+ " uniform lowp vec4 uColor;",
+ " uniform sampler2D sTexture;",
+ " uniform mediump vec3 uCustomPosition;",
+ "",
+ " void main()",
+ " {",
+ " if( texture2D( sTexture, vTexCoord ).a <= 0.0001 )",
+ " {",
+ " discard;",
+ " }",
+ "",
+ " mediump vec2 wrapTexCoord = vec2( ( vTexCoord.x / 4.0 ) + ( uCustomPosition.x / 4.0 ) + ( uCustomPosition.z / 2.0 ), vTexCoord.y / 4.0 );",
+ " mediump vec4 color = texture2D( sTexture, wrapTexCoord );",
+ " mediump float positionWeight = ( uCustomPosition.y + 0.3 ) * color.r * 2.0;",
+ "",
+ " gl_FragColor = vec4( positionWeight, positionWeight, positionWeight, 0.9 ) * uColor + vec4( uColor.xyz, 0.0 );",
+ " }"
+ ]
+ }
+ }
+ }
+ },
+ "FOCUSED":
+ {
+ "color":[0.3, 0.5, 0.8, 0.5],
+ "visuals":
+ {
+ "image":
+ {
+ "url":"{APPLICATION_RESOURCE_PATH}/images/demo-tile-texture-focused.9.png",
+// TILE_BACKGROUND_ALPHA
+// This shader takes a texture.
+// An alpha discard is performed.
+// The shader uses the tiles position within the scroll-view page and the scroll-views rotation position to create a parallax effect.
+ "shader":
+ {
+ "fragmentShader":[
+ " varying mediump vec2 vTexCoord;",
+ " uniform lowp vec4 uColor;",
+ " uniform sampler2D sTexture;",
+ " uniform mediump vec3 uCustomPosition;",
+ "",
+ " void main()",
+ " {",
+ " if( texture2D( sTexture, vTexCoord ).a <= 0.0001 )",
+ " {",
+ " discard;",
+ " }",
+ "",
+ " mediump vec2 wrapTexCoord = vec2( ( vTexCoord.x / 4.0 ) + ( uCustomPosition.x / 4.0 ) + ( uCustomPosition.z / 2.0 ), vTexCoord.y / 4.0 );",
+ " mediump vec4 color = texture2D( sTexture, wrapTexCoord );",
+ " mediump float positionWeight = ( uCustomPosition.y + 0.3 ) * color.r * 2.0;",
+ "",
+ " gl_FragColor = vec4( positionWeight, positionWeight, positionWeight, 0.9 ) * uColor + vec4( uColor.xyz, 0.0 );",
+ " }"
+ ]
+ }
+ }
+ }
+ }
+ }
+ },
+ "FocusActor":
+ {
+ "visuals":
+ {
+ "image":
+ {
+ "url":"{APPLICATION_RESOURCE_PATH}/images/tile-focus.9.png"
+ }
+ }
+ },
+ "DemoTileBorder":
+ {
+ "visuals":
+ {
+ "image":
+ {
+ "url":"{APPLICATION_RESOURCE_PATH}/images/item-background.9.png" // TILE_BACKGROUND
+ }
+ }
+ },
"TextLabelRosemary":
{
"fontFamily":"Rosemary"
"tailLeftImage":"{APPLICATION_RESOURCE_PATH}/images/popup-tail-left.png",
"tailRightImage":"{APPLICATION_RESOURCE_PATH}/images/popup-tail-right.png"
},
+
+ "DemoTile":
+ {
+ "states":
+ {
+ "NORMAL":
+ {
+ "color":[0.4, 0.6, 0.9, 0.6],
+ "visuals":
+ {
+ "image":
+ {
+ "url":"{APPLICATION_RESOURCE_PATH}/images/demo-tile-texture.9.png",
+// TILE_BACKGROUND_ALPHA
+// This shader takes a texture.
+// An alpha discard is performed.
+// The shader uses the tiles position within the scroll-view page and the scroll-views rotation position to create a parallax effect.
+ "shader":
+ {
+ "fragmentShader":[
+ " varying mediump vec2 vTexCoord;",
+ " uniform lowp vec4 uColor;",
+ " uniform sampler2D sTexture;",
+ " uniform mediump vec3 uCustomPosition;",
+ "",
+ " void main()",
+ " {",
+ " if( texture2D( sTexture, vTexCoord ).a <= 0.0001 )",
+ " {",
+ " discard;",
+ " }",
+ "",
+ " mediump vec2 wrapTexCoord = vec2( ( vTexCoord.x / 4.0 ) + ( uCustomPosition.x / 4.0 ) + ( uCustomPosition.z / 2.0 ), vTexCoord.y / 4.0 );",
+ " mediump vec4 color = texture2D( sTexture, wrapTexCoord );",
+ " mediump float positionWeight = ( uCustomPosition.y + 0.3 ) * color.r * 2.0;",
+ "",
+ " gl_FragColor = vec4( positionWeight, positionWeight, positionWeight, 0.9 ) * uColor + vec4( uColor.xyz, 0.0 );",
+ " }"
+ ]
+ }
+ }
+ }
+ },
+ "FOCUSED":
+ {
+ "color":[0.3, 0.5, 0.8, 0.5],
+ "visuals":
+ {
+ "image":
+ {
+ "url":"{APPLICATION_RESOURCE_PATH}/images/demo-tile-texture-focused.9.png",
+// TILE_BACKGROUND_ALPHA
+// This shader takes a texture.
+// An alpha discard is performed.
+// The shader uses the tiles position within the scroll-view page and the scroll-views rotation position to create a parallax effect.
+ "shader":
+ {
+ "fragmentShader":[
+ " varying mediump vec2 vTexCoord;",
+ " uniform lowp vec4 uColor;",
+ " uniform sampler2D sTexture;",
+ " uniform mediump vec3 uCustomPosition;",
+ "",
+ " void main()",
+ " {",
+ " if( texture2D( sTexture, vTexCoord ).a <= 0.0001 )",
+ " {",
+ " discard;",
+ " }",
+ "",
+ " mediump vec2 wrapTexCoord = vec2( ( vTexCoord.x / 4.0 ) + ( uCustomPosition.x / 4.0 ) + ( uCustomPosition.z / 2.0 ), vTexCoord.y / 4.0 );",
+ " mediump vec4 color = texture2D( sTexture, wrapTexCoord );",
+ " mediump float positionWeight = ( uCustomPosition.y + 0.3 ) * color.r * 2.0;",
+ "",
+ " gl_FragColor = vec4( positionWeight, positionWeight, positionWeight, 0.9 ) * uColor + vec4( uColor.xyz, 0.0 );",
+ " }"
+ ]
+ }
+ }
+ }
+ }
+ }
+ },
+ "FocusActor":
+ {
+ "visuals":
+ {
+ "image":
+ {
+ "url":"{APPLICATION_RESOURCE_PATH}/images/tile-focus.9.png"
+ }
+ }
+ },
+ "DemoTileBorder":
+ {
+ "visuals":
+ {
+ "image":
+ {
+ "url":"{APPLICATION_RESOURCE_PATH}/images/item-background.9.png" // TILE_BACKGROUND
+ }
+ }
+ },
"TextLabelRosemary":
{
"fontFamily":"Rosemary"
* limitations under the License.
*
*/
-
{
"styles":
{
- "ProgressBarCustomStyle1":
+ "ProgressBar":
{
- "progressValue": 0,
"trackVisual":{
- "url":"{APPLICATION_RESOURCE_PATH}/images/progress-bar.9.png",
- "size":[5,24]
+ "url":"{APPLICATION_RESOURCE_PATH}/images/new-progress-bar-track.9.png"
},
"progressVisual":{
- "url":"{APPLICATION_RESOURCE_PATH}/images/progress-bar-progress.9.png",
- "size":[5,24]
- }
- },
-
- "ProgressBarCustomStyle2":
- {
- "progressValue": 0,
- "trackVisual":{
- "url":"{APPLICATION_RESOURCE_PATH}/images/progress-bar-2.9.png",
- "size":[5,7]
+ "url":"{APPLICATION_RESOURCE_PATH}/images/new-progress-bar-progress.9.png"
},
- "progressVisual":{
- "url":"{APPLICATION_RESOURCE_PATH}/images/progress-bar-progress-2.9.png",
- "size":[5,7]
+ "secondaryProgressVisual":{
+ "url":"{APPLICATION_RESOURCE_PATH}/images/new-progress-bar-secondary-progress.9.png"
}
}
}
[
{
"target":"imageVisual",
- "property":"mixColor",
- "initialValue":[1,1,1,0],
- "targetValue":[1,1,1,1],
+ "property":"opacity",
+ "initialValue":0,
+ "targetValue":1,
"animator":
{
"alphaFunction":"EASE_IN_OUT",
[
{
"target":"imageVisual",
- "property":"mixColor",
- "targetValue":[1,1,1,0],
+ "property":"opacity",
+ "targetValue":0,
"animator":
{
"alphaFunction":"EASE_IN_OUT",
},
"ShadowButton":
{
- "backgroundVisual":{
- "visualType":"IMAGE",
- "url":"{STYLE_DIR}/images/shadowButtonBg.9.png",
- "mixColor":[1,1,1,0]
- },
- "checkboxBgVisual":{
- "visualType":"IMAGE",
- "url":"{STYLE_DIR}/images/CheckBg.png",
- "transform":{
- "size":[0.09, 0.28],
- "offset":[30,0],
- "offsetSizeMode":[1,1,0,0],
- "origin":"CENTER_BEGIN",
- "anchorPoint":"CENTER_BEGIN"
- }
- },
- "checkboxFgVisual":{
- "visualType":"IMAGE",
- "url":"{STYLE_DIR}/images/Tick.png",
- "transform":{
- "size":[0.09, 0.28],
- "offset":[30,0],
- "offsetSizeMode":[1,1,0,0],
- "origin":"CENTER_BEGIN",
- "anchorPoint":"CENTER_BEGIN"
- }
- },
- "labelVisual":{
- "visualType":"TEXT",
- "text":"Don't show again",
- "pointSize":8,
- "horizontalAlignment":"END",
- "verticalAlignment":"CENTER",
- "textColor":[1,1,1,1],
- "mixColor":[0.3, 0.3, 0.3, 1],
- "transform":{
- "size":[0.9, 0.9],
- "offset":[-30,0],
- "offsetSizeMode":[1,1,0,0],
- "origin":"CENTER_END",
- "anchorPoint":"CENTER_END"
- }
- },
- "activeTransition":
- [
+ "states":
+ {
+ "NORMAL":
{
- "target":"checkboxBgVisual",
- "property":"size",
- "initialValue":[0.09, 0.28],
- "targetValue":[0.12, 0.37],
- "animator":
+ "visuals":
{
- "alphaFunction":"EASE_OUT_BACK",
- "timePeriod":
- {
- "duration":0.8,
- "delay":0
+ "backgroundVisual":{
+ "visualType":"IMAGE",
+ "url":"{STYLE_DIR}/images/shadowButtonBg.9.png"
+ },
+
+ "checkboxBgVisual":{
+ "visualType":"IMAGE",
+ "url":"{STYLE_DIR}/images/CheckBg.png",
+ "transform":{
+ "size":[0.09, 0.28],
+ "offset":[30,0],
+ "offsetSizeMode":[1,1,0,0],
+ "origin":"CENTER_BEGIN",
+ "anchorPoint":"CENTER_BEGIN"
+ }
+ },
+
+ "labelVisual":{
+ "visualType":"TEXT",
+ "text":"Don't show again",
+ "pointSize":8,
+ "horizontalAlignment":"END",
+ "verticalAlignment":"CENTER",
+ "textColor":[1,1,1,1],
+ "mixColor":[0, 0, 0, 1],
+ "transform":{
+ "size":[0.9, 0.9],
+ "offset":[-30,0],
+ "offsetSizeMode":[1,1,0,0],
+ "origin":"CENTER_END",
+ "anchorPoint":"CENTER_END"
+ }
}
- }
- },
- {
- "target":"backgroundVisual",
- "property":"mixColor",
- "initialValue":[1,1,1,0],
- "targetValue":[1,1,1,1],
- "animator":
+ },
+
+ "states":
{
- "alphaFunction":"EASE_OUT_BACK",
- "timePeriod":
+ "CHECKED":
{
- "duration":0.8,
- "delay":0
- }
- }
- },
- {
- "target":"backgroundVisual",
- "property":"size",
- "initialValue":[0.9, 0.9],
- "targetValue":[1, 1],
- "animator":
- {
- "alphaFunction":"EASE_OUT_BACK",
- "timePeriod":
- {
- "duration":0.8,
- "delay":0
- }
- }
- },
- {
- "target":"checkboxFgVisual",
- "property":"size",
- "initialValue":[0.09, 0.28],
- "targetValue":[0.12, 0.37],
- "animator":
- {
- "alphaFunction":"EASE_OUT_BACK",
- "timePeriod":
+ "visuals":
+ {
+ "checkboxFgVisual":{
+ "visualType":"IMAGE",
+ "url":"{STYLE_DIR}/images/Tick.png",
+ "transform":{
+ "size":[0.09, 0.28],
+ "offset":[30,0],
+ "offsetSizeMode":[1,1,0,0],
+ "origin":"CENTER_BEGIN",
+ "anchorPoint":"CENTER_BEGIN"
+ }
+ }
+ },
+ "entryTransition":
+ [
+ {
+ "target":"checkboxFgVisual",
+ "property":"pixelArea",
+ "initialValue":[0.0, 0.0, 0.0, 1.0],
+ "targetValue":[0.0, 0.0, 1.0, 1.0],
+ "animator":
+ {
+ "alphaFunction":"EASE_IN",
+ "timePeriod":
+ {
+ "duration":0.4,
+ "delay":0
+ }
+ }
+ },
+ {
+ "target":"checkboxFgVisual",
+ "property":"size",
+ "initialValue":[0.0, 0.37],
+ "targetValue":[0.12, 0.37],
+ "animator":
+ {
+ "alphaFunction":"EASE_IN",
+ "timePeriod":
+ {
+ "duration":0.4,
+ "delay":0
+ }
+ }
+ }
+ ],
+ "exitTransition":
+ [
+ {
+ "target":"checkboxFgVisual",
+ "property":"pixelArea",
+ "initialValue":[0.0, 0.0, 1.0, 1.0],
+ "targetValue":[0.0, 0.0, 0.0, 1.0],
+ "animator":
+ {
+ "alphaFunction":"EASE_OUT",
+ "timePeriod":
+ {
+ "duration":0.4,
+ "delay":0
+ }
+ }
+ },
+ {
+ "target":"checkboxFgVisual",
+ "property":"size",
+ "targetValue":[0.0, 0.37],
+ "animator":
+ {
+ "alphaFunction":"EASE_OUT",
+ "timePeriod":
+ {
+ "duration":0.4,
+ "delay":0
+ }
+ }
+ }
+ ]
+ },
+ "UNCHECKED":
{
- "duration":0.8,
- "delay":0
}
}
},
+ //"FOCUSED"
+ "DISABLED":
{
- "target":"labelVisual",
- "property":"mixColor",
- "initialValue":[0.2, 0.2, 0.2, 1.0],
- "targetValue":[0, 0, 0, 1],
- "animator":
+ "visuals":
{
- "alphaFunction":"EASE_OUT_BACK",
- "timePeriod":
- {
- "duration":0.8,
- "delay":0
+ "checkboxBgVisual":{
+ "visualType":"IMAGE",
+ "url":"{STYLE_DIR}/images/CheckBg.png",
+ "transform":{
+ "size":[0.09, 0.28],
+ "offset":[30,0],
+ "offsetSizeMode":[1,1,0,0],
+ "origin":"CENTER_BEGIN",
+ "anchorPoint":"CENTER_BEGIN"
+ }
+ },
+
+ "checkboxFgVisual":{
+ "visualType":"IMAGE",
+ "url":"{STYLE_DIR}/images/Tick.png",
+ "transform":{
+ "size":[0.09, 0.28],
+ "offset":[30,0],
+ "offsetSizeMode":[1,1,0,0],
+ "origin":"CENTER_BEGIN",
+ "anchorPoint":"CENTER_BEGIN"
+ }
+ },
+
+ "labelVisual":{
+ "visualType":"TEXT",
+ "text":"Don't show again",
+ "pointSize":8,
+ "horizontalAlignment":"END",
+ "verticalAlignment":"CENTER",
+ "textColor":[1,1,1,1],
+ "mixColor":[0.3, 0.3, 0.3, 1],
+ "transform":{
+ "size":[0.9, 0.9],
+ "offset":[-30,0],
+ "offsetSizeMode":[1,1,0,0],
+ "origin":"CENTER_END",
+ "anchorPoint":"CENTER_END"
+ }
}
}
}
- ],
- "inactiveTransition":
+ },
+ "transitions":
[
{
- "target":"checkboxBgVisual",
- "property":"size",
- "initialValue":[0.12, 0.37],
- "targetValue":[0.09, 0.28],
+ "from":"DISABLED",
+ "to":"NORMAL",
+ "visualName":"backgroundVisual",
+ "effect":"FADE_IN",
"animator":
{
"alphaFunction":"EASE_OUT_BACK",
- "timePeriod":
- {
- "duration":0.8,
- "delay":0
- }
+ "duration":0.8
}
},
{
- "target":"backgroundVisual",
- "property":"mixColor",
- "targetValue":[1,1,1,0],
+ "from":"DISABLED",
+ "to":"NORMAL",
+ "visualName":"*",
"animator":
{
"alphaFunction":"EASE_OUT_BACK",
- "timePeriod":
- {
- "duration":0.8,
- "delay":0
- }
+ "duration":0.8
}
},
{
- "target":"checkboxFgVisual",
- "property":"size",
- "initialValue":[0.12, 0.37],
- "targetValue":[0.09, 0.28],
+ "from":"NORMAL",
+ "to":"DISABLED",
+ "visualName":"backgroundVisual",
+ "effect":"FADE_OUT",
"animator":
{
"alphaFunction":"EASE_OUT_BACK",
- "timePeriod":
- {
- "duration":0.8,
- "delay":0
- }
+ "duration":0.8
}
},
{
- "target":"labelVisual",
- "property":"mixColor",
- "targetValue":[0.4, 0.4, 0.4, 1.0],
+ "from":"NORMAL",
+ "to":"DISABLED",
+ "visualName":"*",
"animator":
{
"alphaFunction":"EASE_OUT_BACK",
- "timePeriod":
- {
- "duration":0.8,
- "delay":0
- }
+ "duration":0.8
}
- },
+ }
+ ]
+ },
+ "BeatControl":
+ {
+ "beatVisual":{
+ "visualType":"IMAGE",
+ "url":"{APPLICATION_RESOURCE_PATH}/images/Logo-for-demo.png"
+ },
+
+ "bounceTransition":
+ [
{
- "target":"backgroundVisual",
+ "target":"beatVisual",
"property":"size",
- "targetValue":[0.9, 0.9],
+ "initialValue":[0.5, 0.5],
+ "targetValue":[0.75, 0.75],
"animator":
{
- "alphaFunction":"EASE_OUT_BACK",
+ "alphaFunction":"BOUNCE",
"timePeriod":
{
- "duration":0.8,
+ "duration":0.5,
"delay":0
}
}
}
],
- "checkTransition":
+
+ "leftTransition":
[
{
- "target":"checkboxFgVisual",
- "property":"pixelArea",
- "initialValue":[0.0, 0.0, 0.0, 1.0],
- "targetValue":[0.0, 0.0, 1.0, 1.0],
- "animator":
- {
- "alphaFunction":"EASE_IN",
- "timePeriod":
- {
- "duration":0.4,
- "delay":0
- }
- }
- },
- {
- "target":"checkboxFgVisual",
- "property":"size",
- "initialValue":[0.0, 0.37],
- "targetValue":[0.12, 0.37],
+ "target":"beatVisual",
+ "property":"offset",
+ "initialValue":[0, 0],
+ "targetValue":[0.25, 0],
"animator":
{
- "alphaFunction":"EASE_IN",
+ "alphaFunction":"BOUNCE",
"timePeriod":
{
- "duration":0.4,
+ "duration":0.5,
"delay":0
}
}
}
],
- "uncheckTransition":
+
+ "upTransition":
[
{
- "target":"checkboxFgVisual",
- "property":"pixelArea",
- "initialValue":[0.0, 0.0, 1.0, 1.0],
- "targetValue":[0.0, 0.0, 0.0, 1.0],
+ "target":"beatVisual",
+ "property":"offset",
+ "initialValue":[0, 0],
+ "targetValue":[0, 0.25],
"animator":
{
- "alphaFunction":"EASE_OUT",
+ "alphaFunction":"BOUNCE",
"timePeriod":
{
- "duration":0.4,
+ "duration":0.5,
"delay":0
}
}
- },
+ }
+ ],
+
+ "fadeTransition":
+ [
{
- "target":"checkboxFgVisual",
- "property":"size",
- "targetValue":[0.0, 0.37],
+ "target":"beatVisual",
+ "property":"opacity",
+ "targetValue":0,
"animator":
{
- "alphaFunction":"EASE_OUT",
+ "alphaFunction":"BOUNCE",
"timePeriod":
{
- "duration":0.4,
+ "duration":0.8,
"delay":0
}
}
{
"styles":
{
- "ProgressBarCustomStyle1":
+ "ProgressBar":
{
- "progressValue": 0,
"trackVisual":{
- "url":"{APPLICATION_RESOURCE_PATH}/images/progress-bar.9.png",
- "size":[5,24]
+ "url":"{APPLICATION_RESOURCE_PATH}/images/new-progress-bar-track.9.png"
},
"progressVisual":{
- "url":"{APPLICATION_RESOURCE_PATH}/images/progress-bar-progress.9.png",
- "size":[5,24]
- }
- },
-
- "ProgressBarCustomStyle2":
- {
- "progressValue": 0,
- "trackVisual":{
- "url":"{APPLICATION_RESOURCE_PATH}/images/progress-bar-2.9.png",
- "size":[5,7]
+ "url":"{APPLICATION_RESOURCE_PATH}/images/new-progress-bar-progress.9.png"
},
- "progressVisual":{
- "url":"{APPLICATION_RESOURCE_PATH}/images/progress-bar-progress-2.9.png",
- "size":[5,7]
+ "secondaryProgressVisual":{
+ "url":"{APPLICATION_RESOURCE_PATH}/images/new-progress-bar-secondary-progress.9.png"
}
}
}
[
{
"target":"imageVisual",
- "property":"mixColor",
- "initialValue":[1,1,1,0],
- "targetValue":[1,1,1,1],
+ "property":"opacity",
+ "initialValue":0,
+ "targetValue":1,
"animator":
{
"alphaFunction":"EASE_IN_OUT",
[
{
"target":"imageVisual",
- "property":"mixColor",
- "targetValue":[1,1,1,0],
+ "property":"opacity",
+ "targetValue":0,
"animator":
{
"alphaFunction":"EASE_IN_OUT",
},
"ShadowButton":
{
- "backgroundVisual":{
- "visualType":"IMAGE",
- "url":"{STYLE_DIR}/images/shadowButtonBg.9.png",
- "mixColor":[1,1,1,0]
- },
- "checkboxBgVisual":{
- "visualType":"IMAGE",
- "url":"{STYLE_DIR}/images/CheckBg.png",
- "transform":{
- "size":[0.09, 0.28],
- "offset":[30,0],
- "offsetSizeMode":[1,1,0,0],
- "origin":"CENTER_BEGIN",
- "anchorPoint":"CENTER_BEGIN"
- }
- },
- "checkboxFgVisual":{
- "visualType":"IMAGE",
- "url":"{STYLE_DIR}/images/Tick.png",
- "transform":{
- "size":[0.09, 0.28],
- "offset":[30,0],
- "offsetSizeMode":[1,1,0,0],
- "origin":"CENTER_BEGIN",
- "anchorPoint":"CENTER_BEGIN"
- }
- },
- "labelVisual":{
- "visualType":"TEXT",
- "text":"Don't show again",
- "pointSize":20,
- "horizontalAlignment":"END",
- "verticalAlignment":"CENTER",
- "textColor":[1,1,1,1],
- "mixColor":[0.3, 0.3, 0.3, 1],
- "transform":{
- "size":[0.9, 0.9],
- "offset":[-30,0],
- "offsetSizeMode":[1,1,0,0],
- "origin":"CENTER_END",
- "anchorPoint":"CENTER_END"
- }
- },
- "activeTransition":
- [
+ "states":
+ {
+ "NORMAL":
{
- "target":"checkboxBgVisual",
- "property":"size",
- "initialValue":[0.09, 0.28],
- "targetValue":[0.12, 0.37],
- "animator":
+ "visuals":
{
- "alphaFunction":"EASE_OUT_BACK",
- "timePeriod":
- {
- "duration":0.8,
- "delay":0
+ "backgroundVisual":{
+ "visualType":"IMAGE",
+ "url":"{STYLE_DIR}/images/shadowButtonBg.9.png"
+ },
+
+ "checkboxBgVisual":{
+ "visualType":"IMAGE",
+ "url":"{STYLE_DIR}/images/CheckBg.png",
+ "transform":{
+ "size":[0.09, 0.28],
+ "offset":[30,0],
+ "offsetSizeMode":[1,1,0,0],
+ "origin":"CENTER_BEGIN",
+ "anchorPoint":"CENTER_BEGIN"
+ }
+ },
+
+ "labelVisual":{
+ "visualType":"TEXT",
+ "text":"Don't show again",
+ "pointSize":20,
+ "horizontalAlignment":"END",
+ "verticalAlignment":"CENTER",
+ "textColor":[1,1,1,1],
+ "mixColor":[0, 0, 0, 1],
+ "transform":{
+ "size":[0.9, 0.9],
+ "offset":[-30,0],
+ "offsetSizeMode":[1,1,0,0],
+ "origin":"CENTER_END",
+ "anchorPoint":"CENTER_END"
+ }
}
- }
- },
- {
- "target":"backgroundVisual",
- "property":"mixColor",
- "initialValue":[1,1,1,0],
- "targetValue":[1,1,1,1],
- "animator":
+ },
+
+ "states":
{
- "alphaFunction":"EASE_OUT_BACK",
- "timePeriod":
+ "CHECKED":
{
- "duration":0.8,
- "delay":0
- }
- }
- },
- {
- "target":"backgroundVisual",
- "property":"size",
- "initialValue":[0.9, 0.9],
- "targetValue":[1, 1],
- "animator":
- {
- "alphaFunction":"EASE_OUT_BACK",
- "timePeriod":
- {
- "duration":0.8,
- "delay":0
- }
- }
- },
- {
- "target":"checkboxFgVisual",
- "property":"size",
- "initialValue":[0.09, 0.28],
- "targetValue":[0.12, 0.37],
- "animator":
- {
- "alphaFunction":"EASE_OUT_BACK",
- "timePeriod":
+ "visuals":
+ {
+ "checkboxFgVisual":{
+ "visualType":"IMAGE",
+ "url":"{STYLE_DIR}/images/Tick.png",
+ "transform":{
+ "size":[0.09, 0.28],
+ "offset":[30,0],
+ "offsetSizeMode":[1,1,0,0],
+ "origin":"CENTER_BEGIN",
+ "anchorPoint":"CENTER_BEGIN"
+ }
+ }
+ },
+ "entryTransition":
+ [
+ {
+ "target":"checkboxFgVisual",
+ "property":"pixelArea",
+ "initialValue":[0.0, 0.0, 0.0, 1.0],
+ "targetValue":[0.0, 0.0, 1.0, 1.0],
+ "animator":
+ {
+ "alphaFunction":"EASE_IN",
+ "timePeriod":
+ {
+ "duration":0.4,
+ "delay":0
+ }
+ }
+ },
+ {
+ "target":"checkboxFgVisual",
+ "property":"size",
+ "initialValue":[0.0, 0.37],
+ "targetValue":[0.12, 0.37],
+ "animator":
+ {
+ "alphaFunction":"EASE_IN",
+ "timePeriod":
+ {
+ "duration":0.4,
+ "delay":0
+ }
+ }
+ }
+ ],
+ "exitTransition":
+ [
+ {
+ "target":"checkboxFgVisual",
+ "property":"pixelArea",
+ "initialValue":[0.0, 0.0, 1.0, 1.0],
+ "targetValue":[0.0, 0.0, 0.0, 1.0],
+ "animator":
+ {
+ "alphaFunction":"EASE_OUT",
+ "timePeriod":
+ {
+ "duration":0.4,
+ "delay":0
+ }
+ }
+ },
+ {
+ "target":"checkboxFgVisual",
+ "property":"size",
+ "targetValue":[0.0, 0.37],
+ "animator":
+ {
+ "alphaFunction":"EASE_OUT",
+ "timePeriod":
+ {
+ "duration":0.4,
+ "delay":0
+ }
+ }
+ }
+ ]
+ },
+ "UNCHECKED":
{
- "duration":0.8,
- "delay":0
}
}
},
+ //"FOCUSED"
+ "DISABLED":
{
- "target":"labelVisual",
- "property":"mixColor",
- "initialValue":[0.2, 0.2, 0.2, 1.0],
- "targetValue":[0, 0, 0, 1],
- "animator":
+ "visuals":
{
- "alphaFunction":"EASE_OUT_BACK",
- "timePeriod":
- {
- "duration":0.8,
- "delay":0
+ "checkboxBgVisual":{
+ "visualType":"IMAGE",
+ "url":"{STYLE_DIR}/images/CheckBg.png",
+ "transform":{
+ "size":[0.09, 0.28],
+ "offset":[30,0],
+ "offsetSizeMode":[1,1,0,0],
+ "origin":"CENTER_BEGIN",
+ "anchorPoint":"CENTER_BEGIN"
+ }
+ },
+
+ "checkboxFgVisual":{
+ "visualType":"IMAGE",
+ "url":"{STYLE_DIR}/images/Tick.png",
+ "transform":{
+ "size":[0.09, 0.28],
+ "offset":[30,0],
+ "offsetSizeMode":[1,1,0,0],
+ "origin":"CENTER_BEGIN",
+ "anchorPoint":"CENTER_BEGIN"
+ }
+ },
+
+ "labelVisual":{
+ "visualType":"TEXT",
+ "text":"Don't show again",
+ "pointSize":20,
+ "horizontalAlignment":"END",
+ "verticalAlignment":"CENTER",
+ "textColor":[1,1,1,1],
+ "mixColor":[0.3, 0.3, 0.3, 1],
+ "transform":{
+ "size":[0.9, 0.9],
+ "offset":[-30,0],
+ "offsetSizeMode":[1,1,0,0],
+ "origin":"CENTER_END",
+ "anchorPoint":"CENTER_END"
+ }
}
}
}
- ],
- "inactiveTransition":
+ },
+ "transitions":
[
{
- "target":"checkboxBgVisual",
- "property":"size",
- "initialValue":[0.12, 0.37],
- "targetValue":[0.09, 0.28],
+ "from":"DISABLED",
+ "to":"NORMAL",
+ "visualName":"backgroundVisual",
+ "effect":"FADE_IN",
"animator":
{
"alphaFunction":"EASE_OUT_BACK",
- "timePeriod":
- {
- "duration":0.8,
- "delay":0
- }
+ "duration":0.8
}
},
{
- "target":"backgroundVisual",
- "property":"mixColor",
- "targetValue":[1,1,1,0],
+ "from":"DISABLED",
+ "to":"NORMAL",
+ "visualName":"*",
"animator":
{
"alphaFunction":"EASE_OUT_BACK",
- "timePeriod":
- {
- "duration":0.8,
- "delay":0
- }
+ "duration":0.8
}
},
{
- "target":"checkboxFgVisual",
- "property":"size",
- "initialValue":[0.12, 0.37],
- "targetValue":[0.09, 0.28],
+ "from":"NORMAL",
+ "to":"DISABLED",
+ "visualName":"backgroundVisual",
+ "effect":"FADE_OUT",
"animator":
{
"alphaFunction":"EASE_OUT_BACK",
- "timePeriod":
- {
- "duration":0.8,
- "delay":0
- }
+ "duration":0.8
}
},
{
- "target":"labelVisual",
- "property":"mixColor",
- "targetValue":[0.4, 0.4, 0.4, 1.0],
+ "from":"NORMAL",
+ "to":"DISABLED",
+ "visualName":"*",
"animator":
{
"alphaFunction":"EASE_OUT_BACK",
- "timePeriod":
- {
- "duration":0.8,
- "delay":0
- }
+ "duration":0.8
}
- },
+ }
+ ]
+ },
+ "BeatControl":
+ {
+ "beatVisual":{
+ "visualType":"IMAGE",
+ "url":"{APPLICATION_RESOURCE_PATH}/images/Logo-for-demo.png"
+ },
+
+ "bounceTransition":
+ [
{
- "target":"backgroundVisual",
+ "target":"beatVisual",
"property":"size",
- "targetValue":[0.9, 0.9],
+ "initialValue":[0.5, 0.5],
+ "targetValue":[0.75, 0.75],
"animator":
{
- "alphaFunction":"EASE_OUT_BACK",
+ "alphaFunction":"BOUNCE",
"timePeriod":
{
- "duration":0.8,
+ "duration":0.5,
"delay":0
}
}
}
],
- "checkTransition":
+
+ "leftTransition":
[
{
- "target":"checkboxFgVisual",
- "property":"pixelArea",
- "initialValue":[0.0, 0.0, 0.0, 1.0],
- "targetValue":[0.0, 0.0, 1.0, 1.0],
- "animator":
- {
- "alphaFunction":"EASE_IN",
- "timePeriod":
- {
- "duration":0.4,
- "delay":0
- }
- }
- },
- {
- "target":"checkboxFgVisual",
- "property":"size",
- "initialValue":[0.0, 0.37],
- "targetValue":[0.12, 0.37],
+ "target":"beatVisual",
+ "property":"offset",
+ "initialValue":[0, 0],
+ "targetValue":[0.25, 0],
"animator":
{
- "alphaFunction":"EASE_IN",
+ "alphaFunction":"BOUNCE",
"timePeriod":
{
- "duration":0.4,
+ "duration":0.5,
"delay":0
}
}
}
],
- "uncheckTransition":
+
+ "upTransition":
[
{
- "target":"checkboxFgVisual",
- "property":"pixelArea",
- "initialValue":[0.0, 0.0, 1.0, 1.0],
- "targetValue":[0.0, 0.0, 0.0, 1.0],
+ "target":"beatVisual",
+ "property":"offset",
+ "initialValue":[0, 0],
+ "targetValue":[0, 0.25],
"animator":
{
- "alphaFunction":"EASE_OUT",
+ "alphaFunction":"BOUNCE",
"timePeriod":
{
- "duration":0.4,
+ "duration":0.5,
"delay":0
}
}
- },
+ }
+ ],
+
+ "fadeTransition":
+ [
{
- "target":"checkboxFgVisual",
- "property":"size",
- "targetValue":[0.0, 0.37],
+ "target":"beatVisual",
+ "property":"opacity",
+ "targetValue":0,
"animator":
{
- "alphaFunction":"EASE_OUT",
+ "alphaFunction":"BOUNCE",
"timePeriod":
{
- "duration":0.4,
+ "duration":0.8,
"delay":0
}
}
#define DALI_DEMO_STR_TITLE_MESH_MORPH dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_MESH_MORPH")
#define DALI_DEMO_STR_TITLE_MESH_SORTING dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_MESH_SORTING")
#define DALI_DEMO_STR_TITLE_MESH_VISUAL dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_MESH_VISUAL")
-#define DALI_DEMO_STR_TITLE_METABALL_EXPLOSION dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_METABALL_EXPLOSION")
-#define DALI_DEMO_STR_TITLE_METABALL_REFRAC dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_METABALL_REFRAC")
#define DALI_DEMO_STR_TITLE_MOTION_BLUR dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_MOTION_BLUR")
#define DALI_DEMO_STR_TITLE_MOTION_STRETCH dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_MOTION_STRETCH")
#define DALI_DEMO_STR_TITLE_NATIVE_IMAGE_SOURCE dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_NATIVE_IMAGE_SOURCE")
#define DALI_DEMO_STR_TITLE_NEGOTIATE_SIZE dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_NEGOTIATE_SIZE")
-#define DALI_DEMO_STR_TITLE_PAGE_TURN_VIEW dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_PAGE_TURN_VIEW")
#define DALI_DEMO_STR_TITLE_POPUP dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_POPUP")
#define DALI_DEMO_STR_TITLE_PRIMITIVE_SHAPES dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_PRIMITIVE_SHAPES")
#define DALI_DEMO_STR_TITLE_PROGRESS_BAR dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_PROGRESS_BAR")
#define DALI_DEMO_STR_TITLE_SCROLL_VIEW dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_SCROLL_VIEW")
#define DALI_DEMO_STR_TITLE_SPARKLE dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_SPARKLE")
#define DALI_DEMO_STR_TITLE_STYLING dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_STYLING")
-#define DALI_DEMO_STR_TITLE_SUPER_BLUR_BLOOM dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_SUPER_BLUR_BLOOM")
#define DALI_DEMO_STR_TITLE_TEXTURED_MESH dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_TEXTURED_MESH")
#define DALI_DEMO_STR_TITLE_TEXT_EDITOR dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_TEXT_EDITOR")
#define DALI_DEMO_STR_TITLE_TEXT_FIELD dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_TEXT_FIELD")
#define DALI_DEMO_STR_TITLE_MESH_MORPH "Mesh Morph"
#define DALI_DEMO_STR_TITLE_MESH_SORTING "Mesh Sorting"
#define DALI_DEMO_STR_TITLE_MESH_VISUAL "Mesh Visual"
-#define DALI_DEMO_STR_TITLE_METABALL_EXPLOSION "Metaball Explosion"
-#define DALI_DEMO_STR_TITLE_METABALL_REFRAC "Metaball Refractions"
#define DALI_DEMO_STR_TITLE_MOTION_BLUR "Motion Blur"
#define DALI_DEMO_STR_TITLE_MOTION_STRETCH "Motion Stretch"
#define DALI_DEMO_STR_TITLE_NATIVE_IMAGE_SOURCE "Native Image Source"
#define DALI_DEMO_STR_TITLE_NEGOTIATE_SIZE "Negotiate Size"
-#define DALI_DEMO_STR_TITLE_PAGE_TURN_VIEW "Page Turn View"
#define DALI_DEMO_STR_TITLE_POPUP "Popup"
#define DALI_DEMO_STR_TITLE_PRIMITIVE_SHAPES "Primitive Shapes"
#define DALI_DEMO_STR_TITLE_PROGRESS_BAR "Progress Bar"
#define DALI_DEMO_STR_TITLE_SCROLL_VIEW "Scroll View"
#define DALI_DEMO_STR_TITLE_SPARKLE "Sparkle"
#define DALI_DEMO_STR_TITLE_STYLING "Styling"
-#define DALI_DEMO_STR_TITLE_SUPER_BLUR_BLOOM "Super Blur and Bloom"
#define DALI_DEMO_STR_TITLE_TEXTURED_MESH "Mesh Texture"
#define DALI_DEMO_STR_TITLE_TEXT_EDITOR "Text Editor"
#define DALI_DEMO_STR_TITLE_TEXT_FIELD "Text Field"
{
const std::string LOGO_PATH( DEMO_IMAGE_DIR "Logo-for-demo.png" );
-const std::string TILE_BACKGROUND(DEMO_IMAGE_DIR "item-background.9.png");
-const std::string TILE_BACKGROUND_ALPHA( DEMO_IMAGE_DIR "demo-tile-texture.9.png" );
-const std::string TILE_FOCUS( DEMO_IMAGE_DIR "tile-focus.9.png" );
// Keyboard focus effect constants.
const float KEYBOARD_FOCUS_ANIMATION_DURATION = 1.0f; ///< The total duration of the keyboard focus animation
const float EFFECT_SNAP_DURATION = 0.66f; ///< Scroll Snap Duration for Effects
const float EFFECT_FLICK_DURATION = 0.5f; ///< Scroll Flick Duration for Effects
const Vector3 ANGLE_CUBE_PAGE_ROTATE(Math::PI * 0.5f, Math::PI * 0.5f, 0.0f);
-const Vector4 TILE_COLOR( 0.4f, 0.6f, 0.9f, 0.6f );
+
const Vector4 BUBBLE_COLOR[] =
{
const float BUBBLE_MIN_Z = -1.0;
const float BUBBLE_MAX_Z = 0.0f;
-// This shader takes a texture.
-// An alpha discard is performed.
-// The shader uses the tiles position within the scroll-view page and the scroll-views rotation position to create a parallax effect.
-const char* FRAGMENT_SHADER_TEXTURED = DALI_COMPOSE_SHADER(
- varying mediump vec2 vTexCoord;
- varying mediump vec3 vIllumination;
- uniform lowp vec4 uColor;
- uniform sampler2D sTexture;
- uniform mediump vec3 uCustomPosition;
-
- void main()
- {
- if( texture2D( sTexture, vTexCoord ).a <= 0.0001 )
- {
- discard;
- }
-
- mediump vec2 wrapTexCoord = vec2( ( vTexCoord.x / 4.0 ) + ( uCustomPosition.x / 4.0 ) + ( uCustomPosition.z / 2.0 ), vTexCoord.y / 4.0 );
- mediump vec4 color = texture2D( sTexture, wrapTexCoord );
- mediump float positionWeight = ( uCustomPosition.y + 0.3 ) * color.r * 2.0;
-
- gl_FragColor = vec4( positionWeight, positionWeight, positionWeight, 0.9 ) * uColor + vec4( uColor.xyz, 0.0 );
- }
-);
/**
* Creates the background image
Stage::GetCurrent().Add( mRootActor );
// Add logo
- ImageView logo = CreateLogo( LOGO_PATH );
+ ImageView logo = ImageView::New( LOGO_PATH );
logo.SetName( "LOGO_IMAGE" );
logo.SetAnchorPoint( AnchorPoint::TOP_CENTER );
logo.SetParentOrigin( Vector3( 0.5f, 0.1f, 0.5f ) );
// Loop to create both actors for the focus highlight effect.
for( unsigned int i = 0; i < FOCUS_ANIMATION_ACTOR_NUMBER; ++i )
{
- mFocusEffect[i].actor = ImageView::New( TILE_FOCUS );
+ mFocusEffect[i].actor = ImageView::New();
+ mFocusEffect[i].actor.SetStyleName( "FocusActor" );
mFocusEffect[i].actor.SetParentOrigin( ParentOrigin::CENTER );
mFocusEffect[i].actor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
mFocusEffect[i].actor.SetInheritScale( false );
Actor DaliTableView::CreateTile( const std::string& name, const std::string& title, const Dali::Vector3& sizeMultiplier, Vector2& position )
{
- Actor focusableTile = Actor::New();
+ Toolkit::ImageView focusableTile = ImageView::New();
+
+ focusableTile.SetStyleName( "DemoTile" );
focusableTile.SetParentOrigin( ParentOrigin::CENTER );
focusableTile.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
focusableTile.SetSizeModeFactor( sizeMultiplier );
// Set the tile to be keyboard focusable
focusableTile.SetKeyboardFocusable( true );
- Toolkit::ImageView tileContent = ImageView::New();
- tileContent.SetParentOrigin( ParentOrigin::CENTER );
- tileContent.SetAnchorPoint( AnchorPoint::CENTER );
- tileContent.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
-
- // Add the image via the property first.
- tileContent.SetProperty( Toolkit::ImageView::Property::IMAGE, TILE_BACKGROUND_ALPHA );
// Register a property with the ImageView. This allows us to inject the scroll-view position into the shader.
Property::Value value = Vector3( 0.0f, 0.0f, 0.0f );
- Property::Index propertyIndex = tileContent.RegisterProperty( "uCustomPosition", value );
-
- // Add a shader to the image (details in shader source).
- Property::Map map;
- Property::Map customShader;
- customShader[ Visual::Shader::Property::FRAGMENT_SHADER ] = FRAGMENT_SHADER_TEXTURED;
- map[ Visual::Property::SHADER ] = customShader;
- tileContent.SetProperty( Toolkit::ImageView::Property::IMAGE, map );
- tileContent.SetColor( TILE_COLOR );
+ Property::Index propertyIndex = focusableTile.RegisterProperty( "uCustomPosition", value );
// We create a constraint to perform a precalculation on the scroll-view X offset
// and pass it to the shader uniform, along with the tile's position.
- Constraint shaderPosition = Constraint::New < Vector3 > ( tileContent, propertyIndex, TileShaderPositionConstraint( mPageWidth, position.x ) );
+ Constraint shaderPosition = Constraint::New < Vector3 > ( focusableTile, propertyIndex, TileShaderPositionConstraint( mPageWidth, position.x ) );
shaderPosition.AddSource( Source( mScrollView, ScrollView::Property::SCROLL_POSITION ) );
shaderPosition.SetRemoveAction( Constraint::Discard );
shaderPosition.Apply();
- focusableTile.Add( tileContent );
+ //focusableTile.Add( tileContent );
// Create an ImageView for the 9-patch border around the tile.
- ImageView borderImage = ImageView::New( TILE_BACKGROUND );
+ ImageView borderImage = ImageView::New();
+ borderImage.SetStyleName("DemoTileBorder");
borderImage.SetAnchorPoint( AnchorPoint::CENTER );
borderImage.SetParentOrigin( ParentOrigin::CENTER );
borderImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
borderImage.SetOpacity( 0.8f );
- tileContent.Add( borderImage );
+ focusableTile.Add( borderImage );
TextLabel label = TextLabel::New();
label.SetAnchorPoint( AnchorPoint::CENTER );
{
float randSize = Random::Range( 10.0f, 400.0f );
int shapeType = static_cast<int>( Random::Range( 0.0f, NUMBER_OF_SHAPE_IMAGES - 1 ) + 0.5f );
- ImageView dfActor = ImageView::New( SHAPE_IMAGE_TABLE[ shapeType ] );
+
+ ImageView dfActor = ImageView::New();
dfActor.SetSize( Vector2( randSize, randSize ) );
dfActor.SetParentOrigin( ParentOrigin::CENTER );
+ // Set the Image URL and the custom shader at the same time
Dali::Property::Map effect = Toolkit::CreateDistanceFieldEffect();
- dfActor.SetProperty( Toolkit::ImageView::Property::IMAGE, effect );
+ Property::Map imageMap;
+ imageMap.Add( ImageVisual::Property::URL, SHAPE_IMAGE_TABLE[ shapeType ] );
+ imageMap.Add( Visual::Property::SHADER, effect );
+ dfActor.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
+
dfActor.SetColor( BUBBLE_COLOR[ i%NUMBER_OF_BUBBLE_COLOR ] );
layer.Add( dfActor );
layer.OnRelayoutSignal().Connect( this, &DaliTableView::InitialiseBackgroundActors );
}
-ImageView DaliTableView::CreateLogo( std::string imagePath )
-{
- ImageView logo = ImageView::New( imagePath );
-
- logo.SetAnchorPoint( AnchorPoint::CENTER );
- logo.SetParentOrigin( ParentOrigin::CENTER );
-
- return logo;
-}
-
bool DaliTableView::PauseBackgroundAnimation()
{
PauseAnimation();
-#ifndef DALI_DEMO_H
-#define DALI_DEMO_H
+#ifndef DALI_DEMO_TABLEVIEW_H
+#define DALI_DEMO_TABLEVIEW_H
/*
* Copyright (c) 2017 Samsung Electronics Co., Ltd.
void AddBackgroundActors( Dali::Actor layer, int count );
/**
- * Creates the logo.
- *
- * @param[in] imagePath The path to the image file to load
- *
- * @return The created image actor
- */
- Dali::Toolkit::ImageView CreateLogo( std::string imagePath );
-
- /**
* Timer handler for ending background animation
*
* @return Return value for timer handler
};
-#endif // DALI_DEMO_H
+#endif // DALI_DEMO_TABLEVIEW_H
"(Chinese)",
"若要重新排列页面,您需要将视图类型更改为可自定义网格。"
},
+ {
+ "ꦧꦱꦗꦮ, basa Jawa",
+ "(Javanese)",
+ "ꦧꦱꦗꦮ ꦕꦫꦗꦮ ꦲꦏ꧀ꦱꦫꦗꦮ ꦲꦤꦕꦫꦏ ꧋ꦱꦧꦼꦤ꧀ꦲꦸꦮꦺꦴꦁꦏꦭꦲꦶꦫꦏꦺꦏꦤ꧀ꦛꦶꦩꦂꦢꦶꦏꦭꦤ꧀ꦢꦂꦧꦺꦩꦂꦠꦧꦠ꧀ꦭꦤ꧀ꦲꦏ꧀ꦲꦏ꧀ꦏꦁꦥꦝ꧉"
+ },
+ {
+ "Basa Sunda, ᮘᮞ ᮞᮥᮔ᮪ᮓ",
+ "(Sundanese)",
+ "ᮃᮊ᮪ᮞᮛ ᮞᮥᮔ᮪ᮓ ᮀᮁᮂᮃᮄᮅᮆᮇᮈᮉᮊᮋᮌᮍᮎᮏᮐᮑᮒᮓᮔᮕᮖᮗᮘᮙᮚᮛᮜᮝᮞᮟᮠᮡᮢᮣᮤᮥᮦᮧᮨᮩ᮪᮫ᮬᮭᮮᮯ᮰᮱᮲᮳᮴᮵᮶᮷᮸᮹ᮺᮻᮼᮽᮾᮿ᳀᳁᳂᳃᳄᳅᳆᳇"
+ },
+ {
+ "isiZulu",
+ "(Zulu)",
+ "Sawubona Mhlaba"
+ },
+ {
+ "isiXhosa",
+ "(Xhosa)",
+ "Molo Lizwe"
+ },
};
- const unsigned int NUMBER_OF_LANGUAGES = 31u;
+ const unsigned int NUMBER_OF_LANGUAGES = 35u;
} // MultiLanguageStrings
return loader.GetPixelData();
}
-/**
- * @deprecated, dont use this anymore
- */
-Dali::Image LoadImage( const char* imagePath,
- Dali::ImageDimensions size = Dali::ImageDimensions(),
- Dali::FittingMode::Type fittingMode = Dali::FittingMode::DEFAULT,
- Dali::SamplingMode::Type samplingMode = Dali::SamplingMode::DEFAULT )
-{
- return Dali::ResourceImage::New( imagePath, size, fittingMode, samplingMode );
-}
-
Dali::Texture LoadTexture( const char* imagePath,
Dali::ImageDimensions size = Dali::ImageDimensions(),
Dali::FittingMode::Type fittingMode = Dali::FittingMode::DEFAULT,
return texture;
}
-/**
- * @brief Load an bitmap resource.
- * @deprecated, dont use this anymore
- *
- * If it is required to scaled-down to no more than the stage dimensions,
- * uses image scaling mode FittingMode::SCALE_TO_FILL to resize the image at
- * load time to cover the entire stage with pixels with no borders,
- * and filter mode BOX_THEN_LINEAR to sample the image with
- * maximum quality.
- */
-
-Dali::Image LoadStageFillingImage( const char* imagePath )
-{
- Dali::Vector2 stageSize = Dali::Stage::GetCurrent().GetSize();
- return LoadImage( imagePath, Dali::ImageDimensions( stageSize.x, stageSize.y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR );
-}
-
Dali::Texture LoadStageFillingTexture( const char* imagePath )
{
Dali::Vector2 stageSize = Dali::Stage::GetCurrent().GetSize();