/*
- * Copyright (c) 2020 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.
{
namespace DevelStyleManager
{
-const Property::Map GetConfigurations(StyleManager styleManager)
+const Property::Map& GetConfigurations(StyleManager styleManager)
{
return GetImpl(styleManager).GetConfigurations();
}
#define DALI_TOOLKIT_STYLE_MANAGER_DEVEL_H
/*
- * Copyright (c) 2020 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.
* @param[in] styleManager The instance of StyleManager
* @return A property map to the currently defined configurations
**/
-DALI_TOOLKIT_API const Property::Map GetConfigurations(StyleManager styleManager);
+DALI_TOOLKIT_API const Property::Map& GetConfigurations(StyleManager styleManager);
/**
* @brief Sets an image to be used when a visual has failed to correctly render
/*
- * 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.
Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
if(styleManager)
{
- Property::Map config = Toolkit::DevelStyleManager::GetConfigurations(styleManager);
- mAlwaysShowIndicator = config["alwaysShowFocus"].Get<bool>() ? ALWAYS_SHOW : NONE;
+ const Property::Map& config = Toolkit::DevelStyleManager::GetConfigurations(styleManager);
+ const auto alwaysShowFocusValue = config.Find("alwaysShowFocus", Property::Type::BOOLEAN);
+
+ mAlwaysShowIndicator = (alwaysShowFocusValue && alwaysShowFocusValue->Get<bool>()) ? ALWAYS_SHOW : NONE;
mIsFocusIndicatorShown = (mAlwaysShowIndicator == ALWAYS_SHOW) ? SHOW : HIDE;
mClearFocusOnTouch = (mIsFocusIndicatorShown == SHOW) ? false : true;
}
nextFocusableActor = mPreFocusChangeSignal.Emit(currentFocusActor, Actor(), direction);
mIsWaitingKeyboardFocusChangeCommit = false;
}
- else if (mEnableDefaultAlgorithm)
+ else if(mEnableDefaultAlgorithm)
{
Actor rootActor = mFocusFinderRootActor.GetHandle();
if(!rootActor)
{
- if (currentFocusActor)
+ if(currentFocusActor)
{
// Find the window of the focused actor.
Integration::SceneHolder window = Integration::SceneHolder::Get(currentFocusActor);
- if (window)
+ if(window)
{
rootActor = window.GetRootLayer();
}
void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
{
- const std::string& keyName = event.GetKeyName();
+ const std::string& keyName = event.GetKeyName();
const std::string& deviceName = event.GetDeviceName();
if(mIsFocusIndicatorShown == UNKNOWN)
bool KeyboardFocusManager::OnCustomWheelEvent(const WheelEvent& event)
{
- bool consumed = false;
- Actor actor = GetCurrentFocusActor();
+ bool consumed = false;
+ Actor actor = GetCurrentFocusActor();
if(actor)
{
// Notify the actor about the wheel event
/*
- * 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.
}
}
-const Property::Map StyleManager::GetConfigurations()
+const Property::Map& StyleManager::GetConfigurations()
{
DALI_LOG_STREAM(gLogFilter, Debug::Concise, "GetConfigurations()\n On entry, mThemeBuilder: " << (bool(mThemeBuilder) ? "Created" : "Empty") << " mThemeFile: " << mThemeFile);
- Property::Map result;
- if(mThemeBuilder)
- {
- result = mThemeBuilder.GetConfigurations();
- }
- else
+ if(!mThemeBuilder)
{
DALI_LOG_STREAM(gLogFilter, Debug::Concise, "GetConfigurations() Loading default theme");
- bool themeLoaded = false;
-
mThemeBuilder = CreateBuilder(mThemeBuilderConstants);
// Load default theme because this is first try to load stylesheet.
- themeLoaded = LoadJSON(mThemeBuilder, mDefaultThemeFilePath);
- mThemeFile = mDefaultThemeFilePath;
-
- if(themeLoaded)
- {
- result = mThemeBuilder.GetConfigurations();
- }
+#if defined(DEBUG_ENABLED)
+ bool themeLoaded = LoadJSON(mThemeBuilder, mDefaultThemeFilePath);
DALI_LOG_STREAM(gLogFilter, Debug::Concise, " themeLoaded" << (themeLoaded ? "success" : "failure"));
+#else
+ LoadJSON(mThemeBuilder, mDefaultThemeFilePath);
+#endif
+
+ mThemeFile = mDefaultThemeFilePath;
}
+#if defined(DEBUG_ENABLED)
+ Property::Map result = mThemeBuilder.GetConfigurations();
DALI_LOG_STREAM(gLogFilter, Debug::Concise, "GetConfigurations()\n On exit, result Count: " << (result.Count() != 0));
DALI_LOG_STREAM(gLogFilter, Debug::Verbose, " result: " << result);
+#endif
- return result;
+ return mThemeBuilder.GetConfigurations();
}
void StyleManager::SetBrokenImageUrl(DevelStyleManager::BrokenImageType brokenImageType, const std::string& brokenImageUrl)
{
- int brokenType = static_cast<int>(brokenImageType);
- mBrokenImageUrls[brokenType] = brokenImageUrl;
+ int brokenType = static_cast<int>(brokenImageType);
+ mBrokenImageUrls[brokenType] = brokenImageUrl;
Toolkit::StyleManager styleManager = StyleManager::Get();
mBrokenImageChangedSignal.Emit(styleManager);
}
#define DALI_TOOLKIT_INTERNAL_STYLE_MANAGER_H
/*
- * 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.
// INTERNAL INCLUDES
#include <dali-toolkit/devel-api/builder/builder.h>
+#include <dali-toolkit/devel-api/styling/style-manager-devel.h>
#include <dali-toolkit/internal/builder/style.h>
#include <dali-toolkit/public-api/styling/style-manager.h>
-#include <dali-toolkit/devel-api/styling/style-manager-devel.h>
namespace Dali
{
/**
* @copydoc Toolkit::StyleManager::GetConfigurations
*/
- const Property::Map GetConfigurations();
+ const Property::Map& GetConfigurations();
/**
* @copydoc Toolkit::DevelStyleManager::SetBrokenImageUrl
Toolkit::Internal::FeedbackStyle* mFeedbackStyle; ///< Feedback style
- std::vector<std::string> mBrokenImageUrls; ///< Broken Image Urls received from user
+ std::vector<std::string> mBrokenImageUrls; ///< Broken Image Urls received from user
// Signals
Toolkit::StyleManager::StyleChangedSignalType mControlStyleChangeSignal; ///< Emitted when the style( theme/font ) changes for the controls to style themselves
// Whether the given glyph is a color one.
const bool isColorGlyph = data.glyphBitmap.isColorEmoji || data.glyphBitmap.isColorBitmap;
const uint32_t glyphPixelSize = Pixel::GetBytesPerPixel(data.glyphBitmap.format);
- const uint32_t alphaIndex = glyphPixelSize - 1u;
// Determinate iterator range.
const int32_t lineIndexRangeMin = std::max(0, -yOffset);
if(Pixel::RGBA8888 == pixelFormat)
{
- const bool swapChannelsBR = Pixel::BGRA8888 == data.glyphBitmap.format;
-
uint32_t* bitmapBuffer = reinterpret_cast<uint32_t*>(data.bitmapBuffer.GetBuffer());
+ // Skip basic line.
+ bitmapBuffer += (lineIndexRangeMin + yOffset) * static_cast<int32_t>(data.width);
// Fast-cut if style is MASK or OUTLINE. Outline not shown for color glyph.
// Just overwrite transparent color and return.
{
for(int32_t lineIndex = lineIndexRangeMin; lineIndex < lineIndexRangeMax; ++lineIndex)
{
- const int32_t yOffsetIndex = yOffset + lineIndex;
- const int32_t verticalOffset = yOffsetIndex * data.width;
-
// We can use memset here.
- memset(bitmapBuffer + verticalOffset + xOffset + indexRangeMin, 0, (indexRangeMax - indexRangeMin) * sizeof(uint32_t));
+ memset(bitmapBuffer + xOffset + indexRangeMin, 0, (indexRangeMax - indexRangeMin) * sizeof(uint32_t));
+ bitmapBuffer += data.width;
}
return;
}
+ const bool swapChannelsBR = Pixel::BGRA8888 == data.glyphBitmap.format;
+
// Pointer to the color glyph if there is one.
- const uint32_t* const colorGlyphBuffer = isColorGlyph ? reinterpret_cast<uint32_t*>(data.glyphBitmap.buffer) : NULL;
+ const uint8_t* glyphBuffer = data.glyphBitmap.buffer;
// Precalculate input color's packed result.
uint32_t packedInputColor = 0u;
*(packedInputColorBuffer + 1u) = static_cast<uint8_t>(color->g * 255);
*(packedInputColorBuffer) = static_cast<uint8_t>(color->r * 255);
+ // Skip basic line of glyph.
+ glyphBuffer += (lineIndexRangeMin) * static_cast<int32_t>(data.glyphBitmap.width) * glyphPixelSize;
+
// Traverse the pixels of the glyph line per line.
- for(int32_t lineIndex = lineIndexRangeMin; lineIndex < lineIndexRangeMax; ++lineIndex)
+ if(isColorGlyph)
{
- const int32_t yOffsetIndex = yOffset + lineIndex;
-
- const int32_t verticalOffset = yOffsetIndex * data.width;
- const int32_t glyphBufferOffset = lineIndex * static_cast<int32_t>(data.glyphBitmap.width);
- for(int32_t index = indexRangeMin; index < indexRangeMax; ++index)
+ for(int32_t lineIndex = lineIndexRangeMin; lineIndex < lineIndexRangeMax; ++lineIndex)
{
- const int32_t xOffsetIndex = xOffset + index;
-
- if(isColorGlyph)
+ for(int32_t index = indexRangeMin; index < indexRangeMax; ++index)
{
+ const int32_t xOffsetIndex = xOffset + index;
+
// Retrieves the color from the color glyph.
- uint32_t packedColorGlyph = *(colorGlyphBuffer + glyphBufferOffset + index);
+ uint32_t packedColorGlyph = *(reinterpret_cast<const uint32_t*>(glyphBuffer + (index << 2)));
uint8_t* packedColorGlyphBuffer = reinterpret_cast<uint8_t*>(&packedColorGlyph);
// Update the alpha channel.
}
// Set the color into the final pixel buffer.
- *(bitmapBuffer + verticalOffset + xOffsetIndex) = packedColorGlyph;
+ *(bitmapBuffer + xOffsetIndex) = packedColorGlyph;
}
- else
+ bitmapBuffer += data.width;
+ glyphBuffer += data.glyphBitmap.width * glyphPixelSize;
+ }
+ }
+ else
+ {
+ for(int32_t lineIndex = lineIndexRangeMin; lineIndex < lineIndexRangeMax; ++lineIndex)
+ {
+ for(int32_t index = indexRangeMin; index < indexRangeMax; ++index)
{
- // Pack the given color into a 32bit buffer. The alpha channel will be updated later for each pixel.
- // The format is RGBA8888.
- uint32_t packedColor = 0u;
- uint8_t* packedColorBuffer = reinterpret_cast<uint8_t*>(&packedColor);
-
// Update the alpha channel.
- const uint8_t alpha = *(data.glyphBitmap.buffer + glyphPixelSize * (glyphBufferOffset + index) + alphaIndex);
+ const uint8_t alpha = *(glyphBuffer + index);
// Copy non-transparent pixels only
if(alpha > 0u)
{
+ const int32_t xOffsetIndex = xOffset + index;
+
// Check alpha of overlapped pixels
- uint32_t& currentColor = *(bitmapBuffer + verticalOffset + xOffsetIndex);
+ uint32_t& currentColor = *(bitmapBuffer + xOffsetIndex);
uint8_t* packedCurrentColorBuffer = reinterpret_cast<uint8_t*>(¤tColor);
// For any pixel overlapped with the pixel in previous glyphs, make sure we don't
}
else
{
+ // Pack the given color into a 32bit buffer. The alpha channel will be updated later for each pixel.
+ // The format is RGBA8888.
+ uint32_t packedColor = 0u;
+ uint8_t* packedColorBuffer = reinterpret_cast<uint8_t*>(&packedColor);
+
// Color is pre-muliplied with its alpha.
*(packedColorBuffer + 3u) = MultiplyAndNormalizeColor(*(packedInputColorBuffer + 3u), currentAlpha);
*(packedColorBuffer + 2u) = MultiplyAndNormalizeColor(*(packedInputColorBuffer + 2u), currentAlpha);
}
}
}
+ bitmapBuffer += data.width;
+ glyphBuffer += data.glyphBitmap.width * glyphPixelSize;
}
}
}
- else
+ else // Pixel::L8
{
// Below codes required only if not color glyph.
if(!isColorGlyph)
{
- uint8_t* bitmapBuffer = reinterpret_cast<uint8_t*>(data.bitmapBuffer.GetBuffer());
+ uint8_t* bitmapBuffer = data.bitmapBuffer.GetBuffer();
+ const uint8_t* glyphBuffer = data.glyphBitmap.buffer;
+
+ // Skip basic line.
+ bitmapBuffer += (lineIndexRangeMin + yOffset) * static_cast<int32_t>(data.width);
+ glyphBuffer += (lineIndexRangeMin) * static_cast<int32_t>(data.glyphBitmap.width);
// Traverse the pixels of the glyph line per line.
for(int32_t lineIndex = lineIndexRangeMin; lineIndex < lineIndexRangeMax; ++lineIndex)
{
- const int32_t yOffsetIndex = yOffset + lineIndex;
-
- const int32_t verticalOffset = yOffsetIndex * data.width;
- const int32_t glyphBufferOffset = lineIndex * static_cast<int32_t>(data.glyphBitmap.width);
for(int32_t index = indexRangeMin; index < indexRangeMax; ++index)
{
const int32_t xOffsetIndex = xOffset + index;
// Update the alpha channel.
- const uint8_t alpha = *(data.glyphBitmap.buffer + glyphPixelSize * (glyphBufferOffset + index) + alphaIndex);
+ const uint8_t alpha = *(glyphBuffer + index);
// Copy non-transparent pixels only
if(alpha > 0u)
{
// Check alpha of overlapped pixels
- uint8_t& currentAlpha = *(bitmapBuffer + verticalOffset + xOffsetIndex);
+ uint8_t& currentAlpha = *(bitmapBuffer + xOffsetIndex);
// For any pixel overlapped with the pixel in previous glyphs, make sure we don't
// overwrite a previous bigger alpha with a smaller alpha (in order to avoid
currentAlpha = std::max(currentAlpha, alpha);
}
}
+
+ bitmapBuffer += data.width;
+ glyphBuffer += data.glyphBitmap.width;
}
}
}
{
namespace Text
{
-const float DEFAULT_TEXTFIT_MIN = 10.f;
-const float DEFAULT_TEXTFIT_MAX = 100.f;
-const float DEFAULT_TEXTFIT_STEP = 1.f;
-const float DEFAULT_FONT_SIZE_SCALE = 1.f;
+const float DEFAULT_TEXTFIT_MIN = 10.f;
+const float DEFAULT_TEXTFIT_MAX = 100.f;
+const float DEFAULT_TEXTFIT_STEP = 1.f;
+const float DEFAULT_FONT_SIZE_SCALE = 1.f;
const float DEFAULT_DISABLED_COLOR_OPACITY = 0.3f;
//Forward declarations
Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
if(styleManager)
{
- bool temp;
- Property::Map config = Toolkit::DevelStyleManager::GetConfigurations(styleManager);
- if(config["clearFocusOnEscape"].Get(temp))
- {
- mShouldClearFocusOnEscape = temp;
- }
+ const Property::Map& config = Toolkit::DevelStyleManager::GetConfigurations(styleManager);
+ const auto clearFocusOnEscapeValue = config.Find("clearFocusOnEscape", Property::Type::BOOLEAN);
+
+ // Default is true. If config don't have "clearFocusOnEscape" property, make it true.
+ mShouldClearFocusOnEscape = (!clearFocusOnEscapeValue || clearFocusOnEscapeValue->Get<bool>());
}
}
if(styleManager)
{
- customBrokenImageUrlList = Toolkit::DevelStyleManager::GetBrokenImageUrlList(styleManager);
- Property::Map config = Toolkit::DevelStyleManager::GetConfigurations(styleManager);
- config["brokenImageUrl"].Get(brokenImageUrl);
+ customBrokenImageUrlList = Toolkit::DevelStyleManager::GetBrokenImageUrlList(styleManager);
+ const Property::Map& config = Toolkit::DevelStyleManager::GetConfigurations(styleManager);
+ const auto brokenImageUrlValue = config.Find("brokenImageUrl", Property::Type::STRING);
+ if(brokenImageUrlValue)
+ {
+ brokenImageUrlValue->Get(brokenImageUrl);
+ }
}
// Add default image