Property added to enable and disable the markup processor.
Change-Id: I0c5e237ed235774a5cbcbbb393de7200385575d8
Signed-off-by: Victor Cebollada <v.cebollada@samsung.com>
const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
+const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
+ DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
END_TEST;
}
field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
+ // Check the enable markup property.
+ DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
+ field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
+ DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
+
END_TEST;
}
const char* const PROPERTY_NAME_UNDERLINE_ENABLED = "underlineEnabled";
const char* const PROPERTY_NAME_UNDERLINE_COLOR = "underlineColor";
const char* const PROPERTY_NAME_UNDERLINE_HEIGHT = "underlineHeight";
+const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE_ENABLED ) == TextLabel::Property::UNDERLINE_ENABLED );
DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE_COLOR ) == TextLabel::Property::UNDERLINE_COLOR );
DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE_HEIGHT) == TextLabel::Property::UNDERLINE_HEIGHT );
+ DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP) == TextLabel::Property::ENABLE_MARKUP );
END_TEST;
}
DALI_TEST_CHECK( label2 );
DALI_TEST_EQUALS( label2.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("New text"), TEST_LOCATION );
+ // Check the enable markup property.
+ DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
+ label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
+ DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
+
END_TEST;
}
DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "decorationBoundingBox", RECTANGLE, DECORATION_BOUNDING_BOX )
DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputMethodSettings", MAP, INPUT_METHOD_SETTINGS )
DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputColor", VECTOR4, INPUT_COLOR )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "enableMarkup", BOOLEAN, ENABLE_MARKUP )
DALI_SIGNAL_REGISTRATION( Toolkit, TextField, "textChanged", SIGNAL_TEXT_CHANGED )
DALI_SIGNAL_REGISTRATION( Toolkit, TextField, "maxLengthReached", SIGNAL_MAX_LENGTH_REACHED )
}
break;
}
+ case Toolkit::TextField::Property::ENABLE_MARKUP:
+ {
+ if( impl.mController )
+ {
+ const bool enableMarkup = value.Get<bool>();
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p ENABLE_MARKUP %d\n", impl.mController.Get(), enableMarkup );
+
+ impl.mController->SetMarkupProcessorEnabled( enableMarkup );
+ }
+ break;
+ }
} // switch
} // textfield
}
{
break;
}
+ case Toolkit::TextField::Property::ENABLE_MARKUP:
+ {
+ if( impl.mController )
+ {
+ value = impl.mController->IsMarkupProcessorEnabled();
+ }
+ break;
+ }
} //switch
}
DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "underlineEnabled", BOOLEAN, UNDERLINE_ENABLED )
DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "underlineColor", VECTOR4, UNDERLINE_COLOR )
DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "underlineHeight", FLOAT, UNDERLINE_HEIGHT )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "enableMarkup", BOOLEAN, ENABLE_MARKUP )
DALI_TYPE_REGISTRATION_END()
}
break;
}
+ case Toolkit::TextLabel::Property::ENABLE_MARKUP:
+ {
+ if( impl.mController )
+ {
+ const bool enableMarkup = value.Get<bool>();
+ impl.mController->SetMarkupProcessorEnabled( enableMarkup );
+ }
+ break;
+ }
}
}
}
}
break;
}
+ case Toolkit::TextLabel::Property::ENABLE_MARKUP:
+ {
+ if( impl.mController )
+ {
+ value = impl.mController->IsMarkupProcessorEnabled();
+ }
+ break;
+ }
}
}
MAX_LENGTH, ///< name "maxLength" The maximum number of characters that can be inserted, type INTEGER
EXCEED_POLICY, ///< name "exceedPolicy" Specifies how the text is truncated when it does not fit, type INTEGER
HORIZONTAL_ALIGNMENT, ///< name "horizontalAlignment", The line horizontal alignment, type STRING, values "BEGIN", "CENTER", "END"
- VERTICAL_ALIGNMENT, ///< name "verticalAlignment", The line vertical alignment, type STRING, values "TOP", "CENTER", "BOTTOM"
+ VERTICAL_ALIGNMENT, ///< name "verticalAlignment", The line vertical alignment, type STRING, values "TOP", "CENTER", "BOTTOM"
TEXT_COLOR, ///< name "textColor", The text color, type VECTOR4
PLACEHOLDER_TEXT_COLOR, ///< name "placeholderTextColor", The placeholder-text color, type VECTOR4
SHADOW_OFFSET, ///< name "shadowOffset", The drop shadow offset 0 indicates no shadow, type VECTOR2
DECORATION_BOUNDING_BOX, ///< name "decorationBoundingBox", The decorations (handles etc) will positioned within this area on-screen, type RECTANGLE
INPUT_METHOD_SETTINGS, ///< name "inputMethodSettings", The settings to relating to the System's Input Method, Key and Value type MAP
INPUT_COLOR, ///< name "inputColor", The color of the new input text, type VECTOR4
+ ENABLE_MARKUP ///< name "enableMarkup", Whether the mark-up processing is enabled. type BOOLEAN
};
};
POINT_SIZE, ///< name "pointSize", The size of font in points, type FLOAT
MULTI_LINE, ///< name "multiLine", The single-line or multi-line layout option, type BOOLEAN
HORIZONTAL_ALIGNMENT, ///< name "horizontalAlignment", The line horizontal alignment, type STRING, values "BEGIN", "CENTER", "END"
- VERTICAL_ALIGNMENT, ///< name "verticalAlignment", The line vertical alignment, type STRING, values "TOP", "CENTER", "BOTTOM"
+ VERTICAL_ALIGNMENT, ///< name "verticalAlignment", The line vertical alignment, type STRING, values "TOP", "CENTER", "BOTTOM"
TEXT_COLOR, ///< name "textColor", The text color, type VECTOR4
SHADOW_OFFSET, ///< name "shadowOffset", The drop shadow offset 0 indicates no shadow, type VECTOR2
SHADOW_COLOR, ///< name "shadowColor", The color of a drop shadow, type VECTOR4
UNDERLINE_ENABLED, ///< name "underlineEnabled", The underline enabled flag, type BOOLEAN
UNDERLINE_COLOR, ///< name "underlineColor", The color of the underline, type VECTOR4
- UNDERLINE_HEIGHT ///< name "underlineHeight", Overrides the underline height from font metrics, type FLOAT
+ UNDERLINE_HEIGHT, ///< name "underlineHeight", Overrides the underline height from font metrics, type FLOAT
+ ENABLE_MARKUP ///< name "enableMarkup", Whether the mark-up processing is enabled. type BOOLEAN
};
};
--- /dev/null
+<!--
+/**-->
+
+# Mark-up Style {#markup-style}
+
+Mark-up tags can be used within the text to set styles.
+
+By default the text controls don't process the mark-up string. To enable the mark-up string processing the property *ENABLE_MARKUP* must be set to *true*.
+
+~~~{.cpp}
+// C++
+
+TextField field = TextField::New();
+field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
+
+Stage::GetCurrent().Add( field );
+~~~
+
+~~~{.js}
+// JavaScript
+
+var field = new dali.TextField();
+field.enableMarkup = true;
+
+dali.stage.add( field );
+~~~
+
+Note the mark-up processor doesn't check the correctness of the mark-up string. This may cause the text to be badly rendered.
+
+The table below describes the priorities when styles are applied while rendering text.
+| | | | |
+|--|--|--|--|
+| Priority 1 | Style set by markup string. | Will override the style set through the control properties. | i.e The \<color\> tag will override the *TEXT_COLOR* property. |
+| Priority 2 | Style set through the control properties. | Will override the default platform style. | |
+| Priority 3 | Default platform style. | | |
+
+Current supported tags are:
+
+## \<color\>
+
+Sets the color of the characters inside the tag. The *color* tag has a *value* attribute used to set the color. Possible values are: 'red', 'green', 'blue', 'yellow', 'magenta',
+ 'cyan', 'white', 'black' and 'transparent'. Web color and 32 bits hexadecimal 0xAARRGGBB formats are also supported.
+
+Examples below are equivalent, render the text in red. Second example codes the color in 0xAARRGGBB, third and fourth in web color with 3 and 6 characters.
+
+~~~{.cpp}
+// C++
+field.SetProperty( TextLabel::Property::TEXT, "<color value='red'>Red Text</color>" ); // Color coded with a text constant.
+~~~
+
+~~~{.js}
+// JavaScript
+
+field.text = "<color value='red'>Red Text</color>"; // Color coded with a text constant.
+~~~
+
+~~~{.cpp}
+// C++
+field.SetProperty( TextLabel::Property::TEXT, "<color value='0xFFFF0000'>Red Text</color>" ); // Color packed inside an ARGB hexadecimal value.
+~~~
+
+~~~{.js}
+// JavaScript
+
+field.text = "<color value='0xFFFF0000'>Red Text</color>"; // Color packed inside an ARGB hexadecimal value.
+~~~
+
+~~~{.cpp}
+// C++
+field.SetProperty( TextLabel::Property::TEXT, "<color value='#F00'>Red Text</color>" ); // Color packed with the web color format (3 characters).
+~~~
+
+~~~{.js}
+// JavaScript
+
+field.text = "<color value='#F00'>Red Text</color>"; // Color packed with the web color format (3 characters).
+~~~
+
+~~~{.cpp}
+// C++
+field.SetProperty( TextLabel::Property::TEXT, "<color value='#FF0000'>Red Text</color>" ); // Color packed with the web color format (6 characters).
+~~~
+
+~~~{.js}
+// JavaScript
+
+field.text = "<color value='#FF0000'>Red Text</color>"; // Color packed with the web color format (6 characters).
+~~~
+
+*/
By default TextField will automatically select a suitable font from the platform. However, a different font could be selected. See the [Font Selection](@ref font-selection) section for more details.
+### Mark-up Style
+
+Mark-up tags can be used to change the style of the text. See the [Mark-up Style](@ref markup-style) section for more details.
+
+### Input Style
+
+The input style can be changed through the control properties. Current supported input style properties are:
+
+#### INPUT_COLOR
+
+Sets the input color. All subsequent characters added will be rendered with the input color.
+
+Note the input color may change if the cursor is updated by tapping in a new position.
+
### Text Alignment
TextField displays a single-line of text, which will scroll if there is not enough room for the text displayed.
horizontalAlignment | HORIZONTAL_ALIGNMENT | STRING | O | X
verticalAlignment | VERTICAL_ALIGNMENT | STRING | O | X
textColor | TEXT_COLOR | VECTOR4 | O | X
+ placeholderTextColor | PLACEHOLDER_TEXT_COLOR | VECTOR4 | O | X
shadowOffset | SHADOW_OFFSET | VECTOR2 | O | X
shadowColor | SHADOW_COLOR | VECTOR4 | O | X
primaryCursorColor | PRIMARY_CURSOR_COLOR | VECTOR4 | O | X
enableCursorBlink | ENABLE_CURSOR_BLINK | BOOLEAN | O | X
cursorBlinkInterval | CURSOR_BLINK_INTERVAL | FLOAT | O | X
cursorBlinkDuration | CURSOR_BLINK_DURATION | FLOAT | O | X
+ cursorWidth | CURSOR_WIDTH | INTEGER | O | X
grabHandleImage | GRAB_HANDLE_IMAGE | STRING | O | X
grabHandlePressedImage | GRAB_HANDLE_PRESSED_IMAGE | STRING | O | X
scrollThreshold | SCROLL_THRESHOLD | FLOAT | O | X
selectionHandleImageRight | SELECTION_HANDLE_IMAGE_RIGHT | STRING | O | X
selectionHandlePressedImageLeft | SELECTION_HANDLE_PRESSED_IMAGE_LEFT | STRING | O | X
selectionHandlePressedImageRight | SELECTION_HANDLE_PRESSED_IMAGE_RIGHT | STRING | O | X
+ selectionHandleMarkerImageLeft | SELECTION_HANDLE_MARKER_IMAGE_LEFT | MAP | O | X
+ selectionHandleMarkerImageRight | SELECTION_HANDLE_MARKER_IMAGE_RIGHT | MAP | O | X
selectionHighlightColor | SELECTION_HIGHLIGHT_COLOR | VECTOR4 | O | X
decorationBoundingBox | DECORATION_BOUNDING_BOX | RECTANGLE | O | X
inputMethodSettings | INPUT_METHOD_SETTINGS | MAP | O | X
+ inputColor | INPUT_COLOR | VECTOR4 | O | X
+ enableMarkup | ENABLE_MARKUP | BOOLEAN | O | X
@class TextField
By default TextLabel will automatically select a suitable font from the platform. However, a different font could be selected. See the [Font Selection](@ref font-selection) section for more details.
+### Mark-up Style
+
+Mark-up tags can be used to change the style of the text. See the [Mark-up Style](@ref markup-style) section for more details.
+
### Text Alignment
Wrapping can be enabled using the MULTI_LINE property:
### Text Label Properties
- Name (JavaScript) | Name (C++) | Type | Writable | Animatable
----------------------|---------------------|--------------|--------------|-----------
- renderingBackend | RENDERING_BACKEND | INTEGER | O | X
- text | TEXT | STRING | O | X
- fontFamily | FONT_FAMILY | STRING | O | X
- fontStyle | FONT_STYLE | STRING | O | X
- pointSize | POINT_SIZE | FLOAT | O | X
- multiLine | MULTI_LINE | BOOLEAN | O | X
- horizontalAlignment | HORIZONTAL_ALIGNMENT| STRING | O | X
- verticalAlignment | VERTICAL_ALIGNMENT | STRING | O | X
- textColor | TEXT_COLOR | VECTOR4 | O | X
- shadowOffset | SHADOW_OFFSET | VECTOR2 | O | X
- shadowColor | SHADOW_COLOR | VECTOR4 | O | X
- underlineEnabled | UNDERLINE_ENABLED | BOOLEAN | O | X
- underlineColor | UNDERLINE_COLOR | VECTOR4 | O | X
- underlineHeight | UNDERLINE_HEIGHT | FLOAT | O | X
+ Name (JavaScript) | Name (C++) | Type | Writable | Animatable
+---------------------|----------------------|--------------|--------------|-----------
+ renderingBackend | RENDERING_BACKEND | INTEGER | O | X
+ text | TEXT | STRING | O | X
+ fontFamily | FONT_FAMILY | STRING | O | X
+ fontStyle | FONT_STYLE | STRING | O | X
+ pointSize | POINT_SIZE | FLOAT | O | X
+ multiLine | MULTI_LINE | BOOLEAN | O | X
+ horizontalAlignment | HORIZONTAL_ALIGNMENT | STRING | O | X
+ verticalAlignment | VERTICAL_ALIGNMENT | STRING | O | X
+ textColor | TEXT_COLOR | VECTOR4 | O | X
+ shadowOffset | SHADOW_OFFSET | VECTOR2 | O | X
+ shadowColor | SHADOW_COLOR | VECTOR4 | O | X
+ underlineEnabled | UNDERLINE_ENABLED | BOOLEAN | O | X
+ underlineColor | UNDERLINE_COLOR | VECTOR4 | O | X
+ underlineHeight | UNDERLINE_HEIGHT | FLOAT | O | X
+ enableMarkup | ENABLE_MARKUP | BOOLEAN | O | X