#include <stdlib.h>
#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/internal/text/text-run-container.h>
#include <dali-toolkit/dali-toolkit.h>
#include <toolkit-text-model.h>
namespace
{
+struct CreateParagraphData
+{
+ std::string description; ///< Description of the test.
+ std::string text; ///< Input text.
+ CharacterIndex index; ///< The first character index.
+ Length numberOfCharacters; ///< The number of characters.
+ unsigned int numberOfParagraphs; ///< The expected number of paragraphs.
+ unsigned int* indices; ///< The expected paragraph info indices.
+ unsigned int* numberOfCharactersPerParagraph; ///< The expected number of characters of each paragraph.
+};
+
+struct FindParagraphData
+{
+ std::string description; ///< Description of the test.
+ std::string text; ///< Input text.
+ CharacterIndex index; ///< The first character index.
+ Length numberOfCharacters; ///< The number of characters.
+ unsigned int numberOfParagraphs; ///< The expected number of paragraphs.
+ unsigned int* paragraphs; ///< The expected paragraph info.
+};
struct SetVisualToLogicalMapData
{
unsigned int* visualToLogical; ///< The expected visual to logical conversion table.
};
+bool CreateParagraphTest( const CreateParagraphData& data )
+{
+ // 1) Create the model.
+ LogicalModelPtr logicalModel = LogicalModel::New();
+ VisualModelPtr visualModel = VisualModel::New();
+ Size textArea(100.f, 60.f);
+ Size layoutSize;
+
+ Vector<FontDescriptionRun> fontDescriptionRuns;
+ LayoutOptions options;
+ CreateTextModel( data.text,
+ textArea,
+ fontDescriptionRuns,
+ options,
+ layoutSize,
+ logicalModel,
+ visualModel );
+
+ // 2) Clear the paragraphs.
+ Vector<ParagraphRun>& paragraphs = logicalModel->mParagraphInfo;
+ ClearCharacterRuns( data.index,
+ data.index + data.numberOfCharacters - 1u,
+ paragraphs );
+
+ // 3) Call the LogicalModel::CreateParagraphInfo() method
+ logicalModel->CreateParagraphInfo( data.index,
+ data.numberOfCharacters );
+
+ // 4) Compare the results.
+ if( data.numberOfParagraphs != paragraphs.Count() )
+ {
+ std::cout << " Different number of paragraphs : " << paragraphs.Count() << ", expected : " << data.numberOfParagraphs << std::endl;
+ return false;
+ }
+
+ unsigned int index = 0u;
+ for( Vector<ParagraphRun>::ConstIterator it = paragraphs.Begin(),
+ endIt = paragraphs.End();
+ it != endIt;
+ ++it, ++index )
+ {
+ const ParagraphRun& paragraph( *it );
+
+ if( data.indices[index] != paragraph.characterRun.characterIndex )
+ {
+ std::cout << " Different character index for paragraph : " << index << ", " << paragraph.characterRun.characterIndex << ", expected : " << data.indices[index] << std::endl;
+ return false;
+ }
+ if( data.numberOfCharactersPerParagraph[index] != paragraph.characterRun.numberOfCharacters )
+ {
+ std::cout << " Different number of characters for paragraph : " << index << ", " << paragraph.characterRun.numberOfCharacters << ", expected : " << data.numberOfCharactersPerParagraph[index] << std::endl;
+ return false;
+ }
+ }
+
+ return true;
+}
+
+bool FindParagraphTest( const FindParagraphData& data )
+{
+ // 1) Create the model.
+ LogicalModelPtr logicalModel = LogicalModel::New();
+ VisualModelPtr visualModel = VisualModel::New();
+ Size textArea(100.f, 60.f);
+ Size layoutSize;
+
+ Vector<FontDescriptionRun> fontDescriptionRuns;
+ LayoutOptions options;
+ CreateTextModel( data.text,
+ textArea,
+ fontDescriptionRuns,
+ options,
+ layoutSize,
+ logicalModel,
+ visualModel );
+
+ // 2) Find the paragraphs.
+ Vector<ParagraphRunIndex> paragraphs;
+ logicalModel->FindParagraphs( data.index, data.numberOfCharacters, paragraphs );
+
+ // 3) compare the results.
+ if( data.numberOfParagraphs != paragraphs.Count() )
+ {
+ return false;
+ }
+
+ unsigned int index = 0u;
+ for( Vector<ParagraphRunIndex>::ConstIterator it = paragraphs.Begin(),
+ endIt = paragraphs.End();
+ it != endIt;
+ ++it, ++index )
+ {
+ const ParagraphRunIndex paragraphIndex = *it;
+
+ if( paragraphIndex != data.paragraphs[index] )
+ {
+ return false;
+ }
+ }
+
+ return true;
+}
+
bool SetVisualToLogicalMapTest( const SetVisualToLogicalMapData& data )
{
std::cout << " testing : " << data.description << std::endl;
} // namespace
//////////////////////////////////////////////////////////
+//
+// UtcDaliCreateParagraph
+// UtcDaliFindParagraph
+// UtcDaliSetVisualToLogicalMap
+//
+//////////////////////////////////////////////////////////
-int UtcDaliSetVisualToLogicalMap(void)
+int UtcDaliCreateParagraph(void)
{
ToolkitTestApplication application;
+ tet_infoline(" UtcDaliCreateParagraph");
+
+ unsigned int paragraphsIndices01[] = { 0u };
+ unsigned int paragraphsNumberOfCharacters01[] = { 0u };
+ unsigned int paragraphsIndices02[] = { 0u, 12u, 17u };
+ unsigned int paragraphsNumberOfCharacters02[] = { 12u, 5u, 1u };
+ unsigned int paragraphsIndices03[] = { 0u, 12u, 17u, 34u };
+ unsigned int paragraphsNumberOfCharacters03[] = { 12u, 5u, 17u ,1u };
+
+ struct CreateParagraphData data[] =
+ {
+ {
+ "Zero characters",
+ "",
+ 0u,
+ 0u,
+ 0u,
+ paragraphsIndices01,
+ paragraphsNumberOfCharacters01,
+ },
+ {
+ "Some paragraphs",
+ "Hello world\ndemo\n\n",
+ 0u,
+ 18u,
+ 3u,
+ paragraphsIndices02,
+ paragraphsNumberOfCharacters02,
+ },
+ {
+ "Some paragraphs. Update the initial paragraphs.",
+ "Hello world\ndemo\nhello world demo\n\n",
+ 0u,
+ 17u,
+ 4u,
+ paragraphsIndices03,
+ paragraphsNumberOfCharacters03,
+ },
+ {
+ "Some paragraphs. Update the mid paragraphs.",
+ "Hello world\ndemo\nhello world demo\n\n",
+ 12u,
+ 5u,
+ 4u,
+ paragraphsIndices03,
+ paragraphsNumberOfCharacters03,
+ },
+ {
+ "Some paragraphs. Update the final paragraphs.",
+ "Hello world\ndemo\nhello world demo\n\n",
+ 17u,
+ 18u,
+ 4u,
+ paragraphsIndices03,
+ paragraphsNumberOfCharacters03,
+ },
+ };
+ const unsigned int numberOfTests = 5u;
+
+ for( unsigned int index = 0u; index < numberOfTests; ++index )
+ {
+ // ToolkitTestApplication application;
+ if( !CreateParagraphTest( data[index] ) )
+ {
+ tet_result(TET_FAIL);
+ }
+ }
+
+ tet_result(TET_PASS);
+ END_TEST;
+}
+
+int UtcDaliFindParagraph(void)
+{
+ tet_infoline(" UtcDaliFindParagraph");
+
+ unsigned int paragraphs01[] = {};
+ unsigned int paragraphs02[] = { 0u, 1u, 2u };
+ unsigned int paragraphs03[] = { 0u };
+ unsigned int paragraphs04[] = { 1u };
+ unsigned int paragraphs05[] = { 0u, 1u, 2u };
+
+ struct FindParagraphData data[] =
+ {
+ {
+ "Zero characters",
+ "",
+ 0u,
+ 100u,
+ 0u,
+ paragraphs01,
+ },
+ {
+ "Some paragraphs",
+ "Hello world\ndemo\n\n",
+ 0u,
+ 18u,
+ 3u,
+ paragraphs02
+ },
+ {
+ "Some paragraphs",
+ "Hello world\ndemo\n\n",
+ 0u,
+ 12u,
+ 1u,
+ paragraphs03
+ },
+ {
+ "Some paragraphs",
+ "Hello world\ndemo\n\n",
+ 12u,
+ 5u,
+ 1u,
+ paragraphs04
+ },
+ {
+ "Some paragraphs",
+ "Hello world\ndemo\n\n",
+ 3u,
+ 15u,
+ 3u,
+ paragraphs05
+ },
+ };
+ const unsigned int numberOfTests = 5u;
+
+ for( unsigned int index = 0u; index < numberOfTests; ++index )
+ {
+ ToolkitTestApplication application;
+ if( !FindParagraphTest( data[index] ) )
+ {
+ tet_result(TET_FAIL);
+ }
+ }
+
+ tet_result(TET_PASS);
+ END_TEST;
+}
+
+int UtcDaliSetVisualToLogicalMap(void)
+{
tet_infoline(" UtcDaliSetVisualToLogicalMap");
unsigned int* visualToLogical01 = NULL;
for( unsigned int index = 0u; index < numberOfTests; ++index )
{
+ ToolkitTestApplication application;
if( !SetVisualToLogicalMapTest( data[index] ) )
{
tet_result(TET_FAIL);
utf32.Resize( numberOfCharacters );
- // 2) Set the line break info.
+ // 2) Set the line break info for the whole text.
Vector<LineBreakInfo> lineBreakInfo;
lineBreakInfo.Resize( numberOfCharacters );
- SetLineBreakInfo( utf32, lineBreakInfo );
+ SetLineBreakInfo( utf32,
+ 0u,
+ numberOfCharacters,
+ lineBreakInfo );
+
+ // 3) Update the word text info if it's requested for part of the text.
+ if( ( 0u != data.index ) &&
+ ( numberOfCharacters != data.numberOfCharacters ) )
+ {
+ // Clear part of the line break info.
+ lineBreakInfo.Erase( lineBreakInfo.Begin() + data.index,
+ lineBreakInfo.Begin() + data.index + data.numberOfCharacters );
- // 3) compare the results
+ // Update the word line info.
+ SetLineBreakInfo( utf32,
+ data.index,
+ data.numberOfCharacters,
+ lineBreakInfo );
+ }
+
+ // 4) compare the results
std::ostringstream breakInfo;
for( unsigned int index = 0u; index < numberOfCharacters; ++index )
if( data.breakInfo != breakInfo.str() )
{
- std::cout << " expected : [" << data.breakInfo << "]" << std::endl;
- std::cout << " got : [" << breakInfo.str() << "]" << std::endl;
+ std::cout << " text : [" << data.text << "]" << std::endl;
+ std::cout << " index : " << data.index << std::endl;
+ std::cout << " numberOfCharacters : " << data.numberOfCharacters << std::endl;
+ std::cout << " expected : [" << data.breakInfo << "]" << std::endl;
+ std::cout << " got : [" << breakInfo.str() << "]" << std::endl;
return false;
}
int UtcDaliTextSegnemtationSetLineBreakInfo(void)
{
- ToolkitTestApplication application;
tet_infoline(" UtcDaliTextSegnemtationSetLineBreakInfo");
struct BreakInfoData data[] =
"222222122222221221222212212221222222122222222220",
},
{
+ "Latin script. Update initial paragraphs.",
+ "Lorem ipsum dolor sit amet, aeque definiebas ea mei, posse iracundia ne cum.\n"
+ "Usu ne nisl maiorum iudicabit, veniam epicurei oporteat eos an.\n"
+ "Ne nec nulla regione albucius, mea doctus delenit ad!\n"
+ "Et everti blandit adversarium mei, eam porro neglegentur suscipiantur an.\n"
+ "Quidam corpora at duo. An eos possim scripserit?",
+ 0u,
+ 141u,
+ "22222122222122222122212222212222212222222222122122221222221222222222122122220"
+ "2221221222212222222122222222221222222122222222122222222122212220"
+ "221222122222122222221222222222122212222221222222212220"
+ "22122222212222222122222222222122221222122222122222222222122222222222212220"
+ "222222122222221221222212212221222222122222222220",
+ },
+ {
+ "Latin script. Update mid paragraphs.",
+ "Lorem ipsum dolor sit amet, aeque definiebas ea mei, posse iracundia ne cum.\n"
+ "Usu ne nisl maiorum iudicabit, veniam epicurei oporteat eos an.\n"
+ "Ne nec nulla regione albucius, mea doctus delenit ad!\n"
+ "Et everti blandit adversarium mei, eam porro neglegentur suscipiantur an.\n"
+ "Quidam corpora at duo. An eos possim scripserit?",
+ 141u,
+ 128u,
+ "22222122222122222122212222212222212222222222122122221222221222222222122122220"
+ "2221221222212222222122222222221222222122222222122222222122212220"
+ "221222122222122222221222222222122212222221222222212220"
+ "22122222212222222122222222222122221222122222122222222222122222222222212220"
+ "222222122222221221222212212221222222122222222220",
+ },
+ {
+ "Latin script. Update final paragraphs.",
+ "Lorem ipsum dolor sit amet, aeque definiebas ea mei, posse iracundia ne cum.\n"
+ "Usu ne nisl maiorum iudicabit, veniam epicurei oporteat eos an.\n"
+ "Ne nec nulla regione albucius, mea doctus delenit ad!\n"
+ "Et everti blandit adversarium mei, eam porro neglegentur suscipiantur an.\n"
+ "Quidam corpora at duo. An eos possim scripserit?",
+ 195u,
+ 122u,
+ "22222122222122222122212222212222212222222222122122221222221222222222122122220"
+ "2221221222212222222122222222221222222122222222122222222122212220"
+ "221222122222122222221222222222122212222221222222212220"
+ "22122222212222222122222222222122221222122222122222222222122222222222212220"
+ "222222122222221221222212212221222222122222222220",
+ },
+ {
"Japanese script",
"韓国側は北朝鮮当局を通じて米ドルで賃金を支払う。\n"
"国際社会から様々な経済制裁を受ける北朝鮮にとっては出稼ぎ労働などと並んで重要な外貨稼ぎの手段となっている。\n"
"21111112112111111111111211121111111111120",
}
};
- const unsigned int numberOfTests = 4u;
+ const unsigned int numberOfTests = 7u;
for( unsigned int index = 0u; index < numberOfTests; ++index )
{
+ ToolkitTestApplication application;
if( !LineBreakInfoTest( data[index] ) )
{
tet_result(TET_FAIL);
int UtcDaliTextSegnemtationSetWordBreakInfo(void)
{
- ToolkitTestApplication application;
tet_infoline(" UtcDaliTextSegnemtationSetWordBreakInfo");
struct BreakInfoData data[] =
for( unsigned int index = 0u; index < numberOfTests; ++index )
{
+ ToolkitTestApplication application;
if( !WordBreakInfoTest( data[index] ) )
{
tet_result(TET_FAIL);
Vector<GlyphIndex>& charactersToGlyph = visualModel->mCharactersToGlyph;
Vector<Length>& glyphsPerCharacter = visualModel->mGlyphsPerCharacter;
+ GlyphIndex startGlyphIndex = 0u;
if( 0u != charactersToGlyph.Count() )
{
// The number of glyphs to be removed.
const Length numberOfGlyphs = charactersToGlyph[data.startIndex + data.numberOfCharacters - 1u] + glyphsPerCharacter[data.startIndex + data.numberOfCharacters - 1u] - charactersToGlyph[data.startIndex];
+ startGlyphIndex = charactersToGlyph[data.startIndex];
charactersToGlyph.Erase( charactersToGlyph.Begin() + data.startIndex,
charactersToGlyph.Begin() + data.startIndex + data.numberOfCharacters );
// 3) Call the CreateGlyphsPerCharacterTable() function
visualModel->CreateGlyphsPerCharacterTable( data.startIndex,
+ startGlyphIndex,
data.numberOfCharacters );
// 4) Compare the results.
Vector<GlyphIndex>& charactersToGlyph = visualModel->mCharactersToGlyph;
Vector<Length>& glyphsPerCharacter = visualModel->mGlyphsPerCharacter;
+ GlyphIndex startGlyphIndex = 0u;
if( 0u != charactersToGlyph.Count() )
{
// The number of glyphs to be removed.
const Length numberOfGlyphs = charactersToGlyph[data.startIndex + data.numberOfCharacters - 1u] + glyphsPerCharacter[data.startIndex + data.numberOfCharacters - 1u] - charactersToGlyph[data.startIndex];
+ startGlyphIndex = charactersToGlyph[data.startIndex];
charactersToGlyph.Erase( charactersToGlyph.Begin() + data.startIndex,
charactersToGlyph.Begin() + data.startIndex + data.numberOfCharacters );
// 3) Call the CreateCharacterToGlyphTable() function
visualModel->CreateCharacterToGlyphTable( data.startIndex,
+ startGlyphIndex,
data.numberOfCharacters );
// 4) Compare the results.
void DummyControlImplOverride::OnPan(const PanGesture& pan) { panCalled = true; }
void DummyControlImplOverride::OnTap(const TapGesture& tap) { tapCalled = true; }
void DummyControlImplOverride::OnLongPress(const LongPressGesture& longPress) { longPressCalled = true; }
-void DummyControlImplOverride::OnStageConnection( int depth ) { stageConnectionCalled = true; }
-void DummyControlImplOverride::OnStageDisconnection() { stageDisconnectionCalled = true; }
+void DummyControlImplOverride::OnStageConnection( int depth ) { Control::OnStageConnection( depth ); stageConnectionCalled = true; }
+void DummyControlImplOverride::OnStageDisconnection() { stageDisconnectionCalled = true; Control::OnStageDisconnection(); }
void DummyControlImplOverride::OnChildAdd(Actor& child) { childAddCalled = true; }
void DummyControlImplOverride::OnChildRemove(Actor& child) { childRemoveCalled = true; }
-void DummyControlImplOverride::OnSizeSet(const Vector3& targetSize) { sizeSetCalled = true; }
-void DummyControlImplOverride::OnSizeAnimation(Animation& animation, const Vector3& targetSize) { sizeAnimationCalled = true; }
+void DummyControlImplOverride::OnSizeSet(const Vector3& targetSize) { Control::OnSizeSet( targetSize ); sizeSetCalled = true; }
+void DummyControlImplOverride::OnSizeAnimation(Animation& animation, const Vector3& targetSize) { Control::OnSizeAnimation( animation, targetSize ); sizeAnimationCalled = true; }
bool DummyControlImplOverride::OnTouchEvent(const TouchEvent& event) { touchEventCalled = true; return false; }
bool DummyControlImplOverride::OnHoverEvent(const HoverEvent& event) { hoverEventCalled = true; return false; }
bool DummyControlImplOverride::OnWheelEvent(const WheelEvent& event) { wheelEventCalled = true; return false; }
Vector<LineBreakInfo>& lineBreakInfo = logicalModel->mLineBreakInfo;
lineBreakInfo.Resize( numberOfCharacters );
- SetLineBreakInfo( utf32Characters, lineBreakInfo );
+ SetLineBreakInfo( utf32Characters,
+ 0u,
+ numberOfCharacters,
+ lineBreakInfo );
if( 0u == numberOfCharacters )
{
numberOfCharacters,
bidirectionalInfo );
+ // Create the paragraph info.
+ logicalModel->CreateParagraphInfo( 0u,
+ numberOfCharacters );
+
// 6) Set character directions.
Vector<CharacterDirection>& characterDirections = logicalModel->mCharacterDirections;
if( 0u != bidirectionalInfo.Count() )
newParagraphGlyphs );
// Create the 'number of glyphs' per character and the glyph to character conversion tables.
- visualModel->CreateGlyphsPerCharacterTable( 0u, numberOfCharacters );
- visualModel->CreateCharacterToGlyphTable( 0u, numberOfCharacters );
+ visualModel->CreateGlyphsPerCharacterTable( 0u, 0u, numberOfCharacters );
+ visualModel->CreateCharacterToGlyphTable( 0u, 0u, numberOfCharacters );
const Length numberOfGlyphs = glyphs.Count();
void BloomView::OnSizeSet(const Vector3& targetSize)
{
+ Control::OnSizeSet( targetSize );
+
mTargetSize = Vector2(targetSize);
mChildrenRoot.SetSize(targetSize);
mCompositeImageActor.SetSize(targetSize);
}
}
-void BloomView::OnControlChildAdd( Actor& child )
+void BloomView::OnChildAdd( Actor& child )
{
+ Control::OnChildAdd( child );
+
if( child != mChildrenRoot && child != mInternalRoot)
{
mChildrenRoot.Add( child );
}
}
-void BloomView::OnControlChildRemove( Actor& child )
+void BloomView::OnChildRemove( Actor& child )
{
mChildrenRoot.Remove( child );
+
+ Control::OnChildRemove( child );
}
void BloomView::AllocateResources()
virtual void OnSizeSet(const Vector3& targetSize);
/**
- * @copydoc Control::OnControlChildAdd()
+ * @copydoc Control::OnChildAdd()
*/
- virtual void OnControlChildAdd( Actor& child );
+ virtual void OnChildAdd( Actor& child );
/**
- * @copydoc Control::OnControlChildRemove()
+ * @copydoc Control::OnChildRemove()
*/
- virtual void OnControlChildRemove( Actor& child );
+ virtual void OnChildRemove( Actor& child );
void AllocateResources();
void CreateRenderTasks();
return false;
}
-void Button::OnButtonStageDisconnection()
-{
- if( ButtonDown == mState )
- {
- if( !mTogglableButton )
- {
- Released();
-
- if( mAutoRepeating )
- {
- mAutoRepeatingTimer.Reset();
- }
- }
- }
-}
-
void Button::OnButtonDown()
{
if( !mTogglableButton )
mTapDetector.Attach( self );
mTapDetector.DetectedSignal().Connect(this, &Button::OnTap);
- OnButtonInitialize();
-
self.SetKeyboardFocusable( true );
}
return ret;
}
-void Button::OnControlStageDisconnection()
+void Button::OnStageDisconnection()
{
- OnButtonStageDisconnection(); // Notification for derived classes.
+ if( ButtonDown == mState )
+ {
+ if( !mTogglableButton )
+ {
+ Released();
+
+ if( mAutoRepeating )
+ {
+ mAutoRepeatingTimer.Reset();
+ }
+ }
+ }
+
mState = ButtonUp;
+
+ Control::OnStageDisconnection();
}
void Button::OnTap(Actor actor, const TapGesture& tap)
bool DoClickAction( const Property::Map& attributes );
/**
- * This method is called after the button initialization.
- * Could be reimplemented in subclasses to provide specific behaviour.
- */
- virtual void OnButtonInitialize() { }
-
- /**
* This method is called when the label is set.
* @param[in] noPadding Used to bypass padding if the label is to be treated generically.
*/
virtual void OnTouchPointInterrupted();
/**
- * This method is called when the button is removed from the stage.
- * Could be reimplemented in subclasses to provide specific behaviour.
- */
- virtual void OnButtonStageDisconnection();
-
- /**
* This method is called when the \e selected property is changed.
*/
virtual void OnSelected() {}
*/
static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
-protected: // From CustomActorImpl
+protected: // From Control
/**
- * @copydoc Dali::CustomActorImpl::OnTouchEvent( const TouchEvent& event )
+ * @copydoc Dali::Control::OnTouchEvent( const TouchEvent& event )
*/
virtual bool OnTouchEvent( const TouchEvent& event );
-private: // From Control
-
/**
* @copydoc Toolkit::Control::OnInitialize()
+ * @note If overridden by deriving button classes, then an up-call to Button::OnInitialize MUST be made at the start.
*/
virtual void OnInitialize();
virtual bool OnKeyboardEnter();
/**
- * Callback received when the button is disconnected from the stage.
- * It resets the button status.
+ * @copydoc Toolkit::Control::OnStageDisconnection()
+ * @note If overridden by deriving button classes, then an up-call to Button::OnStageDisconnection MUST be made at the end.
*/
- void OnControlStageDisconnection();
+ void OnStageDisconnection();
private:
}
}
-void CheckBoxButton::OnButtonInitialize()
+void CheckBoxButton::OnInitialize()
{
+ Button::OnInitialize();
+
// Wrap around all children
Self().SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
/**
- * @copydoc Toolkit::Internal::Button::OnButtonInitialize
+ * @copydoc Toolkit::Internal::Button::OnInitialize
*/
- virtual void OnButtonInitialize();
+ virtual void OnInitialize();
/**
* @copydoc Toolkit::Internal::Button::OnLabelSet
{
}
-void PushButton::OnButtonInitialize()
+void PushButton::OnInitialize()
{
+ Button::OnInitialize();
+
// Push button requires the Leave event.
Actor self = Self();
self.SetLeaveRequired( true );
private: // From Button
/**
- * @copydoc Toolkit::Internal::Button::OnButtonInitialize
+ * @copydoc Toolkit::Internal::Button::OnInitialize
*/
- virtual void OnButtonInitialize();
+ virtual void OnInitialize();
/**
* @copydoc Toolkit::Internal::Button::OnLabelSet
{
}
-void RadioButton::OnButtonInitialize()
+void RadioButton::OnInitialize()
{
+ Button::OnInitialize();
+
Actor self = Self();
// Wrap size of radio button around all its children
private: // From Button
/**
- * @copydoc Toolkit::Internal::Button::OnButtonInitialize
+ * @copydoc Toolkit::Internal::Button::OnInitialize
*/
- virtual void OnButtonInitialize();
+ virtual void OnInitialize();
/**
* @copydoc Toolkit::Internal::Button::OnButtonUp
void EffectsView::OnSizeSet(const Vector3& targetSize)
{
+ Control::OnSizeSet( targetSize );
+
mTargetSize = Vector2(targetSize);
// if we are already on stage, need to update render target sizes now to reflect the new size of this actor
{
mFilters[i]->Disable();
}
+
+ Control::OnStageDisconnection();
}
void EffectsView::SetupFilters()
void GaussianBlurView::OnSizeSet(const Vector3& targetSize)
{
+ Control::OnSizeSet( targetSize );
+
mTargetSize = Vector2(targetSize);
mChildrenRoot.SetSize(targetSize);
}
}
-void GaussianBlurView::OnControlChildAdd( Actor& child )
+void GaussianBlurView::OnChildAdd( Actor& child )
{
+ Control::OnChildAdd( child );
+
if( child != mChildrenRoot && child != mInternalRoot)
{
mChildrenRoot.Add( child );
}
}
-void GaussianBlurView::OnControlChildRemove( Actor& child )
+void GaussianBlurView::OnChildRemove( Actor& child )
{
mChildrenRoot.Remove( child );
+
+ Control::OnChildRemove( child );
}
void GaussianBlurView::AllocateResources()
virtual void OnSizeSet(const Vector3& targetSize);
/**
- * @copydoc Control::OnControlChildAdd()
+ * @copydoc Control::OnChildAdd()
*/
- virtual void OnControlChildAdd( Actor& child );
+ virtual void OnChildAdd( Actor& child );
/**
- * @copydoc Control::OnControlChildRemove()
+ * @copydoc Control::OnChildRemove()
*/
- virtual void OnControlChildRemove( Actor& child );
+ virtual void OnChildRemove( Actor& child );
void SetBlurBellCurveWidth(float blurBellCurveWidth);
float CalcGaussianWeight(float x);
void ImageView::OnSizeSet( const Vector3& targetSize )
{
+ Control::OnSizeSet( targetSize );
+
if( mRenderer )
{
Vector2 size( targetSize );
void Magnifier::OnSizeSet(const Vector3& targetSize)
{
+ Control::OnSizeSet( targetSize );
+
// TODO: Once Camera/CameraActor properties function as proper animatable properties
// this code can disappear.
// whenever the size of the magnifier changes, the field of view needs to change
return true;
}
-void Popup::OnControlStageConnection()
+void Popup::OnStageConnection( int depth )
{
+ Control::OnStageConnection( depth );
+
mLayoutDirty = true;
RelayoutRequest();
}
-void Popup::OnControlChildAdd( Actor& child )
+void Popup::OnChildAdd( Actor& child )
{
+ Control::OnChildAdd( child );
+
// Re-parent any children added by user to the body layer.
if( mAlterAddedChild )
{
/**
* Called when the popup is directly or indirectly parented to the stage.
*/
- virtual void OnControlStageConnection();
+ virtual void OnStageConnection( int depth );
/**
* From Control; called after a child has been added to the owning actor.
* @param[in] child The child which has been added.
*/
- virtual void OnControlChildAdd( Actor& child );
+ virtual void OnChildAdd( Actor& child );
/**
* @copydoc Control::OnRelayOut()
void ScrollView::OnChildAdd(Actor& child)
{
+ ScrollBase::OnChildAdd( child );
+
Dali::Toolkit::ScrollBar scrollBar = Dali::Toolkit::ScrollBar::DownCast(child);
if(scrollBar)
{
{
// TODO: Actor needs a RemoveConstraint method to take out an individual constraint.
UnbindActor(child);
+
+ ScrollBase::OnChildRemove( child );
}
void ScrollView::StartTouchDownTimer()
blurStrengthConstraint.Apply();
}
-void ShadowView::OnControlChildAdd( Actor& child )
+void ShadowView::OnChildAdd( Actor& child )
{
+ Control::OnChildAdd( child );
+
if( child != mChildrenRoot && child != mBlurRootActor)
{
mChildrenRoot.Add( child );
}
}
-void ShadowView::OnControlChildRemove( Actor& child )
+void ShadowView::OnChildRemove( Actor& child )
{
mChildrenRoot.Remove( child );
+
+ Control::OnChildRemove( child );
}
void ShadowView::ConstrainCamera()
virtual void OnInitialize();
/**
- * @copydoc Control::OnControlChildAdd()
+ * @copydoc Control::OnChildAdd()
*/
- virtual void OnControlChildAdd( Actor& child );
+ virtual void OnChildAdd( Actor& child );
/**
- * @copydoc Control::OnControlChildRemove()
+ * @copydoc Control::OnChildRemove()
*/
- virtual void OnControlChildRemove( Actor& child );
+ virtual void OnChildRemove( Actor& child );
/**
* Constrain the camera actor to the position of the point light, pointing
if( child )
{
RelayoutingLock lock( *this );
- // Remove the child, this will trigger a call to OnControlChildRemove
+ // Remove the child, this will trigger a call to OnChildRemove
Self().Remove( child );
// relayout the table only if instances were found
return value;
}
-void TableView::OnControlChildAdd( Actor& child )
+void TableView::OnChildAdd( Actor& child )
{
+ Control::OnChildAdd( child );
+
if( mLayoutingChild )
{
// we're in the middle of laying out children so no point doing anything here
RelayoutRequest();
}
-void TableView::OnControlChildRemove( Actor& child )
+void TableView::OnChildRemove( Actor& child )
{
// dont process if we're in the middle of bigger operation like delete row, column or resize
if( !mLayoutingChild )
RelayoutRequest();
}
}
+
+ Control::OnChildRemove( child );
}
TableView::TableView( unsigned int initialRows, unsigned int initialColumns )
private: // From Control
/**
- * @copydoc Control::OnControlChildAdd(Actor& child)
+ * @copydoc Control::OnChildAdd(Actor& child)
*/
- virtual void OnControlChildAdd( Actor& child );
+ virtual void OnChildAdd( Actor& child );
/**
- * @copydoc Control::OnControlChildRemove(Actor& child)
+ * @copydoc Control::OnChildRemove(Actor& child)
*/
- virtual void OnControlChildRemove( Actor& child );
+ virtual void OnChildRemove( Actor& child );
/**
* @copydoc Control::OnRelayout
mLayout.SetRelativeWidth( 1, mRightRelativeSpace );
}
-void ToolBar::OnControlChildAdd(Actor& child)
+void ToolBar::OnChildAdd(Actor& child)
{
+ Control::OnChildAdd( child );
+
if( !mInitializing )
{
// An actor is being added through the Actor's API.
AddControl( child, DEFAULT_RELATIVE_SIZE, DEFAULT_ALIGNMENT, Toolkit::ToolBar::DEFAULT_PADDING );
}
- // No OnControlChildRemove method required because Actors are added to the mLayout table view, so if an
+ // No OnChildRemove method required because Actors are added to the mLayout table view, so if an
// actor is removed using the Actor::RemoveChild method it will not remove anything because the
// actor is in mLayout not in Self().
}
* Adds a control using some default values (the control uses 10% of the tool bar space and is placed on the left group).
* @param child The control to be added.
*
- * @see Control::OnControlChildAdd()
+ * @see Control::OnChildAdd()
*/
- virtual void OnControlChildAdd(Actor& child);
+ virtual void OnChildAdd(Actor& child);
private:
/**
FreeFontFamilyNames( mFontDescriptionRuns );
}
+void LogicalModel::CreateParagraphInfo( CharacterIndex startIndex,
+ Length numberOfCharacters )
+{
+ const Length totalNumberOfCharacters = mLineBreakInfo.Count();
+
+ // Count the number of LINE_MUST_BREAK to reserve some space for the vector of paragraph's info.
+ Vector<CharacterIndex> paragraphs;
+ paragraphs.Reserve( numberOfCharacters );
+ const TextAbstraction::LineBreakInfo* lineBreakInfoBuffer = mLineBreakInfo.Begin();
+ const CharacterIndex lastCharacterIndexPlusOne = startIndex + numberOfCharacters;
+ for( Length index = startIndex; index < lastCharacterIndexPlusOne; ++index )
+ {
+ if( TextAbstraction::LINE_MUST_BREAK == *( lineBreakInfoBuffer + index ) )
+ {
+ paragraphs.PushBack( index );
+ }
+ }
+
+ // Whether the current paragraphs are updated or set from scratch.
+ const bool updateCurrentParagraphs = numberOfCharacters < totalNumberOfCharacters;
+
+ // Reserve space for current paragraphs plus new ones.
+ const Length numberOfNewParagraphs = paragraphs.Count();
+ const Length totalNumberOfParagraphs = mParagraphInfo.Count() + numberOfNewParagraphs;
+ mParagraphInfo.Resize( totalNumberOfParagraphs );
+
+ ParagraphRun* paragraphInfoBuffer = NULL;
+ Vector<ParagraphRun> newParagraphs;
+
+ if( updateCurrentParagraphs )
+ {
+ newParagraphs.Resize( numberOfNewParagraphs );
+ paragraphInfoBuffer = newParagraphs.Begin();
+ }
+ else
+ {
+ paragraphInfoBuffer = mParagraphInfo.Begin();
+ }
+
+ // Find where to insert the new paragraphs.
+ ParagraphRunIndex paragraphIndex = 0u;
+ CharacterIndex firstIndex = startIndex;
+
+ if( updateCurrentParagraphs )
+ {
+ for( Vector<ParagraphRun>::ConstIterator it = mParagraphInfo.Begin(),
+ endIt = mParagraphInfo.Begin() + totalNumberOfParagraphs - numberOfNewParagraphs;
+ it != endIt;
+ ++it )
+ {
+ const ParagraphRun& paragraph( *it );
+
+ if( startIndex < paragraph.characterRun.characterIndex + paragraph.characterRun.numberOfCharacters )
+ {
+ firstIndex = paragraph.characterRun.characterIndex;
+ break;
+ }
+
+ ++paragraphIndex;
+ }
+ }
+
+ // Create the paragraph info.
+ ParagraphRunIndex newParagraphIndex = 0u;
+ for( Vector<CharacterIndex>::ConstIterator it = paragraphs.Begin(),
+ endIt = paragraphs.End();
+ it != endIt;
+ ++it, ++newParagraphIndex )
+ {
+ const CharacterIndex index = *it;
+
+ ParagraphRun& paragraph = *( paragraphInfoBuffer + newParagraphIndex );
+ paragraph.characterRun.characterIndex = firstIndex;
+ paragraph.characterRun.numberOfCharacters = 1u + index - firstIndex;
+
+ firstIndex += paragraph.characterRun.numberOfCharacters;
+ }
+
+
+ // Insert the new paragraphs.
+ if( updateCurrentParagraphs )
+ {
+ mParagraphInfo.Insert( mParagraphInfo.Begin() + paragraphIndex,
+ newParagraphs.Begin(),
+ newParagraphs.End() );
+
+ mParagraphInfo.Resize( totalNumberOfParagraphs );
+
+ // Update the next paragraph indices.
+ for( Vector<ParagraphRun>::Iterator it = mParagraphInfo.Begin() + paragraphIndex + newParagraphs.Count(),
+ endIt = mParagraphInfo.End();
+ it != endIt;
+ ++it )
+ {
+ ParagraphRun& paragraph( *it );
+
+ paragraph.characterRun.characterIndex += numberOfCharacters;
+ }
+ }
+}
+
+void LogicalModel::FindParagraphs( CharacterIndex index,
+ Length numberOfCharacters,
+ Vector<ParagraphRunIndex>& paragraphs )
+{
+ // Reserve som space for the paragraph indices.
+ paragraphs.Reserve( mParagraphInfo.Count() );
+
+ // Traverse the paragraphs to find which ones contain the given characters.
+ ParagraphRunIndex paragraphIndex = 0u;
+ for( Vector<ParagraphRun>::ConstIterator it = mParagraphInfo.Begin(),
+ endIt = mParagraphInfo.End();
+ it != endIt;
+ ++it, ++paragraphIndex )
+ {
+ const ParagraphRun& paragraph( *it );
+
+ if( ( paragraph.characterRun.characterIndex + paragraph.characterRun.numberOfCharacters > index ) &&
+ ( paragraph.characterRun.characterIndex < index + numberOfCharacters ) )
+ {
+ paragraphs.PushBack( paragraphIndex );
+ }
+ }
+}
+
LogicalModel::~LogicalModel()
{
ClearFontDescriptionRuns();
#include <dali-toolkit/internal/text/color-run.h>
#include <dali-toolkit/internal/text/font-run.h>
#include <dali-toolkit/internal/text/font-description-run.h>
+#include <dali-toolkit/internal/text/paragraph-run.h>
#include <dali-toolkit/internal/text/script-run.h>
namespace Dali
*/
void ClearFontDescriptionRuns();
+ // Paragraphs
+
+ /**
+ * @brief Creates the paragraph info.
+ *
+ * @pre The line break info must be set.
+ *
+ * @param[in] startIndex The character from where the paragraph info is set.
+ * @param[in] numberOfCharacters The number of characters.
+ */
+ void CreateParagraphInfo( CharacterIndex startIndex,
+ Length numberOfCharacters );
+
+ /**
+ * @brief Find the paragraphs which contains the given characters.
+ *
+ * @param[in] index The first character's index of the run.
+ * @param[in] numberOfCharacters The number of characters of the run.
+ * @param[out] paragraphs Indices to the paragraphs which contain the characters.
+ */
+ void FindParagraphs( CharacterIndex index,
+ Length numberOfCharacters,
+ Vector<ParagraphRunIndex>& paragraphs );
+
protected:
/**
Vector<FontDescriptionRun> mFontDescriptionRuns;
Vector<LineBreakInfo> mLineBreakInfo;
Vector<WordBreakInfo> mWordBreakInfo;
+ Vector<ParagraphRun> mParagraphInfo;
Vector<BidirectionalParagraphInfoRun> mBidirectionalParagraphInfo;
Vector<CharacterDirection> mCharacterDirections; ///< For each character, whether is right to left. ( @e flase is left to right, @e true right to left ).
Vector<BidirectionalLineInfoRun> mBidirectionalLineInfo;
--- /dev/null
+#ifndef __DALI_TOOLKIT_TEXT_PARAGRAPH_RUN_H__
+#define __DALI_TOOLKIT_TEXT_PARAGRAPH_RUN_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/public-api/math/vector2.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/text/character-run.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Text
+{
+
+/**
+ * @brief ParagraphRun
+ *
+ * In terms of the bidirectional algorithm, a 'paragraph' is understood as a run of characters between Paragraph Separators or appropriate Newline Functions.
+ * A 'paragraph' may also be determined by higher-level protocols like a mark-up tag.
+ */
+struct ParagraphRun
+{
+ CharacterRun characterRun; ///< The initial character index within the whole text and the number of characters of the run.
+ Size layoutSize; ///< The size of the paragraph when is laid-out.
+};
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // __DALI_TOOLKIT_TEXT_PARAGRAPH_RUN_H__
{
void SetLineBreakInfo( const Vector<Character>& text,
+ CharacterIndex startIndex,
+ Length numberOfCharacters,
Vector<LineBreakInfo>& lineBreakInfo )
{
- const Length numberOfCharacters = text.Count();
+ const Length totalNumberOfCharacters = text.Count();
- if( 0u == numberOfCharacters )
+ if( 0u == totalNumberOfCharacters )
{
// Nothing to do if there are no characters.
return;
}
// Retrieve the line break info.
- lineBreakInfo.Resize( numberOfCharacters );
- TextAbstraction::Segmentation::Get().GetLineBreakPositions( text.Begin(),
+ lineBreakInfo.Resize( totalNumberOfCharacters );
+
+ // Whether the current buffer is being updated or is set from scratch.
+ const bool updateCurrentBuffer = numberOfCharacters < totalNumberOfCharacters;
+
+ LineBreakInfo* lineBreakInfoBuffer = NULL;
+ Vector<LineBreakInfo> newLineBreakInfo;
+
+ if( updateCurrentBuffer )
+ {
+ newLineBreakInfo.Resize( numberOfCharacters );
+ lineBreakInfoBuffer = newLineBreakInfo.Begin();
+ }
+ else
+ {
+ lineBreakInfoBuffer = lineBreakInfo.Begin();
+ }
+
+ // Retrieve the line break info.
+ TextAbstraction::Segmentation::Get().GetLineBreakPositions( text.Begin() + startIndex,
numberOfCharacters,
- lineBreakInfo.Begin() );
+ lineBreakInfoBuffer );
+
+ // If the line break info is updated, it needs to be inserted in the model.
+ if( updateCurrentBuffer )
+ {
+ lineBreakInfo.Insert( lineBreakInfo.Begin() + startIndex,
+ newLineBreakInfo.Begin(),
+ newLineBreakInfo.End() );
+ lineBreakInfo.Resize( totalNumberOfCharacters );
+ }
+
#ifdef DEBUG_ENABLED
if( gLogFilter->IsEnabledFor(Debug::Verbose) )
{
* - 2 is a LINE_NO_BREAK. Text can't be broken into a new line.
*
* @param[in] text Vector of UTF-32 characters.
+ * @param[in] startIndex The character from where the break info is set.
+ * @param[in] numberOfCharacters The number of characters.
* @param[out] lineBreakInfo The line break info
*/
void SetLineBreakInfo( const Vector<Character>& text,
+ CharacterIndex startIndex,
+ Length numberOfCharacters,
Vector<LineBreakInfo>& lineBreakInfo );
/**
shaping.GetGlyphs( tmpGlyphs.Begin(),
tmpGlyphToCharacterMap.Begin() );
- // Update the indices.
+ // Update the new indices of the glyph to character map.
if( 0u != totalNumberOfGlyphs )
{
for( Vector<CharacterIndex>::Iterator it = tmpGlyphToCharacterMap.Begin(),
lineBreakInfo.Resize( numberOfCharacters, TextAbstraction::LINE_NO_BREAK );
SetLineBreakInfo( utf32Characters,
+ startIndex,
+ requestedNumberOfCharacters,
lineBreakInfo );
+
+ // Create the paragraph info.
+ mLogicalModel->CreateParagraphInfo( startIndex,
+ requestedNumberOfCharacters );
}
Vector<WordBreakInfo>& wordBreakInfo = mLogicalModel->mWordBreakInfo;
newParagraphGlyphs );
// Create the 'number of glyphs' per character and the glyph to character conversion tables.
- mVisualModel->CreateGlyphsPerCharacterTable( startIndex, numberOfCharacters );
- mVisualModel->CreateCharacterToGlyphTable( startIndex, numberOfCharacters );
+ mVisualModel->CreateGlyphsPerCharacterTable( startIndex, startGlyphIndex, numberOfCharacters );
+ mVisualModel->CreateCharacterToGlyphTable( startIndex, startGlyphIndex, numberOfCharacters );
}
const Length numberOfGlyphs = glyphs.Count();
return 0.0f;
}
-void Controller::UpdateAfterFontChange( std::string& newDefaultFont )
+void Controller::UpdateAfterFontChange( const std::string& newDefaultFont )
{
DALI_LOG_INFO( gLogFilter, Debug::Concise, "Controller::UpdateAfterFontChange");
return mImpl->mTextColor;
}
-bool Controller::RemoveText( int cursorOffset, int numberOfChars )
+bool Controller::RemoveText( int cursorOffset, int numberOfCharacters )
{
bool removed = false;
return removed;
}
- DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::RemoveText %p mText.Count() %d cursor %d cursorOffset %d numberOfChars %d\n",
- this, mImpl->mLogicalModel->mText.Count(), mImpl->mEventData->mPrimaryCursorPosition, cursorOffset, numberOfChars );
+ DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::RemoveText %p mText.Count() %d cursor %d cursorOffset %d numberOfCharacters %d\n",
+ this, mImpl->mLogicalModel->mText.Count(), mImpl->mEventData->mPrimaryCursorPosition, cursorOffset, numberOfCharacters );
if( !mImpl->IsShowingPlaceholderText() )
{
cursorIndex = oldCursorIndex + cursorOffset;
}
- if( ( cursorIndex + numberOfChars ) > currentText.Count() )
+ if( ( cursorIndex + numberOfCharacters ) > currentText.Count() )
{
- numberOfChars = currentText.Count() - cursorIndex;
+ numberOfCharacters = currentText.Count() - cursorIndex;
}
- if( ( cursorIndex + numberOfChars ) <= currentText.Count() )
+ if( ( cursorIndex + numberOfCharacters ) <= currentText.Count() )
{
// Update the input style and remove the text's style before removing the text.
mImpl->mLogicalModel->RetrieveStyle( cursorIndex, mImpl->mEventData->mInputStyle );
// Remove the text's style before removing the text.
- mImpl->mLogicalModel->UpdateTextStyleRuns( cursorIndex, -numberOfChars );
+ mImpl->mLogicalModel->UpdateTextStyleRuns( cursorIndex, -numberOfCharacters );
// Remove the characters.
Vector<Character>::Iterator first = currentText.Begin() + cursorIndex;
- Vector<Character>::Iterator last = first + numberOfChars;
+ Vector<Character>::Iterator last = first + numberOfCharacters;
currentText.Erase( first, last );
// Cursor position retreat
oldCursorIndex = cursorIndex;
- DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::RemoveText %p removed %d\n", this, numberOfChars );
+ DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::RemoveText %p removed %d\n", this, numberOfCharacters );
removed = true;
}
}
// Remove the previous IMF pre-edit (predicitive text)
if( mImpl->mEventData->mPreEditFlag &&
- ( 0 != mImpl->mEventData->mPreEditLength ) )
+ ( 0u != mImpl->mEventData->mPreEditLength ) )
{
- CharacterIndex offset = mImpl->mEventData->mPrimaryCursorPosition - mImpl->mEventData->mPreEditStartPosition;
+ const CharacterIndex offset = mImpl->mEventData->mPrimaryCursorPosition - mImpl->mEventData->mPreEditStartPosition;
- removedPrevious = RemoveText( -static_cast<int>(offset), mImpl->mEventData->mPreEditLength );
+ removedPrevious = RemoveText( -static_cast<int>( offset ), mImpl->mEventData->mPreEditLength );
mImpl->mEventData->mPrimaryCursorPosition = mImpl->mEventData->mPreEditStartPosition;
- mImpl->mEventData->mPreEditLength = 0;
+ mImpl->mEventData->mPreEditLength = 0u;
}
else
{
const Length numberOfCharactersInModel = mImpl->mLogicalModel->mText.Count();
- // Restrict new text to fit within Maximum characters setting
+ // Restrict new text to fit within Maximum characters setting.
Length maxSizeOfNewText = std::min( ( mImpl->mMaximumNumberOfCharacters - numberOfCharactersInModel ), characterCount );
maxLengthReached = ( characterCount > maxSizeOfNewText );
// Transform a text array encoded in utf8 into an array encoded in utf32.
// It returns the actual number of characters.
- Length characterCount = Utf8ToUtf32( utf8, size, utf32Characters.Begin() );
+ const Length characterCount = Utf8ToUtf32( utf8, size, utf32Characters.Begin() );
utf32Characters.Resize( characterCount );
// Reset the cursor position
* @brief Remove a given number of characters
*
* @param[in] cursorOffset Start position from the current cursor position to start deleting characters.
- * @param[in] numberOfChars The number of characters to delete from the cursorOffset.
+ * @param[in] numberOfCharacters The number of characters to delete from the cursorOffset.
* @return True if the remove was successful.
*/
- bool RemoveText( int cursorOffset, int numberOfChars );
+ bool RemoveText( int cursorOffset, int numberOfCharacters );
/**
* @brief Retrieve the current cursor position.
* @ brief Update the text after a font change
* @param[in] newDefaultFont The new font to change to
*/
- void UpdateAfterFontChange( std::string& newDefaultFont );
+ void UpdateAfterFontChange( const std::string& newDefaultFont );
/**
* @brief Set the text color
typedef uint32_t BidirectionalRunIndex; ///< An index into an array of bidirectional info.
typedef uint32_t BidirectionalLineRunIndex; ///< An index into an array of bidirectional line info.
typedef uint32_t LineIndex; ///< An index into an array of lines.
+typedef uint32_t ParagraphRunIndex; ///< An index into an array of paragraphs.
} // namespace Text
-#ifndef __DALI_TOOLKIT_TEXT_STYLE_RUN_CONTAINER_H__
-#define __DALI_TOOLKIT_TEXT_STYLE_RUN_CONTAINER_H__
+#ifndef __DALI_TOOLKIT_TEXT_RUN_CONTAINER_H__
+#define __DALI_TOOLKIT_TEXT_RUN_CONTAINER_H__
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * 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.
( startIndex >= run->glyphRun.glyphIndex + run->glyphRun.numberOfGlyphs ) )
{
// Run found. Nothing else to do.
+ break;
}
++run;
} // namespace Dali
-#endif // __DALI_TOOLKIT_TEXT_STYLE_RUN_CONTAINER_H__
+#endif // __DALI_TOOLKIT_TEXT_RUN_CONTAINER_H__
}
void VisualModel::CreateCharacterToGlyphTable( CharacterIndex startIndex,
+ GlyphIndex startGlyphIndex,
Length numberOfCharacters )
{
if( 0u == numberOfCharacters )
// 2) Traverse the glyphs and set the glyph indices per character.
// Index to the glyph.
- const GlyphIndex startGlyphIndex = updateCurrentBuffer ? *( mCharactersToGlyph.Begin() + startIndex ) : 0u;
GlyphIndex glyphIndex = startGlyphIndex;
CharacterIndex characterIndex = startIndex;
const CharacterIndex lastCharacterIndexPlusOne = startIndex + numberOfCharacters;
}
void VisualModel::CreateGlyphsPerCharacterTable( CharacterIndex startIndex,
+ GlyphIndex startGlyphIndex,
Length numberOfCharacters )
{
if( 0u == numberOfCharacters )
// 2) Traverse the glyphs and set the number of glyphs per character.
- // The glyph index.
- const GlyphIndex glyphIndex = updateCurrentBuffer ? *( mCharactersToGlyph.Begin() + startIndex ) : 0u;
Length traversedCharacters = 0;
// The number of 'characters per glyph' equal to zero.
Length zeroCharactersPerGlyph = 0u;
- for( Vector<Length>::ConstIterator it = mCharactersPerGlyph.Begin() + glyphIndex,
+ for( Vector<Length>::ConstIterator it = mCharactersPerGlyph.Begin() + startGlyphIndex,
endIt = mCharactersPerGlyph.End();
( it != endIt ) && ( traversedCharacters < numberOfCharacters );
++it )
* @pre The glyphs per character table needs to be created first.
*
* @param[in] startIndex The character from where the conversion table is created.
+ * @param[in] startGlyphIndex The glyph from where the conversion table is created.
* @param[in] numberOfCharacters The number of characters.
*/
void CreateCharacterToGlyphTable( CharacterIndex startIndex,
+ GlyphIndex startGlyphIndex,
Length numberOfCharacters );
/**
* @brief Creates an array containing the number of glyphs per character.
*
* @param[in] startIndex The character from where the table is created.
+ * @param[in] startGlyphIndex The glyph from where the conversion table is created.
* @param[in] numberOfCharacters The number of characters.
*/
void CreateGlyphsPerCharacterTable( CharacterIndex startIndex,
+ GlyphIndex startGlyphIndex,
Length numberOfCharacters );
/**
void CubeTransitionEffect::OnStageConnection( int depth )
{
+ Control::OnStageConnection( depth );
+
Geometry geometry = CreateQuadGeometry();
Shader shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
}
mTargetRenderer.Reset();
}
+
+ Control::OnStageDisconnection();
}
void CubeTransitionEffect::SetTransitionDuration( float duration )
mLongPressGestureDetector(),
mFlags( Control::ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) ),
mIsKeyboardNavigationSupported( false ),
- mIsKeyboardFocusGroup( false ),
- mAddRemoveBackgroundChild( false )
+ mIsKeyboardFocusGroup( false )
{
}
ControlBehaviour mFlags :CONTROL_BEHAVIOUR_FLAG_COUNT; ///< Flags passed in from constructor.
bool mIsKeyboardNavigationSupported :1; ///< Stores whether keyboard navigation is supported by the control.
bool mIsKeyboardFocusGroup :1; ///< Stores whether the control is a focus group.
- bool mAddRemoveBackgroundChild:1; ///< Flag to know when we are adding or removing our own actor to avoid call to OnControlChildAdd
// Properties - these need to be members of Internal::Control::Impl as they need to function within this class.
static const PropertyRegistration PROPERTY_1;
void Control::OnChildAdd(Actor& child)
{
- // If this is the background actor, then we do not want to inform deriving classes
- if ( mImpl->mAddRemoveBackgroundChild )
- {
- return;
- }
-
// Notify derived classes.
OnControlChildAdd( child );
}
void Control::OnChildRemove(Actor& child)
{
- // If this is the background actor, then we do not want to inform deriving classes
- if ( mImpl->mAddRemoveBackgroundChild )
- {
- return;
- }
-
// Notify derived classes.
OnControlChildRemove( child );
}
void Control::OnSizeSet(const Vector3& targetSize)
{
- // Background is resized through size negotiation
+ if( mImpl->mBackgroundRenderer )
+ {
+ Vector2 size( targetSize );
+ mImpl->mBackgroundRenderer.SetSize( size );
+ }
}
void Control::OnSizeAnimation(Animation& animation, const Vector3& targetSize)
/**
* @copydoc CustomActorImpl::OnStageConnection()
+ * @note If overridden, then an up-call to Control::OnStageConnection MUST be made at the start.
*/
virtual void OnStageConnection( int depth );
/**
* @copydoc CustomActorImpl::OnStageDisconnection()
+ * @note If overridden, then an up-call to Control::OnStageDisconnection MUST be made at the end.
*/
virtual void OnStageDisconnection();
/**
* @copydoc CustomActorImpl::OnChildAdd()
+ * @note If overridden, then an up-call to Control::OnChildAdd MUST be made at the start.
*/
virtual void OnChildAdd( Actor& child );
/**
* @copydoc CustomActorImpl::OnChildRemove()
+ * @note If overridden, then an up-call to Control::OnChildRemove MUST be made at the end.
*/
virtual void OnChildRemove( Actor& child );
/**
* @copydoc CustomActorImpl::OnSizeSet()
+ * @note If overridden, then an up-call to Control::OnSizeSet MUST be made at the start.
*/
virtual void OnSizeSet( const Vector3& targetSize );
/**
* @copydoc CustomActorImpl::OnSizeAnimation()
+ * @note If overridden, then an up-call to Control::OnSizeAnimation MUST be made at the start.
*/
virtual void OnSizeAnimation( Animation& animation, const Vector3& targetSize );
virtual void OnInitialize();
/**
+ * @DEPRECATED_1_1.30. Override OnChildAdd instead.
+ *
* @brief Called whenever an Actor is added to the control.
*
* Could be overridden by derived classes.
virtual void OnControlChildAdd( Actor& child );
/**
+ * @DEPRECATED_1_1.30. Override OnChildRemove instead.
+ *
* @brief Called whenever an Actor is removed from the control.
*
* Could be overridden by derived classes.
const unsigned int TOOLKIT_MAJOR_VERSION = 1;
const unsigned int TOOLKIT_MINOR_VERSION = 1;
-const unsigned int TOOLKIT_MICRO_VERSION = 28;
+const unsigned int TOOLKIT_MICRO_VERSION = 29;
const char * const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__;
#ifdef DEBUG_ENABLED
customControl.MyCustomSignal.Connect( this, &AppFunction );
~~~
+
+___________________________________________________________________________________________________
+
+### Children Added/Removed {#creating-controls-children}
+
+Methods are provided that can be overridden if notification is required when a child is added or removed from our control.
+An up call to the Control class is necessary if these methods are overridden.
+
+~~~{.cpp}
+// C++
+void MyUIControlImpl::OnChildAdd( Actor& child );
+{
+ // Up call to Control first
+ Control::OnChildAdd( child );
+
+ // Do any other operations required upon child addition
+}
+~~~
+~~~{.cpp}
+// C++
+void MyUIControlImpl::OnChildRemove( Actor& child );
+{
+ // Do any other operations required upon child removal
+
+ // Up call to Control at the end
+ Control::OnChildRemove( child );
+}
+~~~
+
+Avoid adding or removing the child again within these methods.
+
+___________________________________________________________________________________________________
+
+### Stage Connection {#creating-controls-stage}
+
+Methods are provided that can be overridden if notification is required when our control is connected to or disconnected from the stage.
+An up call to the Control class is necessary if these methods are overridden.
+
+~~~{.cpp}
+// C++
+void MyUIControlImpl::OnStageConnection( int depth )
+{
+ // Up call to Control first
+ Control::OnStageConnection( depth );
+
+ // Do any other operations required upon stage connection
+}
+~~~
+~~~{.cpp}
+// C++
+void MyUIControlImpl::OnStageDisconnection()
+{
+ // Do any other operations required upon stage disconnection
+
+ // Up call to Control at the end
+ Control::OnStageDisconnection();
+}
+~~~
+
+___________________________________________________________________________________________________
+
+### Size {#creating-controls-size}
+
+Methods are provided that can be overridden if notification is required when our control's size is manipulated.
+An up call to the Control class is necessary if these methods are overridden.
+
+~~~{.cpp}
+// C++
+void MyUIControlImpl::OnSizeSet( const Vector3& targetSize )
+{
+ // Up call to Control
+ Control::OnSizeSet( targetSize );
+
+ // Do any other operations required upon size set
+}
+~~~
+~~~{.cpp}
+// C++
+void MyUIControlImpl::OnSizeAnimation( Animation& animation, const Vector3& targetSize )
+{
+ // Up call to Control
+ Control::OnSizeAnimation( animation, targetSize );
+
+ // Do any other operations required upon size animation
+}
+~~~
+
___________________________________________________________________________________________________
### Other Features {#creating-controls-other}
Name: dali-toolkit
Summary: The OpenGLES Canvas Core Library Toolkit
-Version: 1.1.28
+Version: 1.1.29
Release: 1
Group: System/Libraries
License: Apache-2.0 and BSD-2-Clause and MIT