#include <dali.h>
#include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/controls/control-devel.h>
#include <dali/devel-api/adaptor-framework/accessibility.h>
#include <dali/devel-api/adaptor-framework/accessibility-bridge.h>
END_TEST;
}
+
+int utcDaliAccessibilityHidden(void)
+{
+ ToolkitTestApplication application;
+
+ auto control = Toolkit::Control::New();
+ auto* accessible = Dali::Accessibility::Accessible::Get(control);
+
+ // Check not hidden
+ DALI_TEST_CHECK(accessible);
+ DALI_TEST_CHECK(!accessible->IsHidden());
+ DALI_TEST_CHECK(!control.GetProperty<bool>(Toolkit::DevelControl::Property::ACCESSIBILITY_HIDDEN));
+
+ control.SetProperty(Toolkit::DevelControl::Property::ACCESSIBILITY_HIDDEN, true);
+
+ // Check hidden
+ DALI_TEST_CHECK(accessible->IsHidden());
+ DALI_TEST_CHECK(control.GetProperty<bool>(Toolkit::DevelControl::Property::ACCESSIBILITY_HIDDEN));
+
+ END_TEST;
+}
child_1_accessible -> GetIndexInParent();
DALI_ABORT("Object has parent, test abort");
}
- catch (Dali::DaliException &){}
+ catch (const std::domain_error&){}
parent.Add(child_1);
parent.Add(child_2);
DALI_TEST_EQUALS(accessible->IsScrollable(), false, TEST_LOCATION);
DALI_TEST_EQUALS(accessible->ScrollToChild({}), false, TEST_LOCATION);
- DALI_TEST_EQUALS(accessible->GetInternalActor(), Dali::Actor{}, TEST_LOCATION);
+ DALI_TEST_EQUALS(accessible->GetInternalActor(), label, TEST_LOCATION);
Dali::Accessibility::TestEnableSC( false );
END_TEST;
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
END_TEST;
}
+
+int UtcDaliDebugRenderingGetVisual3(void)
+{
+ EnvironmentVariable::SetTestingEnvironmentVariable( true );
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliDebugRenderingGetVisual3: Request visual with various parameters" );
+
+ VisualFactory factory = VisualFactory::Get();
+ DALI_TEST_CHECK( factory );
+
+ // Test that image visual is replaced with debug visual
+ Dali::Property::Map map;
+ map[ Toolkit::Visual::Property::TYPE ] = Visual::IMAGE;
+ map[ ImageVisual::Property::URL ] = TEST_IMAGE_FILE_NAME;
+ Visual::Base imageVisual = factory.CreateVisual( map );
+ DALI_TEST_CHECK( imageVisual );
+ TestDebugVisual( application.GetScene(), imageVisual, Visual::IMAGE, Vector2(64.0f, 64.0f /* Broken Image Size */ ));
+
+ // Test that image visual with null string don't make visual
+ map.Clear();
+ map[ Toolkit::Visual::Property::TYPE ] = Visual::IMAGE;
+ map[ ImageVisual::Property::URL ] = "";
+ Visual::Base emptyVisual = factory.CreateVisual( map );
+ DALI_TEST_CHECK( emptyVisual );
+ TestDebugVisual( application.GetScene(), emptyVisual, Visual::WIREFRAME, Vector2::ZERO);
+
+ tet_infoline( "Check that GetVisualObject returns the actual WireframeVisual" );
+ Toolkit::Internal::Visual::Base& visualImpl = GetImplementation( emptyVisual ).GetVisualObject();
+ DALI_TEST_CHECK( dynamic_cast< Toolkit::Internal::WireframeVisual* >( &visualImpl ) );
+
+ tet_infoline( "Compare the returned emptyVisual with the visual implementation, should be the same" );
+ DALI_TEST_CHECK( emptyVisual.GetObjectPtr() == &visualImpl );
+
+ // Test that image view with empty property map don't make visual even DebugRendering is enabled.
+ map.Clear();
+ ImageView imageView = ImageView::New();
+ imageView.SetProperty(Control::Property::BACKGROUND, map);
+ imageView.SetProperty(ImageView::Property::IMAGE, map);
+
+ application.GetScene().Add(imageView);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( imageView.GetRendererCount(), 0u, TEST_LOCATION );
+
+ EnvironmentVariable::SetTestingEnvironmentVariable(false);
+ END_TEST;
+}
+
+
int UtcDaliDebugRenderingGetVisualObject01(void)
{
EnvironmentVariable::SetTestingEnvironmentVariable( true );
tet_infoline( "Compare the returned TextVisual with the visual implementation, should differ" );
DALI_TEST_CHECK( textVisual.GetObjectPtr() != &visualImpl );
+ EnvironmentVariable::SetTestingEnvironmentVariable( false );
END_TEST;
}
}
END_TEST;
-}
+}
\ No newline at end of file
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
*
*/
-#include <iostream>
#include <stdlib.h>
+#include <iostream>
#include <dali-toolkit-test-suite-utils.h>
#include <dali-toolkit/dali-toolkit.h>
-#include <dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager.h>
#include <dali-toolkit/internal/controls/text-controls/text-editor-impl.h>
-#include <dali-toolkit/internal/text/text-controller.h>
+#include <dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager.h>
#include <dali-toolkit/internal/text/text-controller-impl.h>
+#include <dali-toolkit/internal/text/text-controller.h>
using namespace Dali;
using namespace Toolkit;
int UtcDaliTextEditorSelectText(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliTextEditorSelectText" );
+ tet_infoline("UtcDaliTextEditorSelectText");
// Create a text editor
TextEditor textEditor = TextEditor::New();
- textEditor.SetProperty( Actor::Property::SIZE, Vector2( 400.f, 60.f ) );
- textEditor.SetProperty( TextEditor::Property::TEXT, "Hello World" );
+ textEditor.SetProperty(Actor::Property::SIZE, Vector2(400.f, 60.f));
+ textEditor.SetProperty(TextEditor::Property::TEXT, "Hello World");
// Add the text editor to the stage
- application.GetScene().Add( textEditor );
+ application.GetScene().Add(textEditor);
application.SendNotification();
application.Render();
- Toolkit::Internal::TextEditor& textEditorImpl = GetImpl( textEditor );
+ Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor);
application.SendNotification();
application.Render();
application.Render();
std::string selectedText = textEditorImpl.GetSelectedText();
- DALI_TEST_CHECK( selectedText == "Hello World" );
+ DALI_TEST_CHECK(selectedText == "Hello World");
// Select None
textEditorImpl.SelectNone();
application.Render();
selectedText = textEditorImpl.GetSelectedText();
- DALI_TEST_CHECK( selectedText == "" );
+ DALI_TEST_CHECK(selectedText == "");
END_TEST;
}
TextEditor textEditor = TextEditor::New();
- application.GetScene().Add( textEditor );
+ application.GetScene().Add(textEditor);
- textEditor.SetProperty( TextEditor::Property::TEXT, "<u>ABC</u>EF<u>GH</u>" );
- textEditor.SetProperty( TextEditor ::Property::ENABLE_MARKUP, true );
+ textEditor.SetProperty(TextEditor::Property::TEXT, "<u>ABC</u>EF<u>GH</u>");
+ textEditor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true);
application.SendNotification();
application.Render();
uint32_t expectedNumberOfUnderlinedGlyphs = 5u;
- Toolkit::Internal::TextEditor& textEditorImpl = GetImpl( textEditor );
- const Text::Length numberOfUnderlineRuns = textEditorImpl.GetTextController()->GetTextModel()->GetNumberOfUnderlineRuns();
+ Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor);
+ const Text::Length numberOfUnderlineRuns = textEditorImpl.GetTextController()->GetTextModel()->GetNumberOfUnderlineRuns();
- DALI_TEST_EQUALS( numberOfUnderlineRuns, expectedNumberOfUnderlinedGlyphs, TEST_LOCATION );
+ DALI_TEST_EQUALS(numberOfUnderlineRuns, expectedNumberOfUnderlinedGlyphs, TEST_LOCATION);
Vector<GlyphRun> underlineRuns;
underlineRuns.Resize(numberOfUnderlineRuns);
textEditorImpl.GetTextController()->GetTextModel()->GetUnderlineRuns(underlineRuns.Begin(), 0u, numberOfUnderlineRuns);
//ABC are underlined
- DALI_TEST_EQUALS( underlineRuns[0u].glyphIndex, 0u, TEST_LOCATION);
- DALI_TEST_EQUALS( underlineRuns[1u].glyphIndex, 1u, TEST_LOCATION);
- DALI_TEST_EQUALS( underlineRuns[2u].glyphIndex, 2u, TEST_LOCATION);
+ DALI_TEST_EQUALS(underlineRuns[0u].glyphIndex, 0u, TEST_LOCATION);
+ DALI_TEST_EQUALS(underlineRuns[1u].glyphIndex, 1u, TEST_LOCATION);
+ DALI_TEST_EQUALS(underlineRuns[2u].glyphIndex, 2u, TEST_LOCATION);
//GH are underlined
- DALI_TEST_EQUALS( underlineRuns[3u].glyphIndex, 5u, TEST_LOCATION);
- DALI_TEST_EQUALS( underlineRuns[4u].glyphIndex, 6u, TEST_LOCATION);
+ DALI_TEST_EQUALS(underlineRuns[3u].glyphIndex, 5u, TEST_LOCATION);
+ DALI_TEST_EQUALS(underlineRuns[4u].glyphIndex, 6u, TEST_LOCATION);
END_TEST;
}
// Create a text editor
TextEditor textEditor = TextEditor::New();
//Set size to avoid automatic eliding
- textEditor.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
+ textEditor.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
//Set very large font-size using point-size
- textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 1000);
+ textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 1000);
//Specify font-family
- textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
+ textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
//Set text to check if appear or not
textEditor.SetProperty(TextEditor::Property::TEXT, "A");
- application.GetScene().Add( textEditor );
+ application.GetScene().Add(textEditor);
application.SendNotification();
application.Render();
//Check if Glyph is added to AtlasGlyphManger or not
int countAtlas = AtlasGlyphManager::Get().GetMetrics().mAtlasMetrics.mAtlasCount;
- DALI_TEST_EQUALS( countAtlas, 1, TEST_LOCATION );
+ DALI_TEST_EQUALS(countAtlas, 1, TEST_LOCATION);
END_TEST;
}
-
int UtcDaliTextEditorFontPointSizeLargerThanAtlasPlaceholderCase(void)
{
ToolkitTestApplication application;
//Set Map of placeholder: text, font-family and point-size
Property::Map placeholderMapSet;
- placeholderMapSet["text"] = "A";
+ placeholderMapSet["text"] = "A";
placeholderMapSet["fontFamily"] = "DejaVu Sans";
- placeholderMapSet["pixelSize"] = 1000.0f;
+ placeholderMapSet["pixelSize"] = 1000.0f;
// Create a text editor
TextEditor textEditor = TextEditor::New();
//Set size to avoid automatic eliding
- textEditor.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
+ textEditor.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
//Set placeholder
- textEditor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet) ;
+ textEditor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet);
- application.GetScene().Add( textEditor );
+ application.GetScene().Add(textEditor);
application.SendNotification();
application.Render();
//Check if Glyph is added to AtlasGlyphManger or not
int countAtlas = AtlasGlyphManager::Get().GetMetrics().mAtlasMetrics.mAtlasCount;
- DALI_TEST_EQUALS( countAtlas, 1, TEST_LOCATION );
+ DALI_TEST_EQUALS(countAtlas, 1, TEST_LOCATION);
END_TEST;
}
tet_infoline("UtcDaliTextEditorBackgroundTag\n");
TextEditor editor = TextEditor::New();
- DALI_TEST_CHECK( editor );
+ DALI_TEST_CHECK(editor);
- editor.SetProperty( TextEditor ::Property::ENABLE_MARKUP, true );
- editor.SetProperty( TextEditor::Property::TEXT, "H<background color='red'>e</background> Worl<background color='yellow'>d</background>" );
- application.GetScene().Add( editor );
+ editor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true);
+ editor.SetProperty(TextEditor::Property::TEXT, "H<background color='red'>e</background> Worl<background color='yellow'>d</background>");
+ application.GetScene().Add(editor);
application.SendNotification();
application.Render();
- Toolkit::Internal::TextEditor& editorImpl = GetImpl( editor );
- const ColorIndex* const backgroundColorIndicesBuffer = editorImpl.GetTextController()->GetTextModel()->GetBackgroundColorIndices();
+ Toolkit::Internal::TextEditor& editorImpl = GetImpl(editor);
+ const ColorIndex* const backgroundColorIndicesBuffer = editorImpl.GetTextController()->GetTextModel()->GetBackgroundColorIndices();
- DALI_TEST_CHECK( backgroundColorIndicesBuffer );
+ DALI_TEST_CHECK(backgroundColorIndicesBuffer);
//default color
- DALI_TEST_EQUALS( backgroundColorIndicesBuffer[0], 0u, TEST_LOCATION);
+ DALI_TEST_EQUALS(backgroundColorIndicesBuffer[0], 0u, TEST_LOCATION);
//red color
- DALI_TEST_EQUALS( backgroundColorIndicesBuffer[1], 1u, TEST_LOCATION);
+ DALI_TEST_EQUALS(backgroundColorIndicesBuffer[1], 1u, TEST_LOCATION);
//yellow color
- DALI_TEST_EQUALS( backgroundColorIndicesBuffer[7], 2u, TEST_LOCATION);
+ DALI_TEST_EQUALS(backgroundColorIndicesBuffer[7], 2u, TEST_LOCATION);
END_TEST;
}
tet_infoline("UtcDaliTextEditorTextWithSpan\n");
TextEditor editor = TextEditor::New();
- DALI_TEST_CHECK( editor );
+ DALI_TEST_CHECK(editor);
- editor.SetProperty( TextEditor ::Property::ENABLE_MARKUP, true );
- editor.SetProperty( TextEditor::Property::TEXT, "Hello Span" );
- application.GetScene().Add( editor );
+ editor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true);
+ editor.SetProperty(TextEditor::Property::TEXT, "Hello Span");
+ application.GetScene().Add(editor);
application.SendNotification();
application.Render();
Vector3 originalSize = editor.GetNaturalSize();
- editor.SetProperty( TextEditor::Property::TEXT, "H<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red'>ello</span> Span" );
+ editor.SetProperty(TextEditor::Property::TEXT, "H<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red'>ello</span> Span");
application.SendNotification();
application.Render();
DALI_TEST_GREATER(spanSize.width, originalSize.width, TEST_LOCATION);
- Toolkit::Internal::TextEditor& editorImpl = GetImpl( editor );
- const ColorIndex* const colorIndicesBuffer1 = editorImpl.GetTextController()->GetTextModel()->GetColorIndices();
+ Toolkit::Internal::TextEditor& editorImpl = GetImpl(editor);
+ const ColorIndex* const colorIndicesBuffer1 = editorImpl.GetTextController()->GetTextModel()->GetColorIndices();
- DALI_TEST_CHECK( colorIndicesBuffer1 );
+ DALI_TEST_CHECK(colorIndicesBuffer1);
//default color
- DALI_TEST_EQUALS( colorIndicesBuffer1[0], 0u, TEST_LOCATION);
+ DALI_TEST_EQUALS(colorIndicesBuffer1[0], 0u, TEST_LOCATION);
//span color
- DALI_TEST_EQUALS( colorIndicesBuffer1[1], 1u, TEST_LOCATION);
+ DALI_TEST_EQUALS(colorIndicesBuffer1[1], 1u, TEST_LOCATION);
//default color
- DALI_TEST_EQUALS( colorIndicesBuffer1[6], 0u, TEST_LOCATION);
-
+ DALI_TEST_EQUALS(colorIndicesBuffer1[6], 0u, TEST_LOCATION);
- editor.SetProperty( TextEditor::Property::TEXT, "<span font-size='45'>H</span>ello <span text-color='red'>S</span>pan" );
+ editor.SetProperty(TextEditor::Property::TEXT, "<span font-size='45'>H</span>ello <span text-color='red'>S</span>pan");
application.SendNotification();
application.Render();
const ColorIndex* const colorIndicesBuffer2 = editorImpl.GetTextController()->GetTextModel()->GetColorIndices();
- DALI_TEST_CHECK( colorIndicesBuffer2 );
+ DALI_TEST_CHECK(colorIndicesBuffer2);
//default color
- DALI_TEST_EQUALS( colorIndicesBuffer2[0], 0u, TEST_LOCATION);
+ DALI_TEST_EQUALS(colorIndicesBuffer2[0], 0u, TEST_LOCATION);
//default color
- DALI_TEST_EQUALS( colorIndicesBuffer2[1], 0u, TEST_LOCATION);
+ DALI_TEST_EQUALS(colorIndicesBuffer2[1], 0u, TEST_LOCATION);
//span color
- DALI_TEST_EQUALS( colorIndicesBuffer2[6], 1u, TEST_LOCATION);
+ DALI_TEST_EQUALS(colorIndicesBuffer2[6], 1u, TEST_LOCATION);
//default color
- DALI_TEST_EQUALS( colorIndicesBuffer2[7], 0u, TEST_LOCATION);
+ DALI_TEST_EQUALS(colorIndicesBuffer2[7], 0u, TEST_LOCATION);
END_TEST;
}
application.SendNotification();
application.Render();
- Toolkit::Internal::TextEditor& editorImpl = GetImpl(editor);
- ControllerPtr controller = editorImpl.GetTextController();
- Controller::Impl& controllerImpl = Controller::Impl::GetImplementation(*controller.Get());
+ Toolkit::Internal::TextEditor& editorImpl = GetImpl(editor);
+ ControllerPtr controller = editorImpl.GetTextController();
+ Controller::Impl& controllerImpl = Controller::Impl::GetImplementation(*controller.Get());
// Default color is transparent
controllerImpl.mEditableControlInterface->GetControlBackgroundColor(backgroundColor);
END_TEST;
}
+
+int UtcDaliTextEditorTextPositionWithMinLineAndBigFont(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextEditorTextPositionWithMinLine ");
+
+ TextEditor textEditor = TextEditor::New();
+
+ textEditor.SetProperty(TextEditor::Property::TEXT, "<span font-size='45'>H</span>\ni");
+ textEditor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 50);
+ textEditor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true);
+
+ application.GetScene().Add(textEditor);
+
+ application.SendNotification();
+ application.Render();
+
+ Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor);
+ Text::ViewInterface& view = textEditorImpl.GetTextController()->GetView();
+
+ Length numberOfGlyphs = view.GetNumberOfGlyphs();
+
+ DALI_TEST_EQUALS(numberOfGlyphs, 3u, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
+
+ Vector<GlyphInfo> glyphs;
+ glyphs.Resize(numberOfGlyphs);
+
+ Vector<Vector2> positions;
+ positions.Resize(numberOfGlyphs);
+
+ float alignmentOffset = 0u;
+ numberOfGlyphs = view.GetGlyphs(glyphs.Begin(),
+ positions.Begin(),
+ alignmentOffset,
+ 0u,
+ numberOfGlyphs);
+
+ DALI_TEST_EQUALS(positions[2].y, 165.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
+
+ END_TEST;
+}
\ No newline at end of file
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
DALI_TEST_CHECK( value.Get( map ) ); // Value should NOT be empty
DALI_TEST_CHECK( ! visual ); // Visual should be invalid
+ // Set a URL in property map again
+ propertyMap[ImageVisual::Property::URL] = gImage_34_RGBA;
+ imageView.SetProperty( ImageView::Property::IMAGE, propertyMap );
+
+ application.SendNotification();
+ application.Render( 16 );
+
+ value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
+ visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
+
+ DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
+ DALI_TEST_CHECK( value.Get( map ) ); // Value should NOT be empty
+ DALI_TEST_CHECK( visual ); // Visual should be valid
+
+ // Set an empty property map
+ propertyMap.Clear();
+ imageView.SetProperty( ImageView::Property::IMAGE, propertyMap );
+
+ application.SendNotification();
+ application.Render( 16 );
+
+ value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
+ visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
+
+ DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
+ DALI_TEST_CHECK( value.Get( map ) ); // Value should NOT be empty
+ DALI_TEST_CHECK( map.Empty() ); // But PropertyMap should be empty
+ DALI_TEST_CHECK( ! visual ); // Visual should be invalid
+
END_TEST;
}
END_TEST;
}
+int UtcDaliImageViewImageLoadFailure04(void)
+{
+ ToolkitTestApplication application;
+
+ ImageView imageView = ImageView::New("invalidUrl.png");
+ imageView.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
+ application.GetScene().Add( imageView );
+ application.SendNotification();
+ application.Render(16);
+
+ // loading started, this waits for the loader thread
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+
+
+ Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
+ DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_S);
+ DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, "invalidBroken.png");
+ DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
+
+ ImageView imageView2 = ImageView::New("invalidUrl.png");
+ imageView2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
+ application.GetScene().Add( imageView2 );
+
+ std::string brokenUrl;
+ brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL);
+ DALI_TEST_EQUALS( TEST_BROKEN_IMAGE_S, brokenUrl, TEST_LOCATION);
+
+ brokenUrl = DevelStyleManager::GetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE);
+ DALI_TEST_EQUALS( TEST_BROKEN_IMAGE_L, brokenUrl, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render(16);
+
+ // loading started, this waits for the loader thread
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+
+
+ DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, "invalidBroken.9.png");
+
+ ImageView imageView3 = ImageView::New("invalidUrl.png");
+ imageView3.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
+ application.GetScene().Add( imageView3 );
+
+ application.SendNotification();
+ application.Render(16);
+
+ // loading started, this waits for the loader thread
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+
+ END_TEST;
+}
+
+
namespace
{
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
DALI_TEST_CHECK( value );
DALI_TEST_CHECK( value->Get<int>() == WrapMode::MIRRORED_REPEAT);
- value = resultMap.Find( "synchronousLoading", Property::BOOLEAN );
+ value = resultMap.Find( ImageVisual::Property::SYNCHRONOUS_LOADING, Property::BOOLEAN );
DALI_TEST_CHECK( value );
DALI_TEST_CHECK( value->Get<bool>() == true );
} // unnamed namespace
ControlAccessible::ControlAccessible(Dali::Actor self, Dali::Accessibility::Role role, bool modal)
-: mSelf(self),
+: ActorAccessible(self),
mIsModal(modal)
{
auto control = Dali::Toolkit::Control::DownCast(Self());
return {};
}
-Dali::Accessibility::Accessible* ControlAccessible::GetParent()
-{
- return Dali::Accessibility::Accessible::Get(Self().GetParent());
-}
-
-size_t ControlAccessible::GetChildCount() const
-{
- return Self().GetChildCount();
-}
-
-Dali::Accessibility::Accessible* ControlAccessible::GetChildAtIndex(size_t index)
-{
- return Dali::Accessibility::Accessible::Get(Self().GetChildAt(static_cast<unsigned int>(index)));
-}
-
-size_t ControlAccessible::GetIndexInParent()
-{
- auto self = Self();
- auto parent = self.GetParent();
- DALI_ASSERT_ALWAYS(parent && "can't call GetIndexInParent on object without parent");
-
- auto count = parent.GetChildCount();
- for(auto i = 0u; i < count; ++i)
- {
- auto child = parent.GetChildAt(i);
- if(child == self)
- {
- return i;
- }
- }
- DALI_ASSERT_ALWAYS(false && "object isn't child of it's parent");
- return static_cast<size_t>(-1);
-}
-
Dali::Accessibility::Role ControlAccessible::GetRole() const
{
return Self().GetProperty<Dali::Accessibility::Role>(Toolkit::DevelControl::Property::ACCESSIBILITY_ROLE);
return attributeMap;
}
-Dali::Accessibility::ComponentLayer ControlAccessible::GetLayer() const
+bool ControlAccessible::IsHidden() const
{
- return Dali::Accessibility::ComponentLayer::WINDOW;
-}
-
-Dali::Rect<> ControlAccessible::GetExtents(Dali::Accessibility::CoordinateType type) const
-{
- Dali::Actor self = Self();
-
- Vector2 screenPosition = self.GetProperty(Dali::DevelActor::Property::SCREEN_POSITION).Get<Vector2>();
- auto size = self.GetCurrentProperty<Vector3>(Actor::Property::SIZE) * self.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE);
- bool positionUsesAnchorPoint = self.GetProperty(Dali::DevelActor::Property::POSITION_USES_ANCHOR_POINT).Get<bool>();
- Vector3 anchorPointOffSet = size * (positionUsesAnchorPoint ? self.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT) : AnchorPoint::TOP_LEFT);
- Vector2 position = Vector2((screenPosition.x - anchorPointOffSet.x), (screenPosition.y - anchorPointOffSet.y));
-
- if(type == Dali::Accessibility::CoordinateType::WINDOW)
- {
- return {position.x, position.y, size.x, size.y};
- }
- else // Dali::Accessibility::CoordinateType::SCREEN
- {
- auto window = Dali::DevelWindow::Get(self);
- auto windowPosition = window.GetPosition();
- return {position.x + windowPosition.GetX(), position.y + windowPosition.GetY(), size.x, size.y};
- }
-}
+ auto control = Dali::Toolkit::Control::DownCast(Self());
-int16_t ControlAccessible::GetMdiZOrder() const
-{
- return 0;
-}
+ Internal::Control& internalControl = Toolkit::Internal::GetImplementation(control);
+ Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get(internalControl);
-double ControlAccessible::GetAlpha() const
-{
- return 0;
+ return controlImpl.mAccessibilityHidden;
}
bool ControlAccessible::GrabFocus()
return ret;
}
-Dali::Actor ControlAccessible::GetInternalActor()
-{
- return Dali::Actor{};
-}
-
bool ControlAccessible::ScrollToChild(Actor child)
{
return false;
// EXTERNAL INCLUDES
#include <dali/devel-api/adaptor-framework/accessibility.h>
#include <dali/devel-api/adaptor-framework/accessibility-bridge.h>
-#include <dali/devel-api/atspi-interfaces/accessible.h>
+#include <dali/devel-api/adaptor-framework/actor-accessible.h>
#include <dali/devel-api/atspi-interfaces/action.h>
-#include <dali/devel-api/atspi-interfaces/collection.h>
-#include <dali/devel-api/atspi-interfaces/component.h>
#include <dali/public-api/object/weak-handle.h>
// INTERNAL INCLUDES
* @see Dali::Accessibility::Text
* @see Dali::Accessibility::EditableText
*/
-struct DALI_TOOLKIT_API ControlAccessible : public virtual Dali::Accessibility::Accessible,
- public virtual Dali::Accessibility::Component,
- public virtual Dali::Accessibility::Collection,
+struct DALI_TOOLKIT_API ControlAccessible : public Dali::Accessibility::ActorAccessible,
public virtual Dali::Accessibility::Action
{
protected:
Vector2 mLastPosition{0.0f, 0.0f};
- Dali::WeakHandle<Dali::Actor> mSelf;
Dali::WeakHandle<Dali::Actor> mCurrentHighlightActor;
bool mIsModal = false;
bool mIsRoot = false;
- Dali::Actor Self() const
- {
- auto handle = mSelf.GetHandle();
-
- // Control::Impl holds a std::unique_ptr to the Accessible object,
- // so that one does not outlive the other.
- DALI_ASSERT_ALWAYS(handle);
-
- return handle;
- }
-
void ScrollToSelf();
/**
virtual std::string GetDescriptionRaw() const;
/**
- * @copydoc Dali::Accessibility::Accessible::GetParent()
- */
- Dali::Accessibility::Accessible* GetParent() override;
-
- /**
- * @copydoc Dali::Accessibility::Accessible::GetChildCount()
- */
- size_t GetChildCount() const override;
-
- /**
- * @copydoc Dali::Accessibility::Accessible::GetChildAtIndex()
- */
- Dali::Accessibility::Accessible* GetChildAtIndex(size_t index) override;
-
- /**
- * @copydoc Dali::Accessibility::Accessible::GetIndexInParent()
- */
- size_t GetIndexInParent() override;
-
- /**
* @copydoc Dali::Accessibility::Accessible::GetRole()
*/
Dali::Accessibility::Role GetRole() const override;
Dali::Accessibility::Attributes GetAttributes() const override;
/**
- * @copydoc Dali::Accessibility::Component::GetExtents()
- */
- Dali::Rect<> GetExtents(Accessibility::CoordinateType type) const override;
-
- /**
- * @copydoc Dali::Accessibility::Component::GetLayer()
- */
- Dali::Accessibility::ComponentLayer GetLayer() const override;
-
- /**
- * @copydoc Dali::Accessibility::Component::GetMdiZOrder()
+ * @copydoc Dali::Accessibility::Accessible::IsHidden()
*/
- int16_t GetMdiZOrder() const override;
+ bool IsHidden() const override;
/**
* @copydoc Dali::Accessibility::Component::GrabFocus()
bool GrabFocus() override;
/**
- * @copydoc Dali::Accessibility::Component::GetAlpha()
- */
- double GetAlpha() const override;
-
- /**
* @copydoc Dali::Accessibility::Component::GrabHighlight()
*/
bool GrabHighlight() override;
std::vector<Dali::Accessibility::Relation> GetRelationSet() override;
/**
- * @copydoc Dali::Accessibility::Accessible::GetInternalActor()
- */
- Dali::Actor GetInternalActor() override;
-
- /**
* @copydoc Dali::Accessibility::Accessible::GetStates()
*/
virtual Dali::Accessibility::States CalculateStates();
* @see Dali::Accessibility::Role
*/
ACCESSIBILITY_ROLE,
+
/**
* @brief Mark of able to highlight object.
* @details Name "accessibilityHighlightable", type Property::BOOLEAN.
*/
ACCESSIBILITY_HIGHLIGHTABLE,
+
/**
* @brief Set of accessibility attributes describing object in accessibility hierarchy
* @details Name "accessibilityAttributes", type Property::MAP
* @note If a control's dispatchKeyEvents is set to false, then it's children will not emit a key event signal either.
*/
DISPATCH_KEY_EVENTS,
+
+ /**
+ * @brief Marks the object as invisible to AT-SPI clients.
+ * @details Name "accessibilityHidden", type Property::BOOLEAN.
+ * @note The representative Accessible object will not appear in the AT-SPI tree.
+ */
+ ACCESSIBILITY_HIDDEN,
};
} // namespace Property
${devel_api_src_dir}/transition-effects/cube-transition-fold-effect.cpp
${devel_api_src_dir}/transition-effects/cube-transition-wave-effect.cpp
${devel_api_src_dir}/utility/npatch-utilities.cpp
+ ${devel_api_src_dir}/utility/npatch-helper.cpp
${devel_api_src_dir}/visual-factory/transition-data.cpp
${devel_api_src_dir}/visual-factory/visual-factory.cpp
${devel_api_src_dir}/visual-factory/visual-base.cpp
SET( devel_api_utility_header_files
${devel_api_src_dir}/utility/npatch-utilities.h
+ ${devel_api_src_dir}/utility/npatch-helper.h
)
SET( SOURCES ${SOURCES}
--- /dev/null
+/*
+* Copyright (c) 2021 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.
+*
+*/
+
+// CLASS HEADER
+#include <dali-toolkit/devel-api/utility/npatch-helper.h>
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace NPatchHelper
+{
+namespace
+{
+/**
+ * @brief Creates the geometry formed from the vertices and indices
+ *
+ * @param[in] vertices The vertices to generate the geometry from
+ * @param[in] indices The indices to generate the geometry from
+ * @return The geometry formed from the vertices and indices
+ */
+Geometry GenerateGeometry(const Vector<Vector2>& vertices, const Vector<unsigned short>& indices)
+{
+ Property::Map vertexFormat;
+ vertexFormat["aPosition"] = Property::VECTOR2;
+ VertexBuffer vertexBuffer = VertexBuffer::New(vertexFormat);
+ if(vertices.Size() > 0)
+ {
+ vertexBuffer.SetData(&vertices[0], vertices.Size());
+ }
+
+ // Create the geometry object
+ Geometry geometry = Geometry::New();
+ geometry.AddVertexBuffer(vertexBuffer);
+ if(indices.Size() > 0)
+ {
+ geometry.SetIndexBuffer(&indices[0], indices.Size());
+ }
+
+ return geometry;
+}
+
+/**
+ * @brief Adds the indices to form a quad composed off two triangles where the indices are organised in a grid
+ *
+ * @param[out] indices The indices to add to
+ * @param[in] rowIdx The row index to start the quad
+ * @param[in] nextRowIdx The index to the next row
+ */
+void AddQuadIndices(Vector<unsigned short>& indices, unsigned int rowIdx, unsigned int nextRowIdx)
+{
+ indices.PushBack(rowIdx);
+ indices.PushBack(nextRowIdx + 1);
+ indices.PushBack(rowIdx + 1);
+
+ indices.PushBack(rowIdx);
+ indices.PushBack(nextRowIdx);
+ indices.PushBack(nextRowIdx + 1);
+}
+
+/**
+ * @brief Adds the vertices to create for npatch
+ * @param[out] vertices The vertices to add to
+ * @param[in] x The x value of vector
+ * @param[in] y The y value of vector
+ */
+void AddVertex(Vector<Vector2>& vertices, unsigned int x, unsigned int y)
+{
+ vertices.PushBack(Vector2(x, y));
+}
+
+} // unnamed namespace
+
+Geometry CreateGridGeometry(Uint16Pair gridSize)
+{
+ uint16_t gridWidth = gridSize.GetWidth();
+ uint16_t gridHeight = gridSize.GetHeight();
+
+ // Create vertices
+ Vector<Vector2> vertices;
+ vertices.Reserve((gridWidth + 1) * (gridHeight + 1));
+
+ for(int y = 0; y < gridHeight + 1; ++y)
+ {
+ for(int x = 0; x < gridWidth + 1; ++x)
+ {
+ AddVertex(vertices, x, y);
+ }
+ }
+
+ // Create indices
+ Vector<unsigned short> indices;
+ indices.Reserve(gridWidth * gridHeight * 6);
+
+ unsigned int rowIdx = 0;
+ unsigned int nextRowIdx = gridWidth + 1;
+ for(int y = 0; y < gridHeight; ++y, ++nextRowIdx, ++rowIdx)
+ {
+ for(int x = 0; x < gridWidth; ++x, ++nextRowIdx, ++rowIdx)
+ {
+ AddQuadIndices(indices, rowIdx, nextRowIdx);
+ }
+ }
+
+ return GenerateGeometry(vertices, indices);
+}
+
+Geometry CreateBorderGeometry(Uint16Pair gridSize)
+{
+ uint16_t gridWidth = gridSize.GetWidth();
+ uint16_t gridHeight = gridSize.GetHeight();
+
+ // Create vertices
+ Vector<Vector2> vertices;
+ vertices.Reserve((gridWidth + 1) * (gridHeight + 1));
+
+ //top
+ int y = 0;
+ for(; y < 2; ++y)
+ {
+ for(int x = 0; x < gridWidth + 1; ++x)
+ {
+ AddVertex(vertices, x, y);
+ }
+ }
+
+ for(; y < gridHeight - 1; ++y)
+ {
+ //left
+ AddVertex(vertices, 0, y);
+ AddVertex(vertices, 1, y);
+
+ //right
+ AddVertex(vertices, gridWidth - 1, y);
+ AddVertex(vertices, gridWidth, y);
+ }
+
+ //bottom
+ for(; y < gridHeight + 1; ++y)
+ {
+ for(int x = 0; x < gridWidth + 1; ++x)
+ {
+ AddVertex(vertices, x, y);
+ }
+ }
+
+ // Create indices
+ Vector<unsigned short> indices;
+ indices.Reserve(gridWidth * gridHeight * 6);
+
+ //top
+ unsigned int rowIdx = 0;
+ unsigned int nextRowIdx = gridWidth + 1;
+ for(int x = 0; x < gridWidth; ++x, ++nextRowIdx, ++rowIdx)
+ {
+ AddQuadIndices(indices, rowIdx, nextRowIdx);
+ }
+
+ if(gridHeight > 2)
+ {
+ rowIdx = gridWidth + 1;
+ nextRowIdx = (gridWidth + 1) * 2;
+
+ unsigned increment = gridWidth - 1;
+ if(gridHeight > 3)
+ {
+ increment = 2;
+ //second row left
+ AddQuadIndices(indices, rowIdx, nextRowIdx);
+
+ rowIdx = gridWidth * 2;
+ nextRowIdx = (gridWidth + 1) * 2 + 2;
+ //second row right
+ AddQuadIndices(indices, rowIdx, nextRowIdx);
+
+ //left and right
+ rowIdx = nextRowIdx - 2;
+ nextRowIdx = rowIdx + 4;
+ for(int y = 2; y < 2 * (gridHeight - 3); ++y, rowIdx += 2, nextRowIdx += 2)
+ {
+ AddQuadIndices(indices, rowIdx, nextRowIdx);
+ }
+ }
+
+ //second row left
+ AddQuadIndices(indices, rowIdx, nextRowIdx);
+
+ rowIdx += increment;
+ nextRowIdx += gridWidth - 1;
+ //second row right
+ AddQuadIndices(indices, rowIdx, nextRowIdx);
+ }
+
+ //bottom
+ rowIdx = nextRowIdx - gridWidth + 1;
+ nextRowIdx = rowIdx + gridWidth + 1;
+ for(int x = 0; x < gridWidth; ++x, ++nextRowIdx, ++rowIdx)
+ {
+ AddQuadIndices(indices, rowIdx, nextRowIdx);
+ }
+
+ return GenerateGeometry(vertices, indices);
+}
+
+void RegisterStretchProperties(Renderer& renderer, const char* uniformName, const NPatchUtility::StretchRanges& stretchPixels, uint16_t imageExtent)
+{
+ uint16_t prevEnd = 0;
+ uint16_t prevFix = 0;
+ uint16_t prevStretch = 0;
+ unsigned int i = 1;
+ for(NPatchUtility::StretchRanges::ConstIterator it = stretchPixels.Begin(); it != stretchPixels.End(); ++it, ++i)
+ {
+ uint16_t start = it->GetX();
+ uint16_t end = it->GetY();
+
+ uint16_t fix = prevFix + start - prevEnd;
+ uint16_t stretch = prevStretch + end - start;
+
+ std::stringstream uniform;
+ uniform << uniformName << "[" << i << "]";
+ renderer.RegisterProperty(uniform.str(), Vector2(fix, stretch));
+
+ prevEnd = end;
+ prevFix = fix;
+ prevStretch = stretch;
+ }
+
+ {
+ prevFix += imageExtent - prevEnd;
+ std::stringstream uniform;
+ uniform << uniformName << "[" << i << "]";
+ renderer.RegisterProperty(uniform.str(), Vector2(prevFix, prevStretch));
+ }
+}
+
+void ApplyTextureAndUniforms(Renderer& renderer, const Internal::NPatchData* data)
+{
+ TextureSet textureSet;
+ textureSet = data->GetTextures();
+
+ if(data->GetStretchPixelsX().Size() == 1 && data->GetStretchPixelsY().Size() == 1)
+ {
+ //special case for 9 patch
+ Uint16Pair stretchX = data->GetStretchPixelsX()[0];
+ Uint16Pair stretchY = data->GetStretchPixelsY()[0];
+
+ uint16_t stretchWidth = (stretchX.GetY() >= stretchX.GetX()) ? stretchX.GetY() - stretchX.GetX() : 0;
+ uint16_t stretchHeight = (stretchY.GetY() >= stretchY.GetX()) ? stretchY.GetY() - stretchY.GetX() : 0;
+
+ renderer.RegisterProperty("uFixed[0]", Vector2::ZERO);
+ renderer.RegisterProperty("uFixed[1]", Vector2(stretchX.GetX(), stretchY.GetX()));
+ renderer.RegisterProperty("uFixed[2]", Vector2(data->GetCroppedWidth() - stretchWidth, data->GetCroppedHeight() - stretchHeight));
+ renderer.RegisterProperty("uStretchTotal", Vector2(stretchWidth, stretchHeight));
+ }
+ else
+ {
+ renderer.RegisterProperty("uNinePatchFactorsX[0]", Vector2::ZERO);
+ renderer.RegisterProperty("uNinePatchFactorsY[0]", Vector2::ZERO);
+
+ RegisterStretchProperties(renderer, "uNinePatchFactorsX", data->GetStretchPixelsX(), data->GetCroppedWidth());
+ RegisterStretchProperties(renderer, "uNinePatchFactorsY", data->GetStretchPixelsY(), data->GetCroppedHeight());
+ }
+}
+
+} // namespace NPatchHelper
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_TOOLKIT_NPATCH_HELPER_H
+#define DALI_TOOLKIT_NPATCH_HELPER_H
+
+/*
+ * Copyright (c) 2021 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/uint-16-pair.h>
+#include <dali/public-api/rendering/geometry.h>
+#include <dali/devel-api/rendering/renderer-devel.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
+#include <dali-toolkit/internal/visuals/npatch-data.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace NPatchHelper
+{
+/**
+ * The list that includes stretch pixel ranges
+ */
+using StretchRanges = Dali::Vector<Uint16Pair>;
+
+/**
+ * @brief Creates a Npatch Geometry object
+ *
+ * @param[in] gridSize The gridSize for creating a geometry
+ * @return The Geometry for NPatch
+ */
+DALI_TOOLKIT_API Geometry CreateGridGeometry(Uint16Pair gridSize);
+
+/**
+ * @brief Creates a geometry with the border only for the grid size to be used by this visuals' shaders
+ * e.g. a 5x4 grid would create a geometry that would look like:
+ *
+ * ---------------------
+ * | /| /| /| /| /|
+ * |/ |/ |/ |/ |/ |
+ * ---------------------
+ * | /| | /|
+ * |/ | |/ |
+ * ----- -----
+ * | /| | /|
+ * |/ | |/ |
+ * ---------------------
+ * | /| /| /| /| /|
+ * |/ |/ |/ |/ |/ |
+ * ---------------------
+ *
+ * @param[in] gridSize The grid size of the solid geometry to create
+ * @return Returns the created geometry for the grid size
+ */
+DALI_TOOLKIT_API Geometry CreateBorderGeometry(Uint16Pair gridSize);
+
+
+/**
+ * @brief Registers a properties for Stretch Ranges
+ *
+ * @param[in,out] renderer The renderer for broken image
+ * @param[in] uniformName The name of the uniform
+ * @param[in] stretchPixels The stretchable pixels in the cropped image space
+ * @param[in] imageExtent The imageExtent
+ */
+void RegisterStretchProperties(Renderer& renderer, const char* uniformName, const NPatchUtility::StretchRanges& stretchPixels, uint16_t imageExtent);
+
+/**
+ * @brief Apply a texture and uniforms
+ *
+ * @param[in,out] renderer The renderer for broken image
+ * @param[in] data The pointer of npatch-data
+ */
+void ApplyTextureAndUniforms(Renderer& renderer, const Internal::NPatchData* data);
+
+} // namespace NPatchUtility
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_NPATCH_HELPER_H
const PropertyRegistration Control::Impl::PROPERTY_19(typeRegistration, "accessibilityRole", Toolkit::DevelControl::Property::ACCESSIBILITY_ROLE, Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty);
const PropertyRegistration Control::Impl::PROPERTY_20(typeRegistration, "accessibilityHighlightable", Toolkit::DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE, Property::BOOLEAN, &Control::Impl::SetProperty, &Control::Impl::GetProperty);
const PropertyRegistration Control::Impl::PROPERTY_21(typeRegistration, "accessibilityAttributes", Toolkit::DevelControl::Property::ACCESSIBILITY_ATTRIBUTES, Property::MAP, &Control::Impl::SetProperty, &Control::Impl::GetProperty);
-const PropertyRegistration Control::Impl::PROPERTY_22(typeRegistration, "dispatchKeyEvents", Toolkit::DevelControl::Property::DISPATCH_KEY_EVENTS, Property::BOOLEAN, &Control::Impl::SetProperty, &Control::Impl::GetProperty);
+const PropertyRegistration Control::Impl::PROPERTY_22(typeRegistration, "dispatchKeyEvents", Toolkit::DevelControl::Property::DISPATCH_KEY_EVENTS, Property::BOOLEAN, &Control::Impl::SetProperty, &Control::Impl::GetProperty);
+const PropertyRegistration Control::Impl::PROPERTY_23(typeRegistration, "accessibilityHidden", Toolkit::DevelControl::Property::ACCESSIBILITY_HIDDEN, Property::BOOLEAN, &Control::Impl::SetProperty, &Control::Impl::GetProperty);
// clang-format on
}
break;
}
+
+ case Toolkit::DevelControl::Property::ACCESSIBILITY_HIDDEN:
+ {
+ bool hidden;
+ if(value.Get(hidden))
+ {
+ controlImpl.mImpl->mAccessibilityHidden = hidden;
+ }
+ break;
+ }
}
}
}
value = controlImpl.mImpl->mAccessibilityAttributes;
break;
}
+
case Toolkit::DevelControl::Property::DISPATCH_KEY_EVENTS:
{
value = controlImpl.mImpl->mDispatchKeyEvents;
break;
}
+
+ case Toolkit::DevelControl::Property::ACCESSIBILITY_HIDDEN:
+ {
+ value = controlImpl.mImpl->mAccessibilityHidden;
+ break;
+ }
}
}
bool mAccessibilityHighlightable = false;
bool mAccessibilityHighlightableSet = false;
+ bool mAccessibilityHidden = false;
+
Dali::Accessibility::Role mAccessibilityRole = Dali::Accessibility::Role::UNKNOWN;
std::map<Dali::Accessibility::RelationType, std::set<Accessibility::Accessible*>> mAccessibilityRelations;
static const PropertyRegistration PROPERTY_20;
static const PropertyRegistration PROPERTY_21;
static const PropertyRegistration PROPERTY_22;
+ static const PropertyRegistration PROPERTY_23;
private:
// Accessibility - notification for highlighted object to check if it is showing.
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
map = value.GetMap();
if(map)
{
- Property::Value* shaderValue = map->Find(Toolkit::Visual::Property::SHADER, CUSTOM_SHADER);
- // set image only if property map contains image information other than custom shader
- if(map->Count() > 1u || !shaderValue)
+ // the property map is emtpy map. Unregister visual.
+ if(DALI_UNLIKELY(map->Count() == 0u))
{
- impl.SetImage(*map);
+ // Clear cached properties
+ impl.mPropertyMap.Clear();
+ impl.mUrl.clear();
+
+ // Unregister the exsiting visual
+ DevelControl::UnregisterVisual(impl, Toolkit::ImageView::Property::IMAGE);
+
+ // Trigger a size negotiation request that may be needed when unregistering a visual.
+ impl.RelayoutRequest();
}
- // the property map contains only the custom shader
- else if((map->Count() == 1u) && (shaderValue))
+ else
{
- Property::Map* shaderMap = shaderValue->GetMap();
- if(shaderMap)
+ Property::Value* shaderValue = map->Find(Toolkit::Visual::Property::SHADER, CUSTOM_SHADER);
+ // set image only if property map contains image information other than custom shader
+ if(map->Count() > 1u || !shaderValue)
{
- impl.mShaderMap = *shaderMap;
-
- if(!impl.mUrl.empty())
- {
- impl.SetImage(impl.mUrl, impl.mImageSize);
- }
- else if(!impl.mPropertyMap.Empty())
+ impl.SetImage(*map);
+ }
+ // the property map contains only the custom shader
+ else if((map->Count() == 1u) && (shaderValue))
+ {
+ Property::Map* shaderMap = shaderValue->GetMap();
+ if(shaderMap)
{
- impl.SetImage(impl.mPropertyMap);
+ impl.mShaderMap = *shaderMap;
+
+ if(!impl.mUrl.empty())
+ {
+ impl.SetImage(impl.mUrl, impl.mImageSize);
+ }
+ else if(!impl.mPropertyMap.Empty())
+ {
+ impl.SetImage(impl.mPropertyMap);
+ }
}
}
}
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
if(lastGlyphIndexOfLine == index)
{
- penY += -line->descender;
+ penY += -line->descender + line->lineSpacing;
// Get the next line.
++lineIndex;
lastGlyphIndexOfLine = (line->isSplitToTwoHalves ? line->glyphRunSecondHalf.glyphIndex + line->glyphRunSecondHalf.numberOfGlyphs : line->glyphRun.glyphIndex + line->glyphRun.numberOfGlyphs) - 1u;
- penY += line->ascender + line->lineSpacing;
+ penY += line->ascender;
}
}
}
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
map.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
bool sync = IsSynchronousLoadingRequired();
- map.Insert(SYNCHRONOUS_LOADING, sync);
+ map.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, sync);
if(mImageUrl.IsValid())
{
map.Insert(Toolkit::ImageVisual::Property::URL, mImageUrl.GetUrl());
#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
#include <dali-toolkit/internal/visuals/image-visual-shader-factory.h>
#include <dali-toolkit/internal/visuals/npatch-loader.h>
+#include <dali-toolkit/devel-api/utility/npatch-helper.h>
#include <dali-toolkit/internal/visuals/rendering-addon.h>
#include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
#include <dali-toolkit/internal/visuals/visual-base-impl.h>
{
namespace Internal
{
-namespace
-{
-/**
- * @brief Creates the geometry formed from the vertices and indices
- *
- * @param[in] vertices The vertices to generate the geometry from
- * @param[in] indices The indices to generate the geometry from
- * @return The geometry formed from the vertices and indices
- */
-Geometry GenerateGeometry(const Vector<Vector2>& vertices, const Vector<unsigned short>& indices)
-{
- Property::Map vertexFormat;
- vertexFormat["aPosition"] = Property::VECTOR2;
- VertexBuffer vertexBuffer = VertexBuffer::New(vertexFormat);
- if(vertices.Size() > 0)
- {
- vertexBuffer.SetData(&vertices[0], vertices.Size());
- }
-
- // Create the geometry object
- Geometry geometry = Geometry::New();
- geometry.AddVertexBuffer(vertexBuffer);
- if(indices.Size() > 0)
- {
- geometry.SetIndexBuffer(&indices[0], indices.Size());
- }
-
- return geometry;
-}
-
-/**
- * @brief Adds the indices to form a quad composed off two triangles where the indices are organised in a grid
- *
- * @param[out] indices The indices to add to
- * @param[in] rowIdx The row index to start the quad
- * @param[in] nextRowIdx The index to the next row
- */
-void AddQuadIndices(Vector<unsigned short>& indices, unsigned int rowIdx, unsigned int nextRowIdx)
-{
- indices.PushBack(rowIdx);
- indices.PushBack(nextRowIdx + 1);
- indices.PushBack(rowIdx + 1);
-
- indices.PushBack(rowIdx);
- indices.PushBack(nextRowIdx);
- indices.PushBack(nextRowIdx + 1);
-}
-
-void AddVertex(Vector<Vector2>& vertices, unsigned int x, unsigned int y)
-{
- vertices.PushBack(Vector2(x, y));
-}
-
-void RegisterStretchProperties(Renderer& renderer, const char* uniformName, const NPatchUtility::StretchRanges& stretchPixels, uint16_t imageExtent)
-{
- uint16_t prevEnd = 0;
- uint16_t prevFix = 0;
- uint16_t prevStretch = 0;
- unsigned int i = 1;
- for(NPatchUtility::StretchRanges::ConstIterator it = stretchPixels.Begin(); it != stretchPixels.End(); ++it, ++i)
- {
- uint16_t start = it->GetX();
- uint16_t end = it->GetY();
-
- uint16_t fix = prevFix + start - prevEnd;
- uint16_t stretch = prevStretch + end - start;
-
- std::stringstream uniform;
- uniform << uniformName << "[" << i << "]";
- renderer.RegisterProperty(uniform.str(), Vector2(fix, stretch));
-
- prevEnd = end;
- prevFix = fix;
- prevStretch = stretch;
- }
-
- {
- prevFix += imageExtent - prevEnd;
- std::stringstream uniform;
- uniform << uniformName << "[" << i << "]";
- renderer.RegisterProperty(uniform.str(), Vector2(prevFix, prevStretch));
- }
-}
-
-} //unnamed namespace
/////////////////NPatchVisual////////////////
Uint16Pair gridSize(2 * data->GetStretchPixelsX().Size() + 1, 2 * data->GetStretchPixelsY().Size() + 1);
if(!data->GetRenderingMap())
{
- geometry = !mBorderOnly ? CreateGridGeometry(gridSize) : CreateBorderGeometry(gridSize);
+ geometry = !mBorderOnly ? NPatchHelper::CreateGridGeometry(gridSize) : NPatchHelper::CreateBorderGeometry(gridSize);
}
else
{
uint32_t elementCount[2];
- geometry = !mBorderOnly ? RenderingAddOn::Get().CreateGeometryGrid(data->GetRenderingMap(), gridSize, elementCount) : CreateBorderGeometry(gridSize);
+ geometry = !mBorderOnly ? RenderingAddOn::Get().CreateGeometryGrid(data->GetRenderingMap(), gridSize, elementCount) : NPatchHelper::CreateBorderGeometry(gridSize);
if(mImpl->mRenderer)
{
RenderingAddOn::Get().SubmitRenderTask(mImpl->mRenderer, data->GetRenderingMap());
if(mLoader.GetNPatchData(mId, data) && data->GetLoadingState() == NPatchData::LoadingState::LOAD_COMPLETE)
{
textureSet = data->GetTextures();
-
- if(data->GetStretchPixelsX().Size() == 1 && data->GetStretchPixelsY().Size() == 1)
- {
- //special case for 9 patch
- Uint16Pair stretchX = data->GetStretchPixelsX()[0];
- Uint16Pair stretchY = data->GetStretchPixelsY()[0];
-
- uint16_t stretchWidth = (stretchX.GetY() >= stretchX.GetX()) ? stretchX.GetY() - stretchX.GetX() : 0;
- uint16_t stretchHeight = (stretchY.GetY() >= stretchY.GetX()) ? stretchY.GetY() - stretchY.GetX() : 0;
-
- mImpl->mRenderer.RegisterProperty("uFixed[0]", Vector2::ZERO);
- mImpl->mRenderer.RegisterProperty("uFixed[1]", Vector2(stretchX.GetX(), stretchY.GetX()));
- mImpl->mRenderer.RegisterProperty("uFixed[2]", Vector2(data->GetCroppedWidth() - stretchWidth, data->GetCroppedHeight() - stretchHeight));
- mImpl->mRenderer.RegisterProperty("uStretchTotal", Vector2(stretchWidth, stretchHeight));
- }
- else
- {
- mImpl->mRenderer.RegisterProperty("uNinePatchFactorsX[0]", Vector2::ZERO);
- mImpl->mRenderer.RegisterProperty("uNinePatchFactorsY[0]", Vector2::ZERO);
-
- RegisterStretchProperties(mImpl->mRenderer, "uNinePatchFactorsX", data->GetStretchPixelsX(), data->GetCroppedWidth());
- RegisterStretchProperties(mImpl->mRenderer, "uNinePatchFactorsY", data->GetStretchPixelsY(), data->GetCroppedHeight());
- }
+ NPatchHelper::ApplyTextureAndUniforms(mImpl->mRenderer, data);
}
else
{
{
if(DALI_LIKELY(VisualFactoryCache::NINE_PATCH_GEOMETRY == subType))
{
- geometry = CreateGridGeometry(Uint16Pair(3, 3));
+ geometry = NPatchHelper::CreateGridGeometry(Uint16Pair(3, 3));
}
else if(VisualFactoryCache::NINE_PATCH_BORDER_GEOMETRY == subType)
{
- geometry = CreateBorderGeometry(Uint16Pair(3, 3));
+ geometry = NPatchHelper::CreateBorderGeometry(Uint16Pair(3, 3));
}
mFactoryCache.SaveGeometry(subType, geometry);
}
return geometry;
}
-Geometry NPatchVisual::CreateGridGeometry(Uint16Pair gridSize)
-{
- uint16_t gridWidth = gridSize.GetWidth();
- uint16_t gridHeight = gridSize.GetHeight();
-
- // Create vertices
- Vector<Vector2> vertices;
- vertices.Reserve((gridWidth + 1) * (gridHeight + 1));
-
- for(int y = 0; y < gridHeight + 1; ++y)
- {
- for(int x = 0; x < gridWidth + 1; ++x)
- {
- AddVertex(vertices, x, y);
- }
- }
-
- // Create indices
- Vector<unsigned short> indices;
- indices.Reserve(gridWidth * gridHeight * 6);
-
- unsigned int rowIdx = 0;
- unsigned int nextRowIdx = gridWidth + 1;
- for(int y = 0; y < gridHeight; ++y, ++nextRowIdx, ++rowIdx)
- {
- for(int x = 0; x < gridWidth; ++x, ++nextRowIdx, ++rowIdx)
- {
- AddQuadIndices(indices, rowIdx, nextRowIdx);
- }
- }
-
- return GenerateGeometry(vertices, indices);
-}
-
-Geometry NPatchVisual::CreateBorderGeometry(Uint16Pair gridSize)
-{
- uint16_t gridWidth = gridSize.GetWidth();
- uint16_t gridHeight = gridSize.GetHeight();
-
- // Create vertices
- Vector<Vector2> vertices;
- vertices.Reserve((gridWidth + 1) * (gridHeight + 1));
-
- //top
- int y = 0;
- for(; y < 2; ++y)
- {
- for(int x = 0; x < gridWidth + 1; ++x)
- {
- AddVertex(vertices, x, y);
- }
- }
-
- for(; y < gridHeight - 1; ++y)
- {
- //left
- AddVertex(vertices, 0, y);
- AddVertex(vertices, 1, y);
-
- //right
- AddVertex(vertices, gridWidth - 1, y);
- AddVertex(vertices, gridWidth, y);
- }
-
- //bottom
- for(; y < gridHeight + 1; ++y)
- {
- for(int x = 0; x < gridWidth + 1; ++x)
- {
- AddVertex(vertices, x, y);
- }
- }
-
- // Create indices
- Vector<unsigned short> indices;
- indices.Reserve(gridWidth * gridHeight * 6);
-
- //top
- unsigned int rowIdx = 0;
- unsigned int nextRowIdx = gridWidth + 1;
- for(int x = 0; x < gridWidth; ++x, ++nextRowIdx, ++rowIdx)
- {
- AddQuadIndices(indices, rowIdx, nextRowIdx);
- }
-
- if(gridHeight > 2)
- {
- rowIdx = gridWidth + 1;
- nextRowIdx = (gridWidth + 1) * 2;
-
- unsigned increment = gridWidth - 1;
- if(gridHeight > 3)
- {
- increment = 2;
- //second row left
- AddQuadIndices(indices, rowIdx, nextRowIdx);
-
- rowIdx = gridWidth * 2;
- nextRowIdx = (gridWidth + 1) * 2 + 2;
- //second row right
- AddQuadIndices(indices, rowIdx, nextRowIdx);
-
- //left and right
- rowIdx = nextRowIdx - 2;
- nextRowIdx = rowIdx + 4;
- for(int y = 2; y < 2 * (gridHeight - 3); ++y, rowIdx += 2, nextRowIdx += 2)
- {
- AddQuadIndices(indices, rowIdx, nextRowIdx);
- }
- }
-
- //second row left
- AddQuadIndices(indices, rowIdx, nextRowIdx);
-
- rowIdx += increment;
- nextRowIdx += gridWidth - 1;
- //second row right
- AddQuadIndices(indices, rowIdx, nextRowIdx);
- }
-
- //bottom
- rowIdx = nextRowIdx - gridWidth + 1;
- nextRowIdx = rowIdx + gridWidth + 1;
- for(int x = 0; x < gridWidth; ++x, ++nextRowIdx, ++rowIdx)
- {
- AddQuadIndices(indices, rowIdx, nextRowIdx);
- }
-
- return GenerateGeometry(vertices, indices);
-}
-
void NPatchVisual::SetResource()
{
const NPatchData* data;
#include <dali-toolkit/internal/visuals/image-atlas-manager.h>
#include <dali-toolkit/internal/visuals/svg/svg-visual.h>
#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
+#include <dali-toolkit/devel-api/utility/npatch-helper.h>
#include <dali/integration-api/debug.h>
namespace Dali
{
namespace Internal
{
-namespace
-{
-
-/**
- * @brief Creates the geometry formed from the vertices and indices
- *
- * @param[in] vertices The vertices to generate the geometry from
- * @param[in] indices The indices to generate the geometry from
- * @return The geometry formed from the vertices and indices
- */
-Geometry GenerateGeometry(const Vector<Vector2>& vertices, const Vector<unsigned short>& indices)
-{
- Property::Map vertexFormat;
- vertexFormat["aPosition"] = Property::VECTOR2;
- VertexBuffer vertexBuffer = VertexBuffer::New(vertexFormat);
- if(vertices.Size() > 0)
- {
- vertexBuffer.SetData(&vertices[0], vertices.Size());
- }
-
- // Create the geometry object
- Geometry geometry = Geometry::New();
- geometry.AddVertexBuffer(vertexBuffer);
- if(indices.Size() > 0)
- {
- geometry.SetIndexBuffer(&indices[0], indices.Size());
- }
-
- return geometry;
-}
-
-/**
- * @brief Adds the indices to form a quad composed off two triangles where the indices are organised in a grid
- *
- * @param[out] indices The indices to add to
- * @param[in] rowIdx The row index to start the quad
- * @param[in] nextRowIdx The index to the next row
- */
-void AddQuadIndices(Vector<unsigned short>& indices, unsigned int rowIdx, unsigned int nextRowIdx)
-{
- indices.PushBack(rowIdx);
- indices.PushBack(nextRowIdx + 1);
- indices.PushBack(rowIdx + 1);
-
- indices.PushBack(rowIdx);
- indices.PushBack(nextRowIdx);
- indices.PushBack(nextRowIdx + 1);
-}
-
-/**
- * @brief Adds the vertices to create for npatch
- * @param[out] vertices The vertices to add to
- * @param[in] x The x value of vector
- * @param[in] y The y value of vector
- */
-void AddVertex(Vector<Vector2>& vertices, unsigned int x, unsigned int y)
-{
- vertices.PushBack(Vector2(x, y));
-}
-
-} //unnamed namespace
VisualFactoryCache::VisualFactoryCache(bool preMultiplyOnLoad)
: mSvgRasterizeThread(NULL),
mVectorAnimationManager(),
mPreMultiplyOnLoad(preMultiplyOnLoad),
- mBrokenImageInfoContainer()
+ mBrokenImageInfoContainer(),
+ mDefaultBrokenImageUrl(""),
+ mUseDefaultBrokenImageOnly(true)
{
}
if(!mAtlasManager)
{
mAtlasManager = new ImageAtlasManager();
- if(!mBrokenImageInfoContainer.empty())
- {
- mAtlasManager->SetBrokenImage(mBrokenImageInfoContainer[0].url);
- }
+ mAtlasManager->SetBrokenImage(mDefaultBrokenImageUrl);
}
return mAtlasManager;
return mPreMultiplyOnLoad;
}
-void VisualFactoryCache::SetBrokenImageUrl(const std::vector<std::string>& brokenImageUrlList)
+void VisualFactoryCache::SetBrokenImageUrl(std::string& defaultBrokenUrl, const std::vector<std::string>& brokenImageUrlList)
{
+ mUseDefaultBrokenImageOnly = false;
mBrokenImageInfoContainer.clear();
mBrokenImageInfoContainer.assign(brokenImageUrlList.size(), BrokenImageInfo());
for(unsigned int i = 0; i < brokenImageUrlList.size(); i++)
{
mBrokenImageInfoContainer[i].url = brokenImageUrlList[i];
}
+
+ mDefaultBrokenImageUrl = defaultBrokenUrl;
}
VisualUrl::Type VisualFactoryCache::GetBrokenImageVisualType(int index)
return mBrokenImageInfoContainer[index].visualType;
}
-Geometry VisualFactoryCache::CreateNPatchGeometry(Uint16Pair gridSize)
-{
- uint16_t gridWidth = gridSize.GetWidth();
- uint16_t gridHeight = gridSize.GetHeight();
-
- // Create vertices
- Vector<Vector2> vertices;
- vertices.Reserve((gridWidth + 1) * (gridHeight + 1));
-
- for(int y = 0; y < gridHeight + 1; ++y)
- {
- for(int x = 0; x < gridWidth + 1; ++x)
- {
- AddVertex(vertices, x, y);
- }
- }
-
- // Create indices
- Vector<unsigned short> indices;
- indices.Reserve(gridWidth * gridHeight * 6);
-
- unsigned int rowIdx = 0;
- unsigned int nextRowIdx = gridWidth + 1;
- for(int y = 0; y < gridHeight; ++y, ++nextRowIdx, ++rowIdx)
- {
- for(int x = 0; x < gridWidth; ++x, ++nextRowIdx, ++rowIdx)
- {
- AddQuadIndices(indices, rowIdx, nextRowIdx);
- }
- }
-
- return GenerateGeometry(vertices, indices);
-}
-
Geometry VisualFactoryCache::GetNPatchGeometry(int index)
{
Geometry geometry;
geometry = GetGeometry(VisualFactoryCache::NINE_PATCH_GEOMETRY);
if(!geometry)
{
- geometry = CreateNPatchGeometry(Uint16Pair(3,3));
+ geometry = NPatchHelper::CreateGridGeometry(Uint16Pair(3,3));
SaveGeometry(VisualFactoryCache::NINE_PATCH_GEOMETRY, geometry);
}
}
else if(data->GetStretchPixelsX().Size() > 0 || data->GetStretchPixelsY().Size() > 0)
{
Uint16Pair gridSize(2 * data->GetStretchPixelsX().Size() + 1, 2 * data->GetStretchPixelsY().Size() + 1);
- geometry = CreateNPatchGeometry(gridSize);
+ geometry = NPatchHelper::CreateGridGeometry(gridSize);
}
}
else
geometry = GetGeometry(VisualFactoryCache::NINE_PATCH_GEOMETRY);
if(!geometry)
{
- geometry = CreateNPatchGeometry(Uint16Pair(3,3));
+ geometry = NPatchHelper::CreateGridGeometry(Uint16Pair(3,3));
SaveGeometry(VisualFactoryCache::NINE_PATCH_GEOMETRY, geometry);
}
}
yStretchCount = data->GetStretchPixelsY().Count();
}
- if(DALI_LIKELY((xStretchCount == 0 && yStretchCount == 0)))
+ if(DALI_LIKELY((xStretchCount == 0 && yStretchCount == 0) || (xStretchCount == 1 && yStretchCount == 1)))
{
shader = GetShader(VisualFactoryCache::NINE_PATCH_SHADER);
if(DALI_UNLIKELY(!shader))
return shader;
}
-void VisualFactoryCache::RegisterStretchProperties(Renderer& renderer, const char* uniformName, const NPatchUtility::StretchRanges& stretchPixels, uint16_t imageExtent)
-{
- uint16_t prevEnd = 0;
- uint16_t prevFix = 0;
- uint16_t prevStretch = 0;
- unsigned int i = 1;
- for(NPatchUtility::StretchRanges::ConstIterator it = stretchPixels.Begin(); it != stretchPixels.End(); ++it, ++i)
- {
- uint16_t start = it->GetX();
- uint16_t end = it->GetY();
-
- uint16_t fix = prevFix + start - prevEnd;
- uint16_t stretch = prevStretch + end - start;
-
- std::stringstream uniform;
- uniform << uniformName << "[" << i << "]";
- renderer.RegisterProperty(uniform.str(), Vector2(fix, stretch));
-
- prevEnd = end;
- prevFix = fix;
- prevStretch = stretch;
- }
-
- {
- prevFix += imageExtent - prevEnd;
- std::stringstream uniform;
- uniform << uniformName << "[" << i << "]";
- renderer.RegisterProperty(uniform.str(), Vector2(prevFix, prevStretch));
- }
-}
-
void VisualFactoryCache::ApplyTextureAndUniforms(Renderer& renderer, int index)
{
const NPatchData* data;
if(mNPatchLoader.GetNPatchData(mBrokenImageInfoContainer[index].npatchId, data) && data->GetLoadingState() == NPatchData::LoadingState::LOAD_COMPLETE)
{
textureSet = data->GetTextures();
- mBrokenImageInfoContainer[index].texture = data->GetTextures().GetTexture(0);
-
- if(data->GetStretchPixelsX().Size() == 1 && data->GetStretchPixelsY().Size() == 1)
- {
- //special case for 9 patch
- Uint16Pair stretchX = data->GetStretchPixelsX()[0];
- Uint16Pair stretchY = data->GetStretchPixelsY()[0];
-
- uint16_t stretchWidth = (stretchX.GetY() >= stretchX.GetX()) ? stretchX.GetY() - stretchX.GetX() : 0;
- uint16_t stretchHeight = (stretchY.GetY() >= stretchY.GetX()) ? stretchY.GetY() - stretchY.GetX() : 0;
-
- renderer.RegisterProperty("uFixed[0]", Vector2::ZERO);
- renderer.RegisterProperty("uFixed[1]", Vector2(stretchX.GetX(), stretchY.GetX()));
- renderer.RegisterProperty("uFixed[2]", Vector2(data->GetCroppedWidth() - stretchWidth, data->GetCroppedHeight() - stretchHeight));
- renderer.RegisterProperty("uStretchTotal", Vector2(stretchWidth, stretchHeight));
- }
- else
- {
- renderer.RegisterProperty("uNinePatchFactorsX[0]", Vector2::ZERO);
- renderer.RegisterProperty("uNinePatchFactorsY[0]", Vector2::ZERO);
-
- RegisterStretchProperties(renderer, "uNinePatchFactorsX", data->GetStretchPixelsX(), data->GetCroppedWidth());
- RegisterStretchProperties(renderer, "uNinePatchFactorsY", data->GetStretchPixelsY(), data->GetCroppedHeight());
- }
+ mBrokenImageInfoContainer[index].texture = textureSet.GetTexture(0);
+ NPatchHelper::ApplyTextureAndUniforms(renderer, data);
renderer.SetTextures(textureSet);
}
}
void VisualFactoryCache::UpdateBrokenImageRenderer(Renderer& renderer, const Vector2& size)
{
+
+ bool useDefaultBrokenImage = false;
+ if(mBrokenImageInfoContainer.size() == 0)
+ {
+ useDefaultBrokenImage = true;
+ }
+
// Load Information for broken image
- for(uint32_t index = 0; index < mBrokenImageInfoContainer.size(); index++)
+ for(uint32_t index = 0; (index < mBrokenImageInfoContainer.size()) && !useDefaultBrokenImage; index++)
{
if(mBrokenImageInfoContainer[index].width == 0 && mBrokenImageInfoContainer[index].height == 0)
{
}
else
{
- DALI_LOG_ERROR("Can't update renderer for broken image. maybe image loading is failed [path:%s] \n",mBrokenImageInfoContainer[index].url.c_str());
+ DALI_LOG_ERROR("Can't update renderer for broken image. maybe image loading is failed [index:%d] [path:%s] \n",index, mBrokenImageInfoContainer[index].url.c_str());
+ useDefaultBrokenImage = true;
}
}
else
{
- GetBrokenVisualImage(index);
+ if(!GetBrokenVisualImage(index))
+ {
+ DALI_LOG_ERROR("Can't update renderer for broken image. maybe image loading is failed [index:%d] [path:%s] \n",index, mBrokenImageInfoContainer[index].url.c_str());
+ useDefaultBrokenImage = true;
+ }
}
}
}
}
+ if(!mUseDefaultBrokenImageOnly && useDefaultBrokenImage)
+ {
+ // Clear broken info
+ mBrokenImageInfoContainer.clear();
+
+ // assign for broken image
+ const int defaultBrokenIndex = 0;
+ mBrokenImageInfoContainer.assign(1, BrokenImageInfo());
+ mBrokenImageInfoContainer[defaultBrokenIndex].url = mDefaultBrokenImageUrl;
+ VisualUrl visualUrl(mBrokenImageInfoContainer[defaultBrokenIndex].url);
+ mBrokenImageInfoContainer[defaultBrokenIndex].visualType = visualUrl.GetType();
+ mUseDefaultBrokenImageOnly = true;
+ }
+
// Set Texutre to renderer
int brokenIndex = GetProperBrokenImageIndex(size);
if(GetBrokenImageVisualType(brokenIndex) == VisualUrl::N_PATCH)
{
// Sets the default broken type
int32_t returnIndex = 0;
- if((size.width == 0 || size.height == 0))
+ if((size.width == 0 || size.height == 0) || mUseDefaultBrokenImageOnly )
{
// To do : Need to add observer about size
return returnIndex;
* @brief Set an image to be used when a visual has failed to correctly render
* @param[in] brokenImageUrlList The broken image url list
*/
- void SetBrokenImageUrl(const std::vector<std::string>& brokenImageUrlList);
+ void SetBrokenImageUrl(std::string& defaultBrokenUrl, const std::vector<std::string>& brokenImageUrlList);
/**
* @brief Update the broken image Renderer object
void ApplyTextureAndUniforms(Renderer& renderer, int index);
/**
- * @brief Creates a Npatch Geometry object
- *
- * @param[in] gridSize The gridSize for creating a geometry
- * @return The Geometry for NPatch
- */
- Geometry CreateNPatchGeometry(Uint16Pair gridSize);
-
- /**
* @brief Gets a geometry for npatch image
*
* @param[in] index the index of broken image
Shader GetNPatchShader(int index);
/**
- * @brief Registers a properties for Stretch Ranges
- *
- * @param[in,out] renderer The renderer for broken image
- * @param[in] uniformName The name of the uniform
- * @param[in] stretchPixels The stretchable pixels in the cropped image space
- * @param[in] imageExtent The imageExtent
- */
- void RegisterStretchProperties(Renderer& renderer, const char* uniformName, const NPatchUtility::StretchRanges& stretchPixels, uint16_t imageExtent);
-
- /**
* @brief Returns a broken image type
* @param[in] index BrokenImage index
* @return The broken image type.
std::unique_ptr<VectorAnimationManager> mVectorAnimationManager;
bool mPreMultiplyOnLoad;
std::vector<BrokenImageInfo> mBrokenImageInfoContainer;
+ std::string mDefaultBrokenImageUrl;
+ bool mUseDefaultBrokenImageOnly;
};
} // namespace Internal
if(styleManager)
{
customBrokenImageUrlList = Toolkit::DevelStyleManager::GetBrokenImageUrlList(styleManager);
- if(customBrokenImageUrlList.size() == 0)
- {
- Property::Map config = Toolkit::DevelStyleManager::GetConfigurations(styleManager);
- config["brokenImageUrl"].Get(brokenImageUrl);
- customBrokenImageUrlList.push_back(brokenImageUrl);
- }
- mFactoryCache->SetBrokenImageUrl(customBrokenImageUrlList);
- }
- else
- {
- // Set default image
- customBrokenImageUrlList.push_back(brokenImageUrl);
- mFactoryCache->SetBrokenImageUrl(customBrokenImageUrlList);
+ Property::Map config = Toolkit::DevelStyleManager::GetConfigurations(styleManager);
+ config["brokenImageUrl"].Get(brokenImageUrl);
}
+
+ // Add default image
+ mFactoryCache->SetBrokenImageUrl(brokenImageUrl, customBrokenImageUrlList);
}
Internal::VisualFactoryCache& VisualFactory::GetFactoryCache()
}
case Actor::Property::VISIBLE:
{
- if(Dali::Accessibility::IsUp())
+ if(Dali::Accessibility::IsUp() && !Self().GetProperty<bool>(Toolkit::DevelControl::Property::ACCESSIBILITY_HIDDEN))
{
Dali::Accessibility::Accessible::Get(Self())->EmitVisible(Self().GetProperty(Actor::Property::VISIBLE).Get<bool>());
}