mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-06-01 02:56:28 +03:00
More fixes.
--HG-- branch : dev-css
This commit is contained in:
@@ -7,6 +7,12 @@
|
||||
textSelectionBackColor: #969696FF;
|
||||
}
|
||||
|
||||
Tab:selected,
|
||||
Tab:hover,
|
||||
Tab:pressed {
|
||||
textColor: #FFF;
|
||||
}
|
||||
|
||||
TabWidget {
|
||||
tabSeparation: -1dp;
|
||||
drawLineBelowTabs: true;
|
||||
@@ -14,12 +20,6 @@ TabWidget {
|
||||
lineBelowTabsYOffset: -1dp;
|
||||
}
|
||||
|
||||
Tab:selected,
|
||||
Tab:hover,
|
||||
Tab:pressed {
|
||||
textColor: #FFF;
|
||||
}
|
||||
|
||||
ProgressBar {
|
||||
displayPercent: true;
|
||||
verticalExpand: true;
|
||||
@@ -54,3 +54,18 @@ Slider {
|
||||
ScrollBar {
|
||||
expandBackground: true;
|
||||
}
|
||||
|
||||
Window {
|
||||
winFlags: default|shadow;
|
||||
buttonsPositionFixer: -2, 0;
|
||||
}
|
||||
|
||||
Window::title {
|
||||
textColor: #E6E6E6FF;
|
||||
textStyle: shadow;
|
||||
}
|
||||
|
||||
Tooltip {
|
||||
padding: 8dp;
|
||||
textColor: black;
|
||||
}
|
||||
|
||||
@@ -105,6 +105,10 @@ class NodeAttribute {
|
||||
|
||||
Vector2i asVector2i( const Vector2i& defaultValue = Vector2i::Zero ) const;
|
||||
|
||||
Sizef asSizef( const Sizef& defaultValue = Sizef::Zero ) const;
|
||||
|
||||
Sizei asSizei( const Sizei& defaultValue = Sizei::Zero ) const;
|
||||
|
||||
Rect asRect( const Rect& defaultValue = Rect() ) const;
|
||||
|
||||
Rectf asRectf( const Rectf& defaultValue = Rectf() ) const;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define EE_UICUITEXTBOX_H
|
||||
|
||||
#include <eepp/ui/uiwidget.hpp>
|
||||
#include <eepp/ui/uithemeconfig.hpp>
|
||||
#include <eepp/graphics/text.hpp>
|
||||
|
||||
namespace EE { namespace UI {
|
||||
@@ -10,8 +11,12 @@ class EE_API UITextView : public UIWidget {
|
||||
public:
|
||||
static UITextView * New();
|
||||
|
||||
static UITextView * NewWithTag( const std::string& tag );
|
||||
|
||||
UITextView();
|
||||
|
||||
explicit UITextView( const std::string& tag );
|
||||
|
||||
virtual ~UITextView();
|
||||
|
||||
virtual Uint32 getType() const;
|
||||
@@ -26,7 +31,7 @@ class EE_API UITextView : public UIWidget {
|
||||
|
||||
UITextView * setFont( Graphics::Font * font );
|
||||
|
||||
Uint32 getCharacterSize();
|
||||
Uint32 getCharacterSize() const;
|
||||
|
||||
UITextView * setCharacterSize( const Uint32& characterSize );
|
||||
|
||||
@@ -101,8 +106,6 @@ class EE_API UITextView : public UIWidget {
|
||||
Int32 mFontLineCenter;
|
||||
bool mSelecting;
|
||||
|
||||
UITextView( const std::string& tag );
|
||||
|
||||
virtual void drawSelection(Text * textCache);
|
||||
|
||||
virtual void onSizeChange();
|
||||
|
||||
@@ -62,12 +62,8 @@ class EE_API UITheme : protected ResourceManager<UISkin> {
|
||||
|
||||
virtual UIDropDownListStyleConfig getDropDownListStyleConfig();
|
||||
|
||||
virtual UIWindowStyleConfig getWindowStyleConfig();
|
||||
|
||||
virtual UIPushButtonStyleConfig getPushButtonStyleConfig();
|
||||
|
||||
virtual UITooltipStyleConfig getTooltipStyleConfig();
|
||||
|
||||
const CSS::StyleSheet& getStyleSheet() const;
|
||||
|
||||
void setStyleSheet(const CSS::StyleSheet & styleSheet);
|
||||
|
||||
@@ -144,7 +144,6 @@ class UIWindowStyleConfig : public UIFontStyleConfig {
|
||||
Vector2i ButtonsPositionFixer;
|
||||
Uint32 ButtonsSeparation = 4;
|
||||
Int32 MinCornerDistance = 24;
|
||||
Color TitleFontColor = Color( 255, 255, 255, 255 );
|
||||
Uint8 BaseAlpha = 255;
|
||||
bool DecorationAutoSize = true;
|
||||
bool BorderAutoSize = true;
|
||||
|
||||
@@ -10,10 +10,6 @@ class EE_API UIThemeDefault : public UITheme {
|
||||
static UIThemeDefault * New( const std::string& name, const std::string& abbr, Graphics::Font * defaultFont = NULL );
|
||||
|
||||
UIThemeDefault( const std::string& name, const std::string& abbr, Graphics::Font * defaultFont = NULL );
|
||||
|
||||
UIWindowStyleConfig getWindowStyleConfig();
|
||||
|
||||
UITooltipStyleConfig getTooltipStyleConfig();
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#ifndef EE_UICUITOOLTIP_HPP
|
||||
#define EE_UICUITOOLTIP_HPP
|
||||
|
||||
#include <eepp/ui/uinode.hpp>
|
||||
#include <eepp/ui/uithemeconfig.hpp>
|
||||
#include <eepp/ui/uiwidget.hpp>
|
||||
|
||||
namespace EE { namespace Graphics {
|
||||
class Text;
|
||||
@@ -10,7 +9,7 @@ class Text;
|
||||
|
||||
namespace EE { namespace UI {
|
||||
|
||||
class EE_API UITooltip : public UINode {
|
||||
class EE_API UITooltip : public UIWidget {
|
||||
public:
|
||||
static UITooltip * New();
|
||||
|
||||
@@ -30,8 +29,6 @@ class EE_API UITooltip : public UINode {
|
||||
|
||||
virtual void draw();
|
||||
|
||||
virtual void setAlpha( const Float& alpha );
|
||||
|
||||
Graphics::Font * getFont() const;
|
||||
|
||||
void setFont( Graphics::Font * font );
|
||||
@@ -79,6 +76,24 @@ class EE_API UITooltip : public UINode {
|
||||
UITooltipStyleConfig getStyleConfig() const;
|
||||
|
||||
void setStyleConfig(const UITooltipStyleConfig & styleConfig);
|
||||
|
||||
Uint32 getCharacterSize() const;
|
||||
|
||||
UITooltip * setCharacterSize( const Uint32& characterSize );
|
||||
|
||||
UITooltip * setFontStyle( const Uint32 & fontStyle );
|
||||
|
||||
const Uint32& getFontStyle() const;
|
||||
|
||||
const Float& getOutlineThickness() const;
|
||||
|
||||
UITooltip * setOutlineThickness( const Float& outlineThickness );
|
||||
|
||||
const Color& getOutlineColor() const;
|
||||
|
||||
UITooltip * setOutlineColor( const Color& outlineColor );
|
||||
|
||||
virtual bool setAttribute( const NodeAttribute& attribute, const Uint32& state = UIState::StateFlagNormal );
|
||||
protected:
|
||||
Text * mTextCache;
|
||||
UITooltipStyleConfig mStyleConfig;
|
||||
@@ -87,6 +102,8 @@ class EE_API UITooltip : public UINode {
|
||||
Time mTooltipTime;
|
||||
UINode * mTooltipOf;
|
||||
|
||||
virtual void onAlphaChange();
|
||||
|
||||
virtual void onSizeChange();
|
||||
|
||||
virtual void onAutoSize();
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
#include <eepp/scene/nodeattribute.hpp>
|
||||
#include <eepp/ui/uinode.hpp>
|
||||
#include <eepp/ui/uitooltip.hpp>
|
||||
#include <eepp/ui/css/stylesheetelement.hpp>
|
||||
#include <eepp/ui/uithemeconfig.hpp>
|
||||
|
||||
namespace pugi {
|
||||
class xml_node;
|
||||
@@ -12,6 +12,7 @@ class xml_node;
|
||||
|
||||
namespace EE { namespace UI {
|
||||
|
||||
class UITooltip;
|
||||
class UIStyle;
|
||||
|
||||
class EE_API UIWidget : public UINode, public CSS::StyleSheetElement {
|
||||
|
||||
@@ -196,6 +196,14 @@ Vector2i NodeAttribute::asVector2i( const Vector2i & defaultValue ) const {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
Sizef NodeAttribute::asSizef( const Sizef& defaultValue ) const {
|
||||
return Sizef( asVector2f( defaultValue ) );
|
||||
}
|
||||
|
||||
Sizei NodeAttribute::asSizei( const Sizei& defaultValue ) const {
|
||||
return Sizei( asVector2i( defaultValue ) );
|
||||
}
|
||||
|
||||
Rect NodeAttribute::asRect( const Rect& defaultValue ) const {
|
||||
if ( !mValue.empty() && mValue.find( " " ) != std::string::npos ) {
|
||||
Rect rect( defaultValue );
|
||||
@@ -225,9 +233,9 @@ Rect NodeAttribute::asRect( const Rect& defaultValue ) const {
|
||||
}
|
||||
|
||||
Rectf NodeAttribute::asRectf( const Rectf& defaultValue ) const {
|
||||
if ( !mValue.empty() && mValue.find( " " ) != std::string::npos ) {
|
||||
Rectf rect( defaultValue );
|
||||
Rectf rect( defaultValue );
|
||||
|
||||
if ( !mValue.empty() && mValue.find( " " ) != std::string::npos ) {
|
||||
auto ltrbSplit = String::split( mValue, ' ', true );
|
||||
|
||||
if ( ltrbSplit.size() == 4 ) {
|
||||
@@ -242,14 +250,12 @@ Rectf NodeAttribute::asRectf( const Rectf& defaultValue ) const {
|
||||
} else if ( ltrbSplit.size() == 2 ) {
|
||||
rect.Left = PixelDensity::toDpFromString( ltrbSplit[0] );
|
||||
rect.Top = PixelDensity::toDpFromString( ltrbSplit[1] );
|
||||
} else if ( ltrbSplit.size() == 1 ) {
|
||||
rect.Left = rect.Top = rect.Right = rect.Bottom = PixelDensity::toDpFromString( ltrbSplit[0] );
|
||||
}
|
||||
|
||||
return rect;
|
||||
} else if ( !mValue.empty() ) {
|
||||
rect.Left = rect.Top = rect.Right = rect.Bottom = PixelDensity::toDpFromString( mValue );
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
return rect;
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -82,35 +82,71 @@ bool StyleSheetSelector::isGlobal() const {
|
||||
return mGlobal;
|
||||
}
|
||||
|
||||
const Uint32& StyleSheetSelector::getSpecificity() const { return mSpecificity; }
|
||||
const Uint32& StyleSheetSelector::getSpecificity() const {
|
||||
return mSpecificity;
|
||||
}
|
||||
|
||||
void StyleSheetSelector::parseSelector( const std::string& selector ) {
|
||||
auto selPseudo = String::split( selector, ':' );
|
||||
static void splitSelectorPseudoClass( const std::string& selector, std::string& realSelector, std::string& realPseudoClass ) {
|
||||
if ( !selector.empty() ) {
|
||||
bool lastWasColon = false;
|
||||
|
||||
if ( !selPseudo.empty() ) {
|
||||
std::string rselector( selPseudo[0] );
|
||||
for ( int i = (Int32)selector.size() - 1; i >= 0; i-- ) {
|
||||
char curChar = selector[i];
|
||||
|
||||
if ( !rselector.empty() ) {
|
||||
if ( rselector[0] == '.' ) {
|
||||
mClasses.push_back( rselector.substr(1) );
|
||||
mSpecificity += SpecificityClass;
|
||||
} else if ( selector[0] == '#' ) {
|
||||
mId = rselector.substr(1);
|
||||
mSpecificity += SpecificityId;
|
||||
} else if ( selector[0] == '*' ) {
|
||||
mSpecificity += SpecificityGlobal;
|
||||
mGlobal = true;
|
||||
} else {
|
||||
mTagName = rselector;
|
||||
mSpecificity += SpecificityTag;
|
||||
if ( lastWasColon ) {
|
||||
if ( ':' == curChar ) {
|
||||
// no pseudo class
|
||||
realSelector = selector;
|
||||
} else {
|
||||
if ( i+2 <= (int)selector.size() ) {
|
||||
realSelector = selector.substr(0,i+1);
|
||||
realPseudoClass = selector.substr(i+2);
|
||||
} else {
|
||||
realSelector = selector;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
} else if ( ':' == curChar ) {
|
||||
lastWasColon = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( selPseudo.size() > 1 ) {
|
||||
mPseudoClass = selPseudo[1];
|
||||
mSpecificity += SpecificityPseudoClass;
|
||||
if ( lastWasColon ) {
|
||||
if ( selector.size() > 1 )
|
||||
realPseudoClass = selector.substr(1);
|
||||
} else {
|
||||
realSelector = selector;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void StyleSheetSelector::parseSelector( const std::string& selector ) {
|
||||
std::string realSelector = "";
|
||||
std::string realPseudoClass = "";
|
||||
|
||||
splitSelectorPseudoClass( selector, realSelector, realPseudoClass );
|
||||
|
||||
if ( !realSelector.empty() ) {
|
||||
if ( realSelector[0] == '.' ) {
|
||||
mClasses.push_back( realSelector.substr(1) );
|
||||
mSpecificity += SpecificityClass;
|
||||
} else if ( selector[0] == '#' ) {
|
||||
mId = realSelector.substr(1);
|
||||
mSpecificity += SpecificityId;
|
||||
} else if ( realSelector[0] == '*' ) {
|
||||
mSpecificity += SpecificityGlobal;
|
||||
mGlobal = true;
|
||||
} else {
|
||||
mTagName = realSelector;
|
||||
mSpecificity += SpecificityTag;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !realPseudoClass.empty() ) {
|
||||
mPseudoClass = realPseudoClass;
|
||||
mSpecificity += SpecificityPseudoClass;
|
||||
}
|
||||
}
|
||||
|
||||
}}}
|
||||
|
||||
@@ -94,9 +94,11 @@ void UIState::updateState() {
|
||||
for ( int i = StateFlagCount - 1; i >= 0; i-- ) {
|
||||
if ( ( mState & UIStateFlags[i] ) == UIStateFlags[i] ) {
|
||||
if ( stateExists( UIStateFlags[i] ) ) {
|
||||
mCurrentState = UIStateFlags[i];
|
||||
onStateChange();
|
||||
return;
|
||||
if ( mCurrentState != UIStateFlags[i] ) {
|
||||
mCurrentState = UIStateFlags[i];
|
||||
onStateChange();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,10 @@ UITextView * UITextView::New() {
|
||||
return eeNew( UITextView, () );
|
||||
}
|
||||
|
||||
UITextView * UITextView::NewWithTag( const std::string& tag ) {
|
||||
return eeNew( UITextView, ( tag ) );
|
||||
}
|
||||
|
||||
UITextView::UITextView( const std::string& tag ) :
|
||||
UIWidget( tag ),
|
||||
mRealAlignOffset( 0.f, 0.f ),
|
||||
@@ -94,7 +98,7 @@ UITextView * UITextView::setFont( Graphics::Font * font ) {
|
||||
return this;
|
||||
}
|
||||
|
||||
Uint32 UITextView::getCharacterSize() {
|
||||
Uint32 UITextView::getCharacterSize() const {
|
||||
return mTextCache->getCharacterSize();
|
||||
}
|
||||
|
||||
|
||||
@@ -293,18 +293,10 @@ UIDropDownListStyleConfig UITheme::getDropDownListStyleConfig() {
|
||||
return UIDropDownListStyleConfig( getFontStyleConfig() );
|
||||
}
|
||||
|
||||
UIWindowStyleConfig UITheme::getWindowStyleConfig() {
|
||||
return UIWindowStyleConfig( getFontStyleConfig() );
|
||||
}
|
||||
|
||||
UIPushButtonStyleConfig UITheme::getPushButtonStyleConfig() {
|
||||
return UIPushButtonStyleConfig( getFontStyleConfig() );
|
||||
}
|
||||
|
||||
UITooltipStyleConfig UITheme::getTooltipStyleConfig() {
|
||||
return UITooltipStyleConfig( getFontStyleConfig() );
|
||||
}
|
||||
|
||||
const CSS::StyleSheet& UITheme::getStyleSheet() const {
|
||||
return mStyleSheet;
|
||||
}
|
||||
|
||||
@@ -23,19 +23,4 @@ UIThemeDefault::UIThemeDefault( const std::string& name, const std::string& Abbr
|
||||
mFontStyleConfig.FontSelectionBackColor = Color( 150, 150, 150, 255 );
|
||||
}
|
||||
|
||||
UIWindowStyleConfig UIThemeDefault::getWindowStyleConfig() {
|
||||
UIWindowStyleConfig windowStyleConfig = UITheme::getWindowStyleConfig();
|
||||
windowStyleConfig.WinFlags |= UI_WIN_SHADOW;
|
||||
windowStyleConfig.ButtonsPositionFixer.x = -2;
|
||||
windowStyleConfig.TitleFontColor = Color( 230, 230, 230, 255 );
|
||||
return windowStyleConfig;
|
||||
}
|
||||
|
||||
UITooltipStyleConfig UIThemeDefault::getTooltipStyleConfig() {
|
||||
UITooltipStyleConfig tooltipStyleConfig = UITheme::getTooltipStyleConfig();
|
||||
tooltipStyleConfig.FontColor = Color( 0, 0, 0, 255 );
|
||||
tooltipStyleConfig.Padding = Rectf( 4, 6, 4, 6 );
|
||||
return tooltipStyleConfig;
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -3,15 +3,16 @@
|
||||
#include <eepp/graphics/text.hpp>
|
||||
#include <eepp/ui/uithememanager.hpp>
|
||||
#include <eepp/scene/actions/actions.hpp>
|
||||
#include <eepp/graphics/fontmanager.hpp>
|
||||
|
||||
namespace EE { namespace UI {
|
||||
|
||||
UITooltip *UITooltip::New() {
|
||||
UITooltip * UITooltip::New() {
|
||||
return eeNew( UITooltip, () );
|
||||
}
|
||||
|
||||
UITooltip::UITooltip() :
|
||||
UINode(),
|
||||
UIWidget( "tooltip" ),
|
||||
mAlignOffset( 0.f, 0.f ),
|
||||
mTooltipTime( Time::Zero ),
|
||||
mTooltipOf()
|
||||
@@ -23,14 +24,14 @@ UITooltip::UITooltip() :
|
||||
UITheme * theme = UIThemeManager::instance()->getDefaultTheme();
|
||||
|
||||
if ( NULL != theme ) {
|
||||
setStyleConfig( theme->getTooltipStyleConfig() );
|
||||
mStyleConfig.Font = theme->getDefaultFont();
|
||||
}
|
||||
|
||||
if ( NULL == getFont() ) {
|
||||
if ( NULL != UIThemeManager::instance()->getDefaultFont() )
|
||||
setFont( UIThemeManager::instance()->getDefaultFont() );
|
||||
else
|
||||
eePRINTL( "UITooltip::UITooltip : Created a UI TextBox without a defined font." );
|
||||
eePRINTL( "UITooltip::UITooltip : Created a without a defined font." );
|
||||
}
|
||||
|
||||
autoPadding();
|
||||
@@ -132,9 +133,11 @@ const Color& UITooltip::getFontColor() const {
|
||||
}
|
||||
|
||||
void UITooltip::setFontColor( const Color& color ) {
|
||||
mStyleConfig.FontColor = color;
|
||||
mTextCache->setFillColor( mStyleConfig.FontColor );
|
||||
setAlpha( color.a );
|
||||
if ( mStyleConfig.FontColor != color ) {
|
||||
mStyleConfig.FontColor = color;
|
||||
onAlphaChange();
|
||||
invalidateDraw();
|
||||
}
|
||||
}
|
||||
|
||||
const Color& UITooltip::getFontShadowColor() const {
|
||||
@@ -142,17 +145,11 @@ const Color& UITooltip::getFontShadowColor() const {
|
||||
}
|
||||
|
||||
void UITooltip::setFontShadowColor( const Color& color ) {
|
||||
mStyleConfig.ShadowColor = color;
|
||||
setAlpha( color.a );
|
||||
mTextCache->setShadowColor( mStyleConfig.ShadowColor );
|
||||
}
|
||||
|
||||
void UITooltip::setAlpha( const Float& alpha ) {
|
||||
UINode::setAlpha( alpha );
|
||||
mStyleConfig.FontColor.a = (Uint8)alpha;
|
||||
mStyleConfig.ShadowColor.a = (Uint8)alpha;
|
||||
|
||||
mTextCache->setFillColor( mStyleConfig.FontColor );
|
||||
if ( mStyleConfig.ShadowColor != color ) {
|
||||
mStyleConfig.ShadowColor = color;
|
||||
onAlphaChange();
|
||||
invalidateDraw();
|
||||
}
|
||||
}
|
||||
|
||||
void UITooltip::onAutoSize() {
|
||||
@@ -203,15 +200,20 @@ void UITooltip::onSizeChange() {
|
||||
|
||||
void UITooltip::onTextChanged() {
|
||||
sendCommonEvent( Event::OnTextChanged );
|
||||
invalidateDraw();
|
||||
}
|
||||
|
||||
void UITooltip::onFontChanged() {
|
||||
sendCommonEvent( Event::OnFontChanged );
|
||||
invalidateDraw();
|
||||
}
|
||||
|
||||
void UITooltip::setPadding( const Rectf& padding ) {
|
||||
mStyleConfig.Padding = padding;
|
||||
mRealPadding = PixelDensity::dpToPx( padding );
|
||||
if ( mStyleConfig.Padding != padding ) {
|
||||
mStyleConfig.Padding = padding;
|
||||
mRealPadding = PixelDensity::dpToPx( padding );
|
||||
invalidateDraw();
|
||||
}
|
||||
}
|
||||
|
||||
const Rectf& UITooltip::getPadding() const {
|
||||
@@ -262,6 +264,68 @@ UITooltipStyleConfig UITooltip::getStyleConfig() const {
|
||||
return mStyleConfig;
|
||||
}
|
||||
|
||||
Uint32 UITooltip::getCharacterSize() const {
|
||||
return mTextCache->getCharacterSize();
|
||||
}
|
||||
|
||||
UITooltip * UITooltip::setCharacterSize( const Uint32 & characterSize ) {
|
||||
if ( mTextCache->getCharacterSize() != characterSize ) {
|
||||
mStyleConfig.CharacterSize = characterSize;
|
||||
mTextCache->setCharacterSize( characterSize );
|
||||
onAutoSize();
|
||||
autoAlign();
|
||||
invalidateDraw();
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
UITooltip * UITooltip::setFontStyle(const Uint32 & fontStyle) {
|
||||
if ( mStyleConfig.Style != fontStyle ) {
|
||||
mTextCache->setStyle( fontStyle );
|
||||
mStyleConfig.Style = fontStyle;
|
||||
onAutoSize();
|
||||
autoAlign();
|
||||
invalidateDraw();
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
const Uint32 &UITooltip::getFontStyle() const {
|
||||
return mStyleConfig.Style;
|
||||
}
|
||||
|
||||
const Float &UITooltip::getOutlineThickness() const {
|
||||
return mStyleConfig.OutlineThickness;
|
||||
}
|
||||
|
||||
UITooltip * UITooltip::setOutlineThickness( const Float & outlineThickness ) {
|
||||
if ( mStyleConfig.OutlineThickness != outlineThickness ) {
|
||||
mTextCache->setOutlineThickness( outlineThickness );
|
||||
mStyleConfig.OutlineThickness = outlineThickness;
|
||||
onAutoSize();
|
||||
autoAlign();
|
||||
invalidateDraw();
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
const Color &UITooltip::getOutlineColor() const {
|
||||
return mStyleConfig.OutlineColor;
|
||||
}
|
||||
|
||||
UITooltip * UITooltip::setOutlineColor(const Color & outlineColor) {
|
||||
if ( mStyleConfig.OutlineColor != outlineColor ) {
|
||||
mTextCache->setOutlineColor( outlineColor );
|
||||
onAlphaChange();
|
||||
invalidateDraw();
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
void UITooltip::setStyleConfig(const UITooltipStyleConfig & styleConfig) {
|
||||
mStyleConfig = styleConfig;
|
||||
|
||||
@@ -277,4 +341,71 @@ void UITooltip::setStyleConfig(const UITooltipStyleConfig & styleConfig) {
|
||||
mTextCache->setOutlineColor( mStyleConfig.OutlineColor );
|
||||
}
|
||||
|
||||
bool UITooltip::setAttribute( const NodeAttribute& attribute, const Uint32& state ) {
|
||||
const std::string& name = attribute.getName();
|
||||
|
||||
if ( "textcolor" == name ) {
|
||||
setFontColor( attribute.asColor() );
|
||||
} else if ( "padding" == name ) {
|
||||
setPadding( attribute.asRectf() );
|
||||
} else if ( "textshadowcolor" == name ) {
|
||||
setFontShadowColor( attribute.asColor() );
|
||||
} else if ( "fontfamily" == name || "fontname" == name ) {
|
||||
Font * font = FontManager::instance()->getByName( attribute.asString() );
|
||||
|
||||
if ( NULL != font )
|
||||
setFont( font );
|
||||
} else if ( "textsize" == name || "fontsize" == name || "charactersize" == name ) {
|
||||
setCharacterSize( attribute.asDpDimensionI() );
|
||||
} else if ( "textstyle" == name || "fontstyle" == name ) {
|
||||
std::string valStr = attribute.asString();
|
||||
String::toLowerInPlace( valStr );
|
||||
std::vector<std::string> strings = String::split( valStr, '|' );
|
||||
Uint32 flags = Text::Regular;
|
||||
|
||||
if ( strings.size() ) {
|
||||
for ( std::size_t i = 0; i < strings.size(); i++ ) {
|
||||
std::string cur = strings[i];
|
||||
String::toLowerInPlace( cur );
|
||||
|
||||
if ( "underlined" == cur || "underline" == cur )
|
||||
flags |= Text::Underlined;
|
||||
else if ( "bold" == cur )
|
||||
flags |= Text::Bold;
|
||||
else if ( "italic" == cur )
|
||||
flags |= Text::Italic;
|
||||
else if ( "strikethrough" == cur )
|
||||
flags |= Text::StrikeThrough;
|
||||
else if ( "shadowed" == cur || "shadow" == cur )
|
||||
flags |= Text::Shadow;
|
||||
}
|
||||
|
||||
setFontStyle( flags );
|
||||
}
|
||||
} else if ( "fontoutlinethickness" == name ) {
|
||||
setOutlineThickness( attribute.asDpDimension() );
|
||||
} else if ( "fontoutlinecolor" == name ) {
|
||||
setOutlineColor( attribute.asColor() );
|
||||
} else {
|
||||
return UIWidget::setAttribute( attribute, state );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void UITooltip::onAlphaChange() {
|
||||
Color color( mStyleConfig.FontColor );
|
||||
color.a = mStyleConfig.FontColor.a * getAlpha() / 255.f;
|
||||
|
||||
Color shadowColor( mStyleConfig.ShadowColor );
|
||||
shadowColor.a = mStyleConfig.ShadowColor.a * getAlpha() / 255.f;
|
||||
|
||||
Color outlineColor( mStyleConfig.OutlineColor );
|
||||
outlineColor.a = mStyleConfig.OutlineColor.a * getAlpha() / 255.f;
|
||||
|
||||
mTextCache->setFillColor( color );
|
||||
mTextCache->setShadowColor( shadowColor );
|
||||
mTextCache->setOutlineColor( outlineColor );
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <eepp/ui/uiwidget.hpp>
|
||||
#include <eepp/ui/uithememanager.hpp>
|
||||
#include <eepp/ui/uistyle.hpp>
|
||||
#include <eepp/ui/uitooltip.hpp>
|
||||
#include <eepp/graphics/drawablesearcher.hpp>
|
||||
#include <eepp/ui/uiscenenode.hpp>
|
||||
#include <pugixml/pugixml.hpp>
|
||||
|
||||
@@ -25,7 +25,7 @@ UIWindow * UIWindow::New() {
|
||||
}
|
||||
|
||||
UIWindow::UIWindow( UIWindow::WindowBaseContainerType type ) :
|
||||
UIWindow( type, NULL != UIThemeManager::instance()->getDefaultTheme() ? UIThemeManager::instance()->getDefaultTheme()->getWindowStyleConfig() : UIWindowStyleConfig() )
|
||||
UIWindow( type, UIWindowStyleConfig() )
|
||||
{}
|
||||
|
||||
UIWindow::UIWindow( UIWindow::WindowBaseContainerType type, const UIWindowStyleConfig& windowStyleConfig ) :
|
||||
@@ -1073,20 +1073,12 @@ const Uint8& UIWindow::getBaseAlpha() const {
|
||||
|
||||
void UIWindow::setTitle( const String& text ) {
|
||||
if ( NULL == mTitle ) {
|
||||
mTitle = UITextView::New();
|
||||
mTitle = UITextView::NewWithTag( "window::title" );
|
||||
mTitle->setLayoutSizeRules( FIXED, FIXED );
|
||||
mTitle->writeCtrlFlag( NODE_FLAG_OWNED_BY_NODE, 1 );
|
||||
mTitle->setParent( this );
|
||||
mTitle->setHorizontalAlign( getHorizontalAlign() );
|
||||
mTitle->setVerticalAlign( getVerticalAlign() );
|
||||
mTitle->setFontColor( mStyleConfig.TitleFontColor );
|
||||
|
||||
if ( mStyleConfig.Style & Text::Shadow ) {
|
||||
UIFontStyleConfig fsc = mTitle->getFontStyleConfig();
|
||||
fsc.Style |= Text::Shadow;
|
||||
mTitle->setFontStyleConfig( fsc );
|
||||
}
|
||||
|
||||
mTitle->setEnabled( false );
|
||||
mTitle->setVisible( !( mStyleConfig.WinFlags & UI_WIN_NO_BORDER ) );
|
||||
}
|
||||
@@ -1426,10 +1418,6 @@ bool UIWindow::setAttribute( const NodeAttribute& attribute, const Uint32& state
|
||||
unsigned int val = attribute.asUint();
|
||||
if ( val <= 255 )
|
||||
setBaseAlpha( (Uint8)val );
|
||||
} else if ( "titlefontcolor" == name ) {
|
||||
mStyleConfig.TitleFontColor = attribute.asColor();
|
||||
if ( NULL != mTitle )
|
||||
setTitle( mTitle->getText() );
|
||||
} else if ( "buttonpositionfixer" == name ) {
|
||||
mStyleConfig.ButtonsPositionFixer = attribute.asVector2i();
|
||||
fixChildsSize();
|
||||
@@ -1460,6 +1448,26 @@ bool UIWindow::setAttribute( const NodeAttribute& attribute, const Uint32& state
|
||||
|
||||
setWinFlags( winflags );
|
||||
}
|
||||
} else if ( "decorationsize" == name ) {
|
||||
mStyleConfig.DecorationSize = attribute.asSizei();
|
||||
fixChildsSize();
|
||||
} else if ( "bordersize" == name ) {
|
||||
mStyleConfig.BorderSize = attribute.asSizei();
|
||||
fixChildsSize();
|
||||
} else if ( "minwindowsize" == name ) {
|
||||
mStyleConfig.MinWindowSize = attribute.asSizef();
|
||||
fixChildsSize();
|
||||
} else if ( "buttonsseparation" == name ) {
|
||||
mStyleConfig.ButtonsSeparation = attribute.asUint();
|
||||
fixChildsSize();
|
||||
} else if ( "mincornerdistance" == name ) {
|
||||
mStyleConfig.MinCornerDistance = attribute.asInt();
|
||||
} else if ( "decorationautosize" == name ) {
|
||||
mStyleConfig.DecorationAutoSize = attribute.asBool();
|
||||
fixChildsSize();
|
||||
} else if ( "borderautosize" == name ) {
|
||||
mStyleConfig.BorderAutoSize = attribute.asBool();
|
||||
fixChildsSize();
|
||||
} else {
|
||||
return UIWidget::setAttribute( attribute, state );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user