--- /dev/null
+{
+ "constants":
+ {
+ "CONFIG_SCRIPT_LOG_LEVEL":"NoLogging"
+ },
+ "styles":
+ {
+ "textlabel":
+ {
+ "pointSize":18
+ },
+
+ "textlabelFontSize0":
+ {
+ "pointSize":8
+ },
+ "textlabelFontSize1":
+ {
+ "pointSize":10
+ },
+ "textlabelFontSize2":
+ {
+ "pointSize":15
+ },
+ "textlabelFontSize3":
+ {
+ "pointSize":19
+ },
+ "textlabelFontSize4":
+ {
+ "pointSize":25
+ },
+
+ "textfield":
+ {
+ "pointSize":18,
+ "primaryCursorColor":[0.0,0.72,0.9,1.0],
+ "secondaryCursorColor":[0.0,0.72,0.9,1.0],
+ "cursorWidth":3,
+ "selectionHighlightColor":[0.75,0.96,1.0,1.0],
+ "grabHandleImage" : "{DALI_STYLE_IMAGE_DIR}cursor_handler_drop_center.png",
+ "selectionHandleImageLeft" : {"filename":"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_left.png" },
+ "selectionHandleImageRight": {"filename":"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_right.png" }
+ },
+
+ "textfieldFontSize0":
+ {
+ "pointSize":10
+ },
+ "textfieldFontSize1":
+ {
+ "pointSize":10
+ },
+ "textfieldFontSize2":
+ {
+ "pointSize":10
+ },
+ "textfieldFontSize3":
+ {
+ "pointSize":10
+ },
+ "textfieldFontSize4":
+ {
+ "pointSize":10
+ },
+ "textselectionpopup":
+ {
+ "popupMaxSize":[656,72],
+ "optionDividerSize":[2,0],
+ "popupDividerColor":[0.23,0.72,0.8,0.11],
+ "popupIconColor":[1.0,1.0,1.0,1.0],
+ "popupPressedColor":[0.24,0.72,0.8,0.11],
+ "background": {
+ "rendererType": "nPatch",
+ "imageUrl": "{DALI_IMAGE_DIR}selection-popup-bg.9.png"
+ },
+ "popupFadeInDuration":0.25,
+ "popupFadeOutDuration":0.25
+ },
+ "textselectionpopupbutton":
+ {
+ "label":
+ {
+ "pointSize":8,
+ "fontStyle": { "weight":"light" }
+ }
+ },
+ "textselectiontoolbar":
+ {
+ "enableOvershoot":true,
+ "scrollView":
+ {
+ "overshootAnimationSpeed":360.0,
+ "overshootSize":[720.0,130.0]
+ }
+ },
+ "scrollview":
+ {
+ "overshootEffectColor":"B018",
+ "overshootAnimationSpeed":360.0,
+ "overshootSize":[720.0,130.0]
+ },
+ "itemview":
+ {
+ "overshootEffectColor":"B018",
+ "overshootAnimationSpeed":360.0,
+ "overshootSize":[720.0,130.0]
+ },
+ "texteditor":
+ {
+ "pointSize":18,
+ "primaryCursorColor":[0.0,0.72,0.9,1.0],
+ "secondaryCursorColor":[0.0,0.72,0.9,1.0],
+ "cursorWidth":3,
+ "selectionHighlightColor":[0.75,0.96,1.0,1.0],
+ "grabHandleImage" : "{DALI_STYLE_IMAGE_DIR}cursor_handler_drop_center.png",
+ "selectionHandleImageLeft" : {"filename":"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_left.png" },
+ "selectionHandleImageRight": {"filename":"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_right.png" }
+ },
+ "ComplexControl":
+ {
+ "states":
+ {
+ "NORMAL":
+ {
+ "states":
+ {
+ "SELECTED":
+ {
+ "visuals":
+ {
+ "foregroundVisual":
+ {
+ "visualType":"GRADIENT",
+ "startPosition": [-1, -1],
+ "endPosition": [1, 1],
+ "spreadMethod": "REPEAT",
+ "stopOffset": [0.2, 0.8],
+ "stopColor": [ [ 1,0,0,1], [0,1,0,1] ]
+ }
+ }
+ },
+ "UNSELECTED":
+ {
+ "visuals":
+ {
+ "foregroundVisual":
+ {
+ "visualType":"COLOR",
+ "mixColor": [ 1,0,0,1]
+ }
+ }
+ }
+ },
+ "transitions":
+ {
+ "visualName":"*",
+ "effect":"CROSSFADE",
+ "animator":
+ {
+ "alphaFunction":"EASE_IN_OUT",
+ "duration":0.3
+ }
+ }
+ },
+ "FOCUSED":
+ {
+ "visuals":
+ {
+ "foregroundVisual":
+ {
+ "visualType":"GRADIENT",
+ "startPosition": [-1, -1],
+ "endPosition": [1, 1],
+ "spreadMethod": "REPEAT",
+ "stopOffset": [0.3, 0.9],
+ "stopColor": [ [ 0,0,1,1], [0,1,1,1] ]
+ },
+ "focusVisual":
+ {
+ "visualType":"IMAGE",
+ "url": "focus.png"
+ }
+ },
+ "entryTransition":
+ {
+ "target":"focusVisual",
+ "property":"mixColor",
+ "initialValue":[0,0,0,0],
+ "targetValue":[1,1,1,1],
+ "animator":
+ {
+ "alphaFunction":"EASE_IN_OUT_SINE",
+ "timePeriod":
+ {
+ "duration":0.5,
+ "delay":0
+ }
+ }
+ },
+ "exitTransition":
+ {
+ "target":"focusVisual",
+ "property":"mixColor",
+ "initialValue":[1,1,1,1],
+ "targetValue":[0,0,0,0],
+ "animator":
+ {
+ "alphaFunction":"EASE_IN_OUT_SINE",
+ "timePeriod":
+ {
+ "duration":0.5,
+ "delay":0
+ }
+ }
+ }
+ },
+ "DISABLED":
+ {
+ "visuals":
+ {
+ "foregroundVisual":
+ {
+ "visualType":"COLOR",
+ "mixColor": [1,0,0,1]
+ }
+ }
+ }
+ },
+ "transitions":
+ [
+ {
+ "effect":"CROSSFADE",
+ "animator":
+ {
+ "alphaFunction":"EASE_IN_OUT",
+ "duration":0.3
+ }
+ }
+ ]
+ },
+ "BasicControl":
+ {
+ "states":
+ {
+ "NORMAL":
+ {
+ "visuals":
+ {
+ "foregroundVisual":
+ {
+ "visualType":"GRADIENT",
+ "startPosition": [-1, -1],
+ "endPosition": [1, 1],
+ "spreadMethod": "REPEAT",
+ "stopOffset": [0.2, 0.8],
+ "stopColor": [ [ 1,0,0,1], [0,1,0,1] ]
+ }
+ }
+ },
+ "FOCUSED":
+ {
+ "visuals":
+ {
+ "foregroundVisual":
+ {
+ "visualType":"GRADIENT",
+ "startPosition": [-1, -1],
+ "endPosition": [1, 1],
+ "spreadMethod": "REPEAT",
+ "stopOffset": [0.3, 0.9],
+ "stopColor": [ [ 0,0,1,1], [0,1,1,1] ]
+ },
+ "focusVisual":
+ {
+ "visualType":"IMAGE",
+ "url": "focus.png"
+ }
+ },
+ "entryTransition":
+ {
+ "target":"focusVisual",
+ "property":"mixColor",
+ "initialValue":[0,0,0,0],
+ "targetValue":[1,1,1,1],
+ "animator":
+ {
+ "alphaFunction":"EASE_IN_OUT_SINE",
+ "timePeriod":
+ {
+ "duration":0.5,
+ "delay":0
+ }
+ }
+ },
+ "exitTransition":
+ {
+ "target":"focusVisual",
+ "property":"mixColor",
+ "initialValue":[1,1,1,1],
+ "targetValue":[0,0,0,0],
+ "animator":
+ {
+ "alphaFunction":"EASE_IN_OUT_SINE",
+ "timePeriod":
+ {
+ "duration":0.5,
+ "delay":0
+ }
+ }
+ }
+ },
+ "DISABLED":
+ {
+ "visuals":
+ {
+ "foregroundVisual":
+ {
+ "visualType":"COLOR",
+ "mixColor": [1,0,0,1]
+ }
+ }
+ }
+ },
+ "transitions":
+ [
+ {
+ "effect":"CROSSFADE",
+ "animator":
+ {
+ "alphaFunction":"EASE_IN_OUT",
+ "duration":0.3
+ }
+ }
+ ]
+ }
+ }
+}
#include <dali/devel-api/adaptor-framework/style-monitor.h>
#include <iostream>
+#include <fstream>
+#include <sstream>
#include <stdlib.h>
#include <dali-toolkit-test-suite-utils.h>
#include <dali-toolkit/dali-toolkit.h>
namespace
{
-const char* defaultTheme =
-"{\n"
-" \"constants\":\n"
-" {\n"
-" \"CONFIG_SCRIPT_LOG_LEVEL\":\"NoLogging\"\n"
-" },\n"
-" \"styles\":\n"
-" {\n"
-" \"textlabel\":\n"
-" {\n"
-" \"pointSize\":18\n"
-" },\n"
-"\n"
-" \"textlabelFontSize0\":\n"
-" {\n"
-" \"pointSize\":8\n"
-" },\n"
-" \"textlabelFontSize1\":\n"
-" {\n"
-" \"pointSize\":10\n"
-" },\n"
-" \"textlabelFontSize2\":\n"
-" {\n"
-" \"pointSize\":15\n"
-" },\n"
-" \"textlabelFontSize3\":\n"
-" {\n"
-" \"pointSize\":19\n"
-" },\n"
-" \"textlabelFontSize4\":\n"
-" {\n"
-" \"pointSize\":25\n"
-" },\n"
-"\n"
-" \"textfield\":\n"
-" {\n"
-" \"pointSize\":18,\n"
-" \"primaryCursorColor\":[0.0,0.72,0.9,1.0],\n"
-" \"secondaryCursorColor\":[0.0,0.72,0.9,1.0],\n"
-" \"cursorWidth\":3,\n"
-" \"selectionHighlightColor\":[0.75,0.96,1.0,1.0],\n"
-" \"grabHandleImage\" : \"{DALI_STYLE_IMAGE_DIR}cursor_handler_drop_center.png\",\n"
-" \"selectionHandleImageLeft\" : {\"filename\":\"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_left.png\" },\n"
-" \"selectionHandleImageRight\": {\"filename\":\"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_right.png\" }\n"
-" },\n"
-"\n"
-" \"textfieldFontSize0\":\n"
-" {\n"
-" \"pointSize\":10\n"
-" },\n"
-" \"textfieldFontSize1\":\n"
-" {\n"
-" \"pointSize\":10\n"
-" },\n"
-" \"textfieldFontSize2\":\n"
-" {\n"
-" \"pointSize\":10\n"
-" },\n"
-" \"textfieldFontSize3\":\n"
-" {\n"
-" \"pointSize\":10\n"
-" },\n"
-" \"textfieldFontSize4\":\n"
-" {\n"
-" \"pointSize\":10\n"
-" },\n"
-" \"textselectionpopup\":\n"
-" {\n"
-" \"popupMaxSize\":[656,72],\n"
-" \"optionDividerSize\":[2,0],\n"
-" \"popupDividerColor\":[0.23,0.72,0.8,0.11],\n"
-" \"popupIconColor\":[1.0,1.0,1.0,1.0],\n"
-" \"popupPressedColor\":[0.24,0.72,0.8,0.11],\n"
-" \"background\": {\n"
-" \"rendererType\": \"nPatch\",\n"
-" \"imageUrl\": \"{DALI_IMAGE_DIR}selection-popup-bg.9.png\"\n"
-" },\n"
-" \"popupFadeInDuration\":0.25,\n"
-" \"popupFadeOutDuration\":0.25\n"
-" },\n"
-" \"textselectionpopupbutton\":\n"
-" {\n"
-" \"label\":\n"
-" {\n"
-" \"pointSize\":8,\n"
-" \"fontStyle\":\"{\\\\""weight\\\\"":\\\\""light\\\\""}\"\n"
-" }\n"
-" },\n"
-" \"textselectiontoolbar\":\n"
-" {\n"
-" \"enableOvershoot\":true,\n"
-" \"scrollView\":\n"
-" {\n"
-" \"overshootAnimationSpeed\":360.0,\n"
-" \"overshootSize\":[720.0,130.0]\n"
-" }\n"
-" },\n"
-" \"scrollview\":\n"
-" {\n"
-" \"overshootEffectColor\":\"B018\",\n"
-" \"overshootAnimationSpeed\":360.0,\n"
-" \"overshootSize\":[720.0,130.0]\n"
-" },\n"
-" \"itemview\":\n"
-" {\n"
-" \"overshootEffectColor\":\"B018\",\n"
-" \"overshootAnimationSpeed\":360.0,\n"
-" \"overshootSize\":[720.0,130.0]\n"
-" },\n"
-" \"texteditor\":\n"
-" {\n"
-" \"pointSize\":18,\n"
-" \"primaryCursorColor\":[0.0,0.72,0.9,1.0],\n"
-" \"secondaryCursorColor\":[0.0,0.72,0.9,1.0],\n"
-" \"cursorWidth\":3,\n"
-" \"selectionHighlightColor\":[0.75,0.96,1.0,1.0],\n"
-" \"grabHandleImage\" : \"{DALI_STYLE_IMAGE_DIR}cursor_handler_drop_center.png\",\n"
-" \"selectionHandleImageLeft\" : {\"filename\":\"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_left.png\" },\n"
-" \"selectionHandleImageRight\": {\"filename\":\"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_right.png\" }\n"
-" },\n"
-" \"ComplexControl\":\n"
-" {\n"
-" \"states\":\n"
-" {\n"
-" \"NORMAL\":\n"
-" {\n"
-" \"states\":\n"
-" {\n"
-" \"SELECTED\":\n"
-" {\n"
-" \"visuals\":\n"
-" {\n"
-" \"foregroundVisual\":\n"
-" {\n"
-" \"visualType\":\"GRADIENT\",\n"
-" \"startPosition\": [-1, -1],\n"
-" \"endPosition\": [1, 1],\n"
-" \"spreadMethod\": \"REPEAT\",\n"
-" \"stopOffset\": [0.2, 0.8],\n"
-" \"stopColor\": [ [ 1,0,0,1], [0,1,0,1] ]\n"
-" }\n"
-" }\n"
-" },\n"
-" \"UNSELECTED\":\n"
-" {\n"
-" \"visuals\":\n"
-" {\n"
-" \"foregroundVisual\":\n"
-" {\n"
-" \"visualType\":\"COLOR\",\n"
-" \"mixColor\": [ 1,0,0,1]\n"
-" }\n"
-" }\n"
-" }\n"
-" },\n"
-" \"transitions\":\n"
-" {\n"
-" \"visualName\":\"*\",\n"
-" \"effect\":\"CROSSFADE\",\n"
-" \"animator\":\n"
-" {\n"
-" \"alphaFunction\":\"EASE_IN_OUT\",\n"
-" \"duration\":0.3\n"
-" }\n"
-" }\n"
-" },\n"
-" \"FOCUSED\":\n"
-" {\n"
-" \"visuals\":\n"
-" {\n"
-" \"foregroundVisual\":\n"
-" {\n"
-" \"visualType\":\"GRADIENT\",\n"
-" \"startPosition\": [-1, -1],\n"
-" \"endPosition\": [1, 1],\n"
-" \"spreadMethod\": \"REPEAT\",\n"
-" \"stopOffset\": [0.3, 0.9],\n"
-" \"stopColor\": [ [ 0,0,1,1], [0,1,1,1] ]\n"
-" },\n"
-" \"focusVisual\":\n"
-" {\n"
-" \"visualType\":\"IMAGE\",\n"
-" \"url\": \"focus.png\"\n"
-" }\n"
-" },\n"
-" \"entryTransition\":\n"
-" {\n"
-" \"target\":\"focusVisual\",\n"
-" \"property\":\"mixColor\",\n"
-" \"initialValue\":[0,0,0,0],\n"
-" \"targetValue\":[1,1,1,1],\n"
-" \"animator\":\n"
-" {\n"
-" \"alphaFunction\":\"EASE_IN_OUT_SINE\",\n"
-" \"timePeriod\": \n"
-" {\n"
-" \"duration\":0.5,\n"
-" \"delay\":0\n"
-" }\n"
-" }\n"
-" },\n"
-" \"exitTransition\":\n"
-" {\n"
-" \"target\":\"focusVisual\",\n"
-" \"property\":\"mixColor\",\n"
-" \"initialValue\":[1,1,1,1],\n"
-" \"targetValue\":[0,0,0,0],\n"
-" \"animator\":\n"
-" {\n"
-" \"alphaFunction\":\"EASE_IN_OUT_SINE\",\n"
-" \"timePeriod\": \n"
-" {\n"
-" \"duration\":0.5,\n"
-" \"delay\":0\n"
-" }\n"
-" }\n"
-" }\n"
-" },\n"
-" \"DISABLED\":\n"
-" {\n"
-" \"visuals\":\n"
-" {\n"
-" \"foregroundVisual\":\n"
-" {\n"
-" \"visualType\":\"COLOR\",\n"
-" \"mixColor\": [1,0,0,1]\n"
-" }\n"
-" }\n"
-" }\n"
-" },\n"
-" \"transitions\":\n"
-" [\n"
-" {\n"
-" \"effect\":\"CROSSFADE\",\n"
-" \"animator\":\n"
-" {\n"
-" \"alphaFunction\":\"EASE_IN_OUT\",\n"
-" \"duration\":0.3\n"
-" }\n"
-" }\n"
-" ]\n"
-" },\n"
-" \"BasicControl\":\n"
-" {\n"
-" \"states\":\n"
-" {\n"
-" \"NORMAL\":\n"
-" {\n"
-" \"visuals\":\n"
-" {\n"
-" \"foregroundVisual\":\n"
-" {\n"
-" \"visualType\":\"GRADIENT\",\n"
-" \"startPosition\": [-1, -1],\n"
-" \"endPosition\": [1, 1],\n"
-" \"spreadMethod\": \"REPEAT\",\n"
-" \"stopOffset\": [0.2, 0.8],\n"
-" \"stopColor\": [ [ 1,0,0,1], [0,1,0,1] ]\n"
-" }\n"
-" }\n"
-" },\n"
-" \"FOCUSED\":\n"
-" {\n"
-" \"visuals\":\n"
-" {\n"
-" \"foregroundVisual\":\n"
-" {\n"
-" \"visualType\":\"GRADIENT\",\n"
-" \"startPosition\": [-1, -1],\n"
-" \"endPosition\": [1, 1],\n"
-" \"spreadMethod\": \"REPEAT\",\n"
-" \"stopOffset\": [0.3, 0.9],\n"
-" \"stopColor\": [ [ 0,0,1,1], [0,1,1,1] ]\n"
-" },\n"
-" \"focusVisual\":\n"
-" {\n"
-" \"visualType\":\"IMAGE\",\n"
-" \"url\": \"focus.png\"\n"
-" }\n"
-" },\n"
-" \"entryTransition\":\n"
-" {\n"
-" \"target\":\"focusVisual\",\n"
-" \"property\":\"mixColor\",\n"
-" \"initialValue\":[0,0,0,0],\n"
-" \"targetValue\":[1,1,1,1],\n"
-" \"animator\":\n"
-" {\n"
-" \"alphaFunction\":\"EASE_IN_OUT_SINE\",\n"
-" \"timePeriod\": \n"
-" {\n"
-" \"duration\":0.5,\n"
-" \"delay\":0\n"
-" }\n"
-" }\n"
-" },\n"
-" \"exitTransition\":\n"
-" {\n"
-" \"target\":\"focusVisual\",\n"
-" \"property\":\"mixColor\",\n"
-" \"initialValue\":[1,1,1,1],\n"
-" \"targetValue\":[0,0,0,0],\n"
-" \"animator\":\n"
-" {\n"
-" \"alphaFunction\":\"EASE_IN_OUT_SINE\",\n"
-" \"timePeriod\": \n"
-" {\n"
-" \"duration\":0.5,\n"
-" \"delay\":0\n"
-" }\n"
-" }\n"
-" }\n"
-" },\n"
-" \"DISABLED\":\n"
-" {\n"
-" \"visuals\":\n"
-" {\n"
-" \"foregroundVisual\":\n"
-" {\n"
-" \"visualType\":\"COLOR\",\n"
-" \"mixColor\": [1,0,0,1]\n"
-" }\n"
-" }\n"
-" }\n"
-" },\n"
-" \"transitions\":\n"
-" [\n"
-" {\n"
-" \"effect\":\"CROSSFADE\",\n"
-" \"animator\":\n"
-" {\n"
-" \"alphaFunction\":\"EASE_IN_OUT\",\n"
-" \"duration\":0.3\n"
-" }\n"
-" }\n"
-" ]\n"
-" }\n"
-" }\n"
-"}\n";
+std::string defaultTheme;
} // anonymous namespace
void dali_style_manager_startup(void)
{
test_return_value = TET_UNDEF;
+
+ std::ifstream t("src/dali-toolkit-styling/default-theme.json");
+ defaultTheme = std::string((std::istreambuf_iterator<char>(t)), std::istreambuf_iterator<char>());
}
void dali_style_manager_cleanup(void)
}
-int UtcDaliStyleManagerVisualTransitionParsing(void)
+int UtcDaliStyleManagerSetState01(void)
{
tet_infoline("Instantiate dummy control and test state/visual/transition capture" );
Test::StyleMonitor::SetThemeFileOutput( DALI_STYLE_DIR "dali-toolkit-default-theme.json",
END_TEST;
}
-
-int UtcDaliStyleManagerVisualTransitionParsing02(void)
+int UtcDaliStyleManagerSetState02(void)
{
tet_infoline("Instantiate dummy control and test state/visual/transition capture" );
Test::StyleMonitor::SetThemeFileOutput( DALI_STYLE_DIR "dali-toolkit-default-theme.json",
StyleManager styleManager = StyleManager::Get();
DummyControl actor = DummyControl::New(true);
- actor.SetProperty(DevelControl::Property::STATE, "FOCUSED");
-
- actor.SetStyleName("ComplexControl");
+ actor.SetStyleName("BasicControl");
Stage::GetCurrent().Add(actor);
Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
+ int state = actor.GetProperty<int>( DevelControl::Property::STATE );
+ DALI_TEST_EQUALS( state, (int) DevelControl::NORMAL, TEST_LOCATION );
+
DALI_TEST_EQUALS(dummyImpl.IsVisualEnabled(DummyControl::Property::FOREGROUND_VISUAL), true, TEST_LOCATION);
Visual::Base visual1 = dummyImpl.GetVisual(DummyControl::Property::FOREGROUND_VISUAL);
+
+ actor.SetProperty( DevelControl::Property::STATE,
+ Property::Map().Add( "state", "FOCUSED" ).Add("withTransitions", false));
+
+ state = actor.GetProperty<int>( DevelControl::Property::STATE );
+ DALI_TEST_EQUALS( state, (int) DevelControl::FOCUSED, TEST_LOCATION );
+
+ DALI_TEST_EQUALS(dummyImpl.IsVisualEnabled(DummyControl::Property::FOREGROUND_VISUAL), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(dummyImpl.IsVisualEnabled(DummyControl::Property::FOCUS_VISUAL), true, TEST_LOCATION);
+
+ Visual::Base visual2 = dummyImpl.GetVisual(DummyControl::Property::FOREGROUND_VISUAL);
+ DALI_TEST_CHECK( visual1 != visual2 );
+
+ actor.SetProperty( DevelControl::Property::STATE,
+ Property::Map().Add( "state", "DISABLED" ).Add("withTransitions", false));
+
+ state = actor.GetProperty<int>( DevelControl::Property::STATE );
+ DALI_TEST_EQUALS( state, (int) DevelControl::DISABLED, TEST_LOCATION );
+
+ DALI_TEST_EQUALS(dummyImpl.IsVisualEnabled(DummyControl::Property::FOREGROUND_VISUAL), true, TEST_LOCATION);
+
+ Visual::Base visual3 = dummyImpl.GetVisual(DummyControl::Property::FOREGROUND_VISUAL);
+ Visual::Base focusVisual = dummyImpl.GetVisual(DummyControl::Property::FOCUS_VISUAL);
+ DALI_TEST_CHECK( !focusVisual );
+ DALI_TEST_EQUALS(dummyImpl.IsVisualEnabled(DummyControl::Property::FOCUS_VISUAL), false, TEST_LOCATION);
+
+ DALI_TEST_CHECK( visual1 != visual3 );
+ DALI_TEST_CHECK( visual2 != visual3 );
+
+ actor.SetProperty( DevelControl::Property::STATE,
+ Property::Map().Add( "state", "NORMAL" ).Add("withTransitions", false));
+
+ state = actor.GetProperty<int>( DevelControl::Property::STATE );
+ DALI_TEST_EQUALS( state, (int) DevelControl::NORMAL, TEST_LOCATION );
+
+ DALI_TEST_EQUALS(dummyImpl.IsVisualEnabled(DummyControl::Property::FOREGROUND_VISUAL), true, TEST_LOCATION);
+
+ visual1 = dummyImpl.GetVisual(DummyControl::Property::FOREGROUND_VISUAL);
DALI_TEST_CHECK( visual1 );
- Property::Map map;
- visual1.CreatePropertyMap( map );
- Property::Value* value = map.Find( Visual::Property::TYPE );
- DALI_TEST_CHECK( value );
- int visualType;
- value->Get( visualType );
+ focusVisual = dummyImpl.GetVisual(DummyControl::Property::FOCUS_VISUAL);
+ DALI_TEST_CHECK( !focusVisual );
+ DALI_TEST_EQUALS(dummyImpl.IsVisualEnabled(DummyControl::Property::FOCUS_VISUAL), false, TEST_LOCATION);
+
+
+ END_TEST;
+}
+
+
+int UtcDaliStyleManagerSetSubState(void)
+{
+ tet_infoline("Instantiate dummy control and test state/visual/transition capture" );
+ Test::StyleMonitor::SetThemeFileOutput( DALI_STYLE_DIR "dali-toolkit-default-theme.json",
+ defaultTheme );
+
+ ToolkitTestApplication application;
+
+ StyleChangedSignalChecker styleChangedSignalHandler;
+ Dali::StyleMonitor styleMonitor = Dali::StyleMonitor::Get();
+ StyleManager styleManager = StyleManager::Get();
+
+ DummyControl actor = DummyControl::New(true);
+ actor.SetProperty(DevelControl::Property::STATE, "NORMAL");
+ actor.SetProperty(DevelControl::Property::SUB_STATE, "SELECTED");
+ actor.SetStyleName("ComplexControl");
+ Stage::GetCurrent().Add(actor);
+
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
+
+ {
+ DALI_TEST_EQUALS(dummyImpl.IsVisualEnabled(DummyControl::Property::FOREGROUND_VISUAL), true, TEST_LOCATION);
+ Visual::Base visual = dummyImpl.GetVisual(DummyControl::Property::FOREGROUND_VISUAL);
+ DALI_TEST_CHECK( visual );
+ Property::Map map;
+ visual.CreatePropertyMap( map );
+ Property::Value* value = map.Find( Visual::Property::TYPE );
+ DALI_TEST_CHECK( value );
+
+ int visualType;
+ value->Get( visualType );
+ DALI_TEST_EQUALS( visualType, (int)Toolkit::Visual::GRADIENT, TEST_LOCATION );
+ }
+
+ actor.SetProperty(DevelControl::Property::SUB_STATE, "UNSELECTED");
+
+ {
+ DALI_TEST_EQUALS(dummyImpl.IsVisualEnabled(DummyControl::Property::FOREGROUND_VISUAL), true, TEST_LOCATION);
+ Visual::Base visual = dummyImpl.GetVisual(DummyControl::Property::FOREGROUND_VISUAL);
+ DALI_TEST_CHECK( visual );
+ Property::Map map;
+ visual.CreatePropertyMap( map );
+ Property::Value* value = map.Find( Visual::Property::TYPE );
+ DALI_TEST_CHECK( value );
+
+ int visualType;
+ value->Get( visualType );
+ DALI_TEST_EQUALS( visualType, (int)Toolkit::Visual::COLOR, TEST_LOCATION );
+ }
- DALI_TEST_EQUALS( visualType, (int)Toolkit::Visual::GRADIENT, TEST_LOCATION );
+ actor.SetProperty(DevelControl::Property::SUB_STATE, "SELECTED");
+ {
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
+ DALI_TEST_EQUALS(dummyImpl.IsVisualEnabled(DummyControl::Property::FOREGROUND_VISUAL), true, TEST_LOCATION);
+ Visual::Base visual = dummyImpl.GetVisual(DummyControl::Property::FOREGROUND_VISUAL);
+ DALI_TEST_CHECK( visual );
+ Property::Map map;
+ visual.CreatePropertyMap( map );
+ Property::Value* value = map.Find( Visual::Property::TYPE );
+ DALI_TEST_CHECK( value );
+
+ int visualType;
+ value->Get( visualType );
+ DALI_TEST_EQUALS( visualType, (int)Toolkit::Visual::GRADIENT, TEST_LOCATION );
+ }
END_TEST;
}
DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == Actor());
DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == first);
- DALI_TEST_EQUALS(first.GetProperty<std::string>(DevelControl::Property::STATE), "FOCUSED", TEST_LOCATION );
+ DALI_TEST_EQUALS(first.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::FOCUSED, TEST_LOCATION );
focusChangedCallback.Reset();
// Move the focus towards right
DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == first);
DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == second);
- DALI_TEST_EQUALS(first.GetProperty<std::string>(DevelControl::Property::STATE), "NORMAL", TEST_LOCATION );
- DALI_TEST_EQUALS(second.GetProperty<std::string>(DevelControl::Property::STATE), "FOCUSED", TEST_LOCATION );
+ DALI_TEST_EQUALS(first.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
+ DALI_TEST_EQUALS(second.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::FOCUSED, TEST_LOCATION );
focusChangedCallback.Reset();
// Move the focus towards up
DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == second);
DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == first);
- DALI_TEST_EQUALS(first.GetProperty<std::string>(DevelControl::Property::STATE), "FOCUSED", TEST_LOCATION );
- DALI_TEST_EQUALS(second.GetProperty<std::string>(DevelControl::Property::STATE), "NORMAL", TEST_LOCATION );
+ DALI_TEST_EQUALS(first.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::FOCUSED, TEST_LOCATION );
+ DALI_TEST_EQUALS(second.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
focusChangedCallback.Reset();
DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == first);
DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == second);
- DALI_TEST_EQUALS(first.GetProperty<std::string>(DevelControl::Property::STATE), "NORMAL", TEST_LOCATION );
- DALI_TEST_EQUALS(second.GetProperty<std::string>(DevelControl::Property::STATE), "FOCUSED", TEST_LOCATION );
+ DALI_TEST_EQUALS(first.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
+ DALI_TEST_EQUALS(second.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::FOCUSED, TEST_LOCATION );
focusChangedCallback.Reset();
DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == second);
DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == fourth);
- DALI_TEST_EQUALS(first.GetProperty<std::string>(DevelControl::Property::STATE), "NORMAL", TEST_LOCATION );
- DALI_TEST_EQUALS(second.GetProperty<std::string>(DevelControl::Property::STATE), "NORMAL", TEST_LOCATION );
- DALI_TEST_EQUALS(third.GetProperty<std::string>(DevelControl::Property::STATE), "NORMAL", TEST_LOCATION );
- DALI_TEST_EQUALS(fourth.GetProperty<std::string>(DevelControl::Property::STATE), "FOCUSED", TEST_LOCATION );
+ DALI_TEST_EQUALS(first.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
+ DALI_TEST_EQUALS(second.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
+ DALI_TEST_EQUALS(third.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
+ DALI_TEST_EQUALS(fourth.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::FOCUSED, TEST_LOCATION );
focusChangedCallback.Reset();
DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == fourth);
DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == third);
- DALI_TEST_EQUALS(first.GetProperty<std::string>(DevelControl::Property::STATE), "NORMAL", TEST_LOCATION );
- DALI_TEST_EQUALS(second.GetProperty<std::string>(DevelControl::Property::STATE), "NORMAL", TEST_LOCATION );
- DALI_TEST_EQUALS(third.GetProperty<std::string>(DevelControl::Property::STATE), "FOCUSED", TEST_LOCATION );
- DALI_TEST_EQUALS(fourth.GetProperty<std::string>(DevelControl::Property::STATE), "NORMAL", TEST_LOCATION );
+ DALI_TEST_EQUALS(first.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
+ DALI_TEST_EQUALS(second.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
+ DALI_TEST_EQUALS(third.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::FOCUSED, TEST_LOCATION );
+ DALI_TEST_EQUALS(fourth.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
focusChangedCallback.Reset();
DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == third);
DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == first);
- DALI_TEST_EQUALS(first.GetProperty<std::string>(DevelControl::Property::STATE), "FOCUSED", TEST_LOCATION );
- DALI_TEST_EQUALS(second.GetProperty<std::string>(DevelControl::Property::STATE), "NORMAL", TEST_LOCATION );
- DALI_TEST_EQUALS(third.GetProperty<std::string>(DevelControl::Property::STATE), "NORMAL", TEST_LOCATION );
- DALI_TEST_EQUALS(fourth.GetProperty<std::string>(DevelControl::Property::STATE), "NORMAL", TEST_LOCATION );
+ DALI_TEST_EQUALS(first.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::FOCUSED, TEST_LOCATION );
+ DALI_TEST_EQUALS(second.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
+ DALI_TEST_EQUALS(third.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
+ DALI_TEST_EQUALS(fourth.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
focusChangedCallback.Reset();
// Move the focus towards left. The focus move will fail as no way to move it upwards
DALI_TEST_CHECK(preFocusChangeCallback.mCurrentFocusedActor == first);
DALI_TEST_CHECK(preFocusChangeCallback.mProposedActorToFocus == Actor());
DALI_TEST_CHECK(preFocusChangeCallback.mDirection == Control::KeyboardFocus::LEFT);
- DALI_TEST_EQUALS(first.GetProperty<std::string>(DevelControl::Property::STATE), "FOCUSED", TEST_LOCATION );
- DALI_TEST_EQUALS(second.GetProperty<std::string>(DevelControl::Property::STATE), "NORMAL", TEST_LOCATION );
- DALI_TEST_EQUALS(third.GetProperty<std::string>(DevelControl::Property::STATE), "NORMAL", TEST_LOCATION );
- DALI_TEST_EQUALS(fourth.GetProperty<std::string>(DevelControl::Property::STATE), "NORMAL", TEST_LOCATION );
+ DALI_TEST_EQUALS(first.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::FOCUSED, TEST_LOCATION );
+ DALI_TEST_EQUALS(second.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
+ DALI_TEST_EQUALS(third.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
+ DALI_TEST_EQUALS(fourth.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
preFocusChangeCallback.Reset();
DALI_TEST_CHECK(!focusChangedCallback.mSignalVerified);
DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == first);
DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == fourth);
- DALI_TEST_EQUALS(first.GetProperty<std::string>(DevelControl::Property::STATE), "NORMAL", TEST_LOCATION );
- DALI_TEST_EQUALS(second.GetProperty<std::string>(DevelControl::Property::STATE), "NORMAL", TEST_LOCATION );
- DALI_TEST_EQUALS(third.GetProperty<std::string>(DevelControl::Property::STATE), "NORMAL", TEST_LOCATION );
- DALI_TEST_EQUALS(fourth.GetProperty<std::string>(DevelControl::Property::STATE), "FOCUSED", TEST_LOCATION );
+ DALI_TEST_EQUALS(first.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
+ DALI_TEST_EQUALS(second.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
+ DALI_TEST_EQUALS(third.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
+ DALI_TEST_EQUALS(fourth.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::FOCUSED, TEST_LOCATION );
focusChangedCallback.Reset();
// Clear the focus
manager.ClearFocus();
- DALI_TEST_EQUALS(first.GetProperty<std::string>(DevelControl::Property::STATE), "NORMAL", TEST_LOCATION );
- DALI_TEST_EQUALS(second.GetProperty<std::string>(DevelControl::Property::STATE), "NORMAL", TEST_LOCATION );
- DALI_TEST_EQUALS(third.GetProperty<std::string>(DevelControl::Property::STATE), "NORMAL", TEST_LOCATION );
- DALI_TEST_EQUALS(fourth.GetProperty<std::string>(DevelControl::Property::STATE), "NORMAL", TEST_LOCATION );
+ DALI_TEST_EQUALS(first.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
+ DALI_TEST_EQUALS(second.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
+ DALI_TEST_EQUALS(third.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
+ DALI_TEST_EQUALS(fourth.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
END_TEST;
const StylePtr Builder::GetStyle( const std::string& styleName )
{
- const StylePtr* style = mStyles.FindCaseInsensitiveC( styleName );
+ const StylePtr* style = mStyles.FindConst( styleName );
if( style==NULL )
{
StylePtr* matchedStyle = NULL;
if( styleName )
{
- matchedStyle = mStyles.FindCaseInsensitive( styleName );
+ matchedStyle = mStyles.Find( styleName );
if( ! matchedStyle )
{
OptionalChild styleNodes = IsChild(root, KEYNAME_STYLES);
continue;
}
- StylePtr* stylePtr = style->subStates.FindCaseInsensitive( stateName );
+ StylePtr* stylePtr = style->subStates.Find( stateName );
if( stylePtr )
{
StylePtr style(*stylePtr);
Dali::Property::Value property(Property::MAP);
if( DeterminePropertyFromNode( visual.second, Property::MAP, property, replacements ) )
{
- Property::Map* mapPtr = style->visuals.FindCaseInsensitive( visual.first );
+ Property::Map* mapPtr = style->visuals.Find( visual.first );
if( mapPtr )
{
// Override existing visuals
mapPtr->Clear();
- mapPtr->Merge(*property.GetMap());
+ mapPtr->Merge( *property.GetMap() );
}
else
{
}
else if( key == KEYNAME_ENTRY_TRANSITION )
{
- Dali::Property::Value property(Property::MAP);
- if( DeterminePropertyFromNode( keyValue.second, Property::MAP, property, replacements ) )
- {
- style->entryTransition = Toolkit::TransitionData::New( *property.GetMap() );
- }
+ RecordTransitionData( keyValue, style->entryTransition, replacements );
}
else if( key == KEYNAME_EXIT_TRANSITION )
{
- Dali::Property::Value property(Property::MAP);
- if( DeterminePropertyFromNode( keyValue.second, Property::MAP, property, replacements ) )
- {
- style->exitTransition = Toolkit::TransitionData::New( *property.GetMap() );
- }
+ RecordTransitionData( keyValue, style->exitTransition, replacements );
}
else if( key == KEYNAME_TRANSITIONS )
{
- //@todo add new transitions to style.transitions
- // override existing transitions. A transition matches on target & property name
- const TreeNode& node = keyValue.second;
- if( node.GetType() == TreeNode::ARRAY )
- {
- Dali::Property::Value property(Property::ARRAY);
- if( DeterminePropertyFromNode( node, Property::ARRAY, property, replacements ) )
- {
- style->transitions = *property.GetArray();
- }
- }
- else if( node.GetType() == TreeNode::OBJECT )
- {
- Dali::Property::Value property(Property::MAP);
- if( DeterminePropertyFromNode( node, Property::MAP, property, replacements ) )
- {
- Property::Array propertyArray;
- propertyArray.Add( property );
- style->transitions = propertyArray;
- }
- }
- else
- {
- DALI_LOG_WARNING( "RecordStyle() Node \"%s\" is not a JSON array or object\n", key.c_str() );
- }
+ RecordTransitions( keyValue, style->transitions, replacements );
}
else if( key == KEYNAME_TYPE ||
key == KEYNAME_ACTORS ||
}
}
+void Builder::RecordTransitions(
+ const TreeNode::KeyNodePair& keyValue,
+ Property::Array& value,
+ const Replacement& replacements )
+{
+ //@todo add new transitions to style.transitions
+ // override existing transitions. A transition matches on target & property name
+ const TreeNode& node = keyValue.second;
+ if( node.GetType() == TreeNode::ARRAY )
+ {
+ Dali::Property::Value property(Property::ARRAY);
+ if( DeterminePropertyFromNode( node, Property::ARRAY, property, replacements ) )
+ {
+ value = *property.GetArray();
+ }
+ }
+ else if( node.GetType() == TreeNode::OBJECT )
+ {
+ Dali::Property::Value property(Property::MAP);
+ if( DeterminePropertyFromNode( node, Property::MAP, property, replacements ) )
+ {
+ Property::Array propertyArray;
+ propertyArray.Add( property );
+ value = propertyArray;
+ }
+ }
+ else
+ {
+ DALI_LOG_WARNING( "RecordStyle() Node \"%s\" is not a JSON array or object\n", keyValue.first );
+ }
+}
+
+void Builder::RecordTransitionData(
+ const TreeNode::KeyNodePair& keyValue,
+ Toolkit::TransitionData& transitionData,
+ const Replacement& replacements )
+{
+ const TreeNode& node = keyValue.second;
+ if( node.GetType() == TreeNode::ARRAY )
+ {
+ Dali::Property::Value property(Property::ARRAY);
+ if( DeterminePropertyFromNode( keyValue.second, Property::ARRAY, property, replacements ) )
+ {
+ transitionData = Toolkit::TransitionData::New( *property.GetArray() );
+ }
+ }
+ else if( node.GetType() == TreeNode::OBJECT )
+ {
+ Dali::Property::Value property(Property::MAP);
+ if( DeterminePropertyFromNode( keyValue.second, Property::MAP, property, replacements ) )
+ {
+ transitionData = Toolkit::TransitionData::New( *property.GetMap() );
+ }
+ }
+}
+
+
// Set properties from node on handle.
void Builder::ApplyProperties( const TreeNode& root, const TreeNode& node,
Dali::Handle& handle, const Replacement& constant )
Dali::Handle& handle,
const Replacement& replacements );
+ void RecordTransitions( const TreeNode::KeyNodePair& keyValue,
+ Property::Array& transitions,
+ const Replacement& replacements );
+
+ void RecordTransitionData( const TreeNode::KeyNodePair& keyNode,
+ Toolkit::TransitionData& transitionData,
+ const Replacement& replacements );
+
void ApplyProperties( const TreeNode& root,
const TreeNode& node,
Dali::Handle& handle,
/**
* Find the element in the dictionary pointed at by key, and
- * return a pointer to it, or NULL.
- */
- EntryType* Find( const std::string& key ) const
- {
- EntryType* result=NULL;
-
- if( ! key.empty() )
- {
- for( typename Elements::iterator iter = container.begin(); iter != container.end(); ++iter )
- {
- if( iter->key == key )
- {
- result = &(iter->entry);
- break;
- }
- }
- }
- return result;
- }
-
- /**
- * Find the element in the dictionary pointed at by key, and
- * return a pointer to it, or NULL
- */
- EntryType* Find( const char* key ) const
- {
- if( key != NULL )
- {
- std::string theKey(key);
- return Find(theKey);
- }
- return NULL;
- }
-
- /**
- * Find the element in the dictionary pointed at by key using a case
* insensitive search, and return a const pointer to it, or NULL
*/
- const EntryType* FindCaseInsensitiveC( const std::string& key ) const
+ const EntryType* FindConst( const std::string& key ) const
{
if( ! key.empty() )
{
* Find the element in the dictionary pointed at by key using a case
* insensitive search, and return a non-const pointer to it, or NULL
*/
- EntryType* FindCaseInsensitive( const std::string& key ) const
+ EntryType* Find( const std::string& key ) const
{
EntryType* result = NULL;
if( ! key.empty() )
* Find the element in the dictionary pointed at by key using a case
* insensitive search, and return a const pointer to it, or NULL
*/
- const EntryType* FindCaseInsensitiveC( const char* key ) const
+ const EntryType* FindConst( const char* key ) const
{
if( key != NULL )
{
std::string theKey(key);
- return FindCaseInsensitiveC( theKey );
+ return FindConst( theKey );
}
return NULL;
}
* Find the element in the dictionary pointed at by key using a case
* insensitive search, and return a non-const pointer to it, or NULL
*/
- EntryType* FindCaseInsensitive( const char* key ) const
+ EntryType* Find( const char* key ) const
{
if( key != NULL )
{
std::string theKey(key);
- return FindCaseInsensitive( theKey );
+ return Find( theKey );
}
return NULL;
}
-
/**
* Return an iterator pointing at the first entry in the dictionary
*/
*/
#include <dali/public-api/object/handle.h>
+#include <dali/devel-api/scripting/scripting.h>
#include <dali-toolkit/public-api/controls/control.h>
#include <dali-toolkit/devel-api/controls/control-devel.h>
#include <dali-toolkit/internal/builder/style.h>
{
namespace Toolkit
{
+
namespace Internal
{
+extern const Dali::Scripting::StringEnum ControlStateTable[];
+extern const unsigned int ControlStateTableCount;
+
StylePtr Style::New()
{
StylePtr stylePtr( new Style() );
Toolkit::Control control = Toolkit::Control::DownCast(handle);
if( control )
{
- Property::Value value = control.GetProperty(DevelControl::Property::STATE);
std::string stateName;
- if( value.Get( stateName ) )
+ Property::Value value = control.GetProperty(DevelControl::Property::STATE);
+ Dali::Toolkit::DevelControl::State state = static_cast<Dali::Toolkit::DevelControl::State>(value.Get<int>());
+ stateName = Scripting::GetEnumerationName< Toolkit::DevelControl::State >( state, ControlStateTable, ControlStateTableCount );
+
+ if( ! stateName.empty() )
{
// Look up state in states table:
- const StylePtr* stylePtr = subStates.FindCaseInsensitiveC( stateName );
+ const StylePtr* stylePtr = subStates.FindConst( stateName );
if( stylePtr )
{
const StylePtr statePtr(*stylePtr);
std::string subStateName;
if( value.Get( subStateName ) && ! subStateName.empty() )
{
- const StylePtr* stylePtr = statePtr->subStates.FindCaseInsensitiveC( subStateName );
+ const StylePtr* stylePtr = statePtr->subStates.FindConst( subStateName );
if( stylePtr )
{
const StylePtr subStatePtr(*stylePtr);
Style::Style()
{
}
-
Style::~Style()
{
}
*/
void ApplyVisualsAndPropertiesRecursively( Handle handle ) const;
-
-private:
/**
* Apply the visuals of the style to the control pointed at by
* handle.
namespace Toolkit
{
+namespace Internal
+{
+
+extern const Dali::Scripting::StringEnum ControlStateTable[];
+extern const unsigned int ControlStateTableCount;
+
+
+// Not static or anonymous - shared with other translation units
+const Scripting::StringEnum ControlStateTable[] = {
+ { "NORMAL", Toolkit::DevelControl::NORMAL },
+ { "FOCUSED", Toolkit::DevelControl::FOCUSED },
+ { "DISABLED", Toolkit::DevelControl::DISABLED },
+}; const unsigned int ControlStateTableCount = sizeof( ControlStateTable ) / sizeof( ControlStateTable[0] );
+
+} // Internal namespace
+
namespace
{
return connected;
}
-const Scripting::StringEnum ControlStateTable[] = {
- { "NORMAL", Toolkit::DevelControl::NORMAL },
- { "FOCUSED", Toolkit::DevelControl::FOCUSED },
- { "DISABLED", Toolkit::DevelControl::DISABLED },
-}; const unsigned int ControlStateTableCount = sizeof( ControlStateTable ) / sizeof( ControlStateTable[0] );
-
// Setup signals and actions using the type-registry.
DALI_TYPE_REGISTRATION_BEGIN( Control, CustomActor, Create );
Impl(Control& controlImpl)
: mControlImpl( controlImpl ),
mState( Toolkit::DevelControl::NORMAL ),
- mSubState(""),
+ mSubStateName(""),
mStyleName(""),
mBackgroundColor(Color::TRANSPARENT),
mStartingPinchScale( NULL ),
case Toolkit::DevelControl::Property::STATE:
{
- Toolkit::DevelControl::State state( controlImpl.mImpl->mState );
+ bool withTransitions=true;
+ const Property::Value* valuePtr=&value;
+ Property::Map* map = value.GetMap();
+ if(map)
+ {
+ Property::Value* value2 = map->Find("withTransitions");
+ if( value2 )
+ {
+ withTransitions = value2->Get<bool>();
+ }
+
+ valuePtr = map->Find("state");
+ }
- if( Scripting::GetEnumerationProperty< Toolkit::DevelControl::State >( value, ControlStateTable, ControlStateTableCount, state ) )
+ if( valuePtr )
{
- controlImpl.mImpl->SetState( state );
+ Toolkit::DevelControl::State state( controlImpl.mImpl->mState );
+ if( Scripting::GetEnumerationProperty< Toolkit::DevelControl::State >( *valuePtr, ControlStateTable, ControlStateTableCount, state ) )
+ {
+ controlImpl.mImpl->SetState( state, withTransitions );
+ }
}
}
break;
case Toolkit::DevelControl::Property::STATE:
{
- value = Scripting::GetEnumerationName< Toolkit::DevelControl::State >( controlImpl.mImpl->mState, ControlStateTable, ControlStateTableCount );
+ value = controlImpl.mImpl->mState;
+ break;
+ }
+
+ case Toolkit::DevelControl::Property::SUB_STATE:
+ {
+ value = controlImpl.mImpl->mSubStateName;
break;
}
return value;
}
- void SetState( DevelControl::State state )
+ void SetState( DevelControl::State state, bool withTransitions=true )
{
if( mState != state )
{
}
}
- void SetSubState( const std::string& state )
+ void SetSubState( const std::string& subStateName, bool withTransitions=true )
{
- if( mSubState != state )
+ if( mSubStateName != subStateName )
{
- mSubState = state;
- // Trigger transitions
+ // Get existing sub-state visuals, and unregister them
+ Dali::CustomActor handle( mControlImpl.GetOwner() );
+
+ Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
+ if( styleManager )
+ {
+ const StylePtr stylePtr = GetImpl( styleManager ).GetRecordedStyle( Toolkit::Control( mControlImpl.GetOwner() ) );
+ if( stylePtr )
+ {
+ // Stringify state
+ std::string stateName = Scripting::GetEnumerationName< Toolkit::DevelControl::State >( mState, ControlStateTable, ControlStateTableCount );
+
+ const StylePtr* state = stylePtr->subStates.Find( stateName );
+ if( state )
+ {
+ StylePtr stateStyle(*state);
+
+ // Unregister existing visuals of this substate
+ const StylePtr* subState = stateStyle->subStates.Find( mSubStateName );
+ if( subState )
+ {
+ StylePtr subStateStyle(*subState);
+
+ for( Dictionary<Property::Map>::iterator iter = subStateStyle->visuals.Begin(); iter != subStateStyle->visuals.End(); ++iter )
+ {
+ const std::string& visualName = (*iter).key;
+ Dali::Property::Index index = handle.GetPropertyIndex( visualName );
+ if( index != Property::INVALID_INDEX )
+ {
+ mControlImpl.UnregisterVisual( index );
+ }
+ }
+ }
+
+ // Register visuals of the new substate
+ const StylePtr* newSubState = stateStyle->subStates.Find( subStateName );
+ if( newSubState )
+ {
+ StylePtr newSubStateStyle(*newSubState);
+ newSubStateStyle->ApplyVisuals( handle );
+ newSubStateStyle->ApplyProperties( handle );
+ }
+ }
+ }
+ }
+ mSubStateName = subStateName;
}
}
Control& mControlImpl;
DevelControl::State mState;
- std::string mSubState;
+ std::string mSubStateName;
RegisteredVisualContainer mVisuals; // Stores visuals needed by the control, non trivial type so std::vector used.
std::string mStyleName;