X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Finput-style.h;h=fed87e814c2c338eddb4e1e5e4730658f2642985;hb=29a52105283ce8ced672ed92545daeacf882316a;hp=30ce38ce760b47be433e2fe23d757ff26f2a5ae6;hpb=39fc99671f79f683a834406e24edf485752c600d;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/text/input-style.h b/dali-toolkit/internal/text/input-style.h index 30ce38c..fed87e8 100644 --- a/dali-toolkit/internal/text/input-style.h +++ b/dali-toolkit/internal/text/input-style.h @@ -1,8 +1,8 @@ -#ifndef __DALI_TOOLKIT_TEXT_INPUT_STYLE_H__ -#define __DALI_TOOLKIT_TEXT_INPUT_STYLE_H__ +#ifndef DALI_TOOLKIT_TEXT_INPUT_STYLE_H +#define DALI_TOOLKIT_TEXT_INPUT_STYLE_H /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * 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. @@ -19,72 +19,234 @@ */ // EXTERNAL INCLUDES -#include +#include // INTERNAL INCLUDES #include namespace Dali { - namespace Toolkit { - namespace Text { - /** * The input text's style. */ struct InputStyle { + enum Mask + { + NONE = 0x0000, + INPUT_COLOR = 0x0001, + INPUT_FONT_FAMILY = 0x0002, + INPUT_POINT_SIZE = 0x0004, + INPUT_FONT_WEIGHT = 0x0008, + INPUT_FONT_WIDTH = 0x0010, + INPUT_FONT_SLANT = 0x0020, + INPUT_LINE_SPACING = 0x0040, + INPUT_UNDERLINE = 0x0080, + INPUT_SHADOW = 0x0100, + INPUT_EMBOSS = 0x0200, + INPUT_OUTLINE = 0x0400, + INPUT_STRIKETHROUGH = 0x0800 + }; + InputStyle() - : textColor( Color::BLACK ), - fontStyle(), + : textColor(Color::BLACK), familyName(), - weight( TextAbstraction::FontWeight::NORMAL ), - width( TextAbstraction::FontWidth::NORMAL ), - slant( TextAbstraction::FontSlant::NORMAL ), - size( 0.f ), - lineSpacing( 0.f ), + weight(TextAbstraction::FontWeight::NORMAL), + width(TextAbstraction::FontWidth::NORMAL), + slant(TextAbstraction::FontSlant::NORMAL), + size(0.f), + lineSpacing(0.f), underlineProperties(), shadowProperties(), embossProperties(), outlineProperties(), - isDefaultColor( true ), - familyDefined( false ), - weightDefined( false ), - widthDefined( false ), - slantDefined( false ), - sizeDefined( false ), - lineSpacingDefined( false ) - {} - - ~InputStyle() - {}; - - Vector4 textColor; ///< The text's color. - std::string fontStyle; ///< The font's style string. - std::string familyName; ///< The font's family name. - FontWeight weight; ///< The font's weight. - FontWidth width; ///< The font's width. - FontSlant slant; ///< The font's slant. - float size; ///< The font's size. - - float lineSpacing; ///< The line's spacing. - std::string underlineProperties; ///< The underline properties string. - std::string shadowProperties; ///< The shadow properties string. - std::string embossProperties; ///< The emboss properties string. - std::string outlineProperties; ///< The outline properties string. - - bool isDefaultColor : 1; ///< Whether the text's color is the default. - bool familyDefined : 1; ///< Whether the font's family is defined. - bool weightDefined : 1; ///< Whether the font's weight is defined. - bool widthDefined : 1; ///< Whether the font's width is defined. - bool slantDefined : 1; ///< Whether the font's slant is defined. - bool sizeDefined : 1; ///< Whether the font's size is defined. - - bool lineSpacingDefined : 1; ///< Whether the line spacing is defined. + strikethroughProperties(), + isDefaultColor(true), + isFamilyDefined(false), + isWeightDefined(false), + isWidthDefined(false), + isSlantDefined(false), + isSizeDefined(false), + isLineSpacingDefined(false), + isUnderlineDefined(false), + isShadowDefined(false), + isEmbossDefined(false), + isOutlineDefined(false), + isStrikethroughDefined(false) + { + } + + ~InputStyle(){}; + + /** + * @brief + * + * Does not copy the font-style, underline, shadow, emboss and outline property strings. + */ + void Copy(const InputStyle& inputStyle) + { + isDefaultColor = inputStyle.isDefaultColor; + textColor = inputStyle.textColor; + + isFamilyDefined = inputStyle.isFamilyDefined; + familyName = inputStyle.familyName; + + isWeightDefined = inputStyle.isWeightDefined; + weight = inputStyle.weight; + + isWidthDefined = inputStyle.isWidthDefined; + width = inputStyle.width; + + isSlantDefined = inputStyle.isSlantDefined; + slant = inputStyle.slant; + + isSizeDefined = inputStyle.isSizeDefined; + size = inputStyle.size; + + isLineSpacingDefined = inputStyle.isLineSpacingDefined; + lineSpacing = inputStyle.lineSpacing; + + isUnderlineDefined = inputStyle.isUnderlineDefined; + underlineProperties = inputStyle.underlineProperties; + + isShadowDefined = inputStyle.isShadowDefined; + shadowProperties = inputStyle.shadowProperties; + + isEmbossDefined = inputStyle.isEmbossDefined; + embossProperties = inputStyle.embossProperties; + + isOutlineDefined = inputStyle.isOutlineDefined; + outlineProperties = inputStyle.outlineProperties; + + isStrikethroughDefined = inputStyle.isStrikethroughDefined; + strikethroughProperties = inputStyle.strikethroughProperties; + } + + /** + * @brief + * + * Does not compare the font-style, underline, shadow, emboss and outline property strings. + */ + bool Equal(const InputStyle& inputStyle) const + { + if((isDefaultColor != inputStyle.isDefaultColor) || + (isFamilyDefined != inputStyle.isFamilyDefined) || + (isWeightDefined != inputStyle.isWeightDefined) || + (isWidthDefined != inputStyle.isWidthDefined) || + (isSlantDefined != inputStyle.isSlantDefined) || + (isSizeDefined != inputStyle.isSizeDefined) || + (isLineSpacingDefined != inputStyle.isLineSpacingDefined) || + (isUnderlineDefined != inputStyle.isUnderlineDefined) || + (isShadowDefined != inputStyle.isShadowDefined) || + (isEmbossDefined != inputStyle.isEmbossDefined) || + (isOutlineDefined != inputStyle.isOutlineDefined) || + (textColor != inputStyle.textColor) || + (familyName != inputStyle.familyName) || + (weight != inputStyle.weight) || + (width != inputStyle.width) || + (slant != inputStyle.slant) || + (size != inputStyle.size) || + (lineSpacing != inputStyle.lineSpacing) || + (underlineProperties != inputStyle.underlineProperties) || + (shadowProperties != inputStyle.shadowProperties) || + (embossProperties != inputStyle.embossProperties) || + (outlineProperties != inputStyle.outlineProperties) || + (isStrikethroughDefined != inputStyle.isStrikethroughDefined)) + { + return false; + } + + return true; + } + + Mask GetInputStyleChangeMask(const InputStyle& inputStyle) const + { + Mask mask = NONE; + + if(textColor != inputStyle.textColor) + { + mask = static_cast(mask | INPUT_COLOR); + } + if(familyName != inputStyle.familyName) + { + mask = static_cast(mask | INPUT_FONT_FAMILY); + } + if(weight != inputStyle.weight) + { + mask = static_cast(mask | INPUT_FONT_WEIGHT); + } + if(width != inputStyle.width) + { + mask = static_cast(mask | INPUT_FONT_WIDTH); + } + if(slant != inputStyle.slant) + { + mask = static_cast(mask | INPUT_FONT_SLANT); + } + if(size != inputStyle.size) + { + mask = static_cast(mask | INPUT_POINT_SIZE); + } + if(lineSpacing != inputStyle.lineSpacing) + { + mask = static_cast(mask | INPUT_LINE_SPACING); + } + if(underlineProperties != inputStyle.underlineProperties) + { + mask = static_cast(mask | INPUT_UNDERLINE); + } + if(shadowProperties != inputStyle.shadowProperties) + { + mask = static_cast(mask | INPUT_SHADOW); + } + if(embossProperties != inputStyle.embossProperties) + { + mask = static_cast(mask | INPUT_EMBOSS); + } + if(outlineProperties != inputStyle.outlineProperties) + { + mask = static_cast(mask | INPUT_OUTLINE); + } + if(strikethroughProperties != inputStyle.strikethroughProperties) + { + mask = static_cast(mask | INPUT_STRIKETHROUGH); + } + + return mask; + } + + Vector4 textColor; ///< The text's color. + std::string familyName; ///< The font's family name. + FontWeight weight; ///< The font's weight. + FontWidth width; ///< The font's width. + FontSlant slant; ///< The font's slant. + float size; ///< The font's size. + + float lineSpacing; ///< The line's spacing. + + std::string underlineProperties; ///< The underline properties string. + std::string shadowProperties; ///< The shadow properties string. + std::string embossProperties; ///< The emboss properties string. + std::string outlineProperties; ///< The outline properties string. + std::string strikethroughProperties; ///< The strikethrough properties string. + + bool isDefaultColor : 1; ///< Whether the text's color is the default. + bool isFamilyDefined : 1; ///< Whether the font's family is defined. + bool isWeightDefined : 1; ///< Whether the font's weight is defined. + bool isWidthDefined : 1; ///< Whether the font's width is defined. + bool isSlantDefined : 1; ///< Whether the font's slant is defined. + bool isSizeDefined : 1; ///< Whether the font's size is defined. + + bool isLineSpacingDefined : 1; ///< Whether the line spacing is defined. + bool isUnderlineDefined : 1; ///< Whether the underline parameters are defined. + bool isShadowDefined : 1; ///< Whether the shadow parameters are defined. + bool isEmbossDefined : 1; ///< Whether the emboss parameters are defined. + bool isOutlineDefined : 1; ///< Whether the outline parameters are defined. + bool isStrikethroughDefined : 1; ///< Whether the strikethrough parameters are defined. }; } // namespace Text @@ -93,4 +255,4 @@ struct InputStyle } // namespace Dali -#endif // __DALI_TOOLKIT_TEXT_INPUT_STYLE_H__ +#endif // DALI_TOOLKIT_TEXT_INPUT_STYLE_H