Added MeterStyle functionality:

Rainy, given the "issues" listed at the bottom of this comment, I leave it to you whether to create a build using this revision or use r208 for the build.  I would like to start testing MeterStyle, but there are a few more things it needs work on.

What is MeterStyle?

MeterStyle
This will allow users to create CSS-like "Styles" for meters. This means that all the parameters of a meter can be defined in the style, and then many meters can use the style to eliminate copy / pasting the same parameters over and over on multiple meters. (Examples: FontColor=, FontSize= etc.)

How do I use it?

You will create a new [Section] (as many as you want) in the .ini. The section(s) can have any name.

[MyStringStyle]

Then you will tell Rainmeter that this is a "MeterStyle" and not a measure or meter

Style=Meter

Note: The "value" of the key "Style" can be anything. It can be used to add a description of the style if you like. Style=This style is for the AccuWeather part of this skin
It is however required, both to tell Rainmeter it is not a meter or measure and to have the MeterStyle routines parse it.

Then you define parameters you want to use in the style

FontColor=#FontColor#
FontFace=TheSansBold-Caps
FontSize=11
StringEffect=SHADOW
StringStyle=BOLD
StringAlign=LEFT
AntiAlias=1

Then in any or all meters, you just use

[MeterName]
Meter=STRING (or any other meter type)
MeterStyle=MyStringStyle

None of the parameters in the style are then required to be actually in the meter(s). They are "inherited" from the MeterStyle.

Note: This works and has had preliminary testing with dynamic variables like FontColor=[MeasureName] and regular variables like FontColor=#FontColor#. It doesn't matter if the [Variables] section or the [MeasureName] measure is before or after the [StyleName] in the .ini file.

What if I want to override a MeterStyle parameter on a meter?

Sure. Just put in any parameter with a value different from the one defined in the MeterStyle and the one in the meter will take presidence. All non-defined parameters will still use the MeterStyle value.

[MeterName]
Meter=STRING
MeterStyle=MyStringStyle
FontColor=100,100,100,50

What are these "known issues" you are on about?

This is still a bit of a work in progress. Right now you cannot define X or Y in a style. You can define W and H, but NOT for a STRING meter. You cannot define a "Transformation Matrix" in a style. MattKing will be looking into these tomorrow. W and H in a string meter is our top priority. We will also look at X and Y and hope for an easy solution. Transformation Matrix may have to come later.
This commit is contained in:
jsmorley
2009-09-04 14:48:28 +00:00
parent 863c17bd57
commit 8239919333
16 changed files with 135 additions and 115 deletions

View File

@ -109,6 +109,7 @@ void CMeterString::Initialize()
if(m_FontFamily) delete m_FontFamily;
m_FontFamily = new FontFamily(m_FontFace.c_str());
Status status = m_FontFamily->GetLastStatus();
//===================================================
/* Matt King Code */
// It couldn't find the font family
@ -212,25 +213,27 @@ void CMeterString::ReadConfig(const WCHAR* section)
}
i++;
} while(loop);
m_Color = parser.ReadColor(section, L"FontColor", parser.ReadColor(m_StyleName.c_str(), L"FontColor", Color::Black));
m_EffectColor = parser.ReadColor(section, L"FontEffectColor", parser.ReadColor(m_StyleName.c_str(), L"FontEffectColor", Color::Black));
m_Color = parser.ReadColor(section, L"FontColor", Color::Black);
m_EffectColor = parser.ReadColor(section, L"FontEffectColor", Color::Black);
m_Prefix = parser.ReadString(section, L"Prefix", parser.ReadString(m_StyleName.c_str(), L"Prefix", L"").c_str(),true,true);
m_Postfix = parser.ReadString(section, L"Postfix", parser.ReadString(m_StyleName.c_str(), L"Postfix", L"").c_str(),true,true);
m_Text = parser.ReadString(section, L"Text", parser.ReadString(m_StyleName.c_str(), L"Text", L"").c_str(),true,true);
m_Prefix = parser.ReadString(section, L"Prefix", L"");
m_Postfix = parser.ReadString(section, L"Postfix", L"");
m_Text = parser.ReadString(section, L"Text", L"");
m_Percentual = 0!=parser.ReadInt(section, L"Percentual", 0!=parser.ReadInt(m_StyleName.c_str(), L"Percentual", 0));
m_AutoScale = 0!=parser.ReadInt(section, L"AutoScale", 0!=parser.ReadInt(m_StyleName.c_str(), L"AutoScale", 0));
m_ClipString = 0!=parser.ReadInt(section, L"ClipString", 0!=parser.ReadInt(m_StyleName.c_str(), L"ClipString", 0));
m_Percentual = 0!=parser.ReadInt(section, L"Percentual", 0);
m_AutoScale = 0!=parser.ReadInt(section, L"AutoScale", 0);
m_ClipString = 0!=parser.ReadInt(section, L"ClipString", 0);
m_FontSize = parser.ReadFormula(section, L"FontSize", parser.ReadFormula(m_StyleName.c_str(), L"FontSize", 10));
m_FontSize = parser.ReadFormula(section, L"FontSize", 10);
m_NumOfDecimals = parser.ReadInt(section, L"NumOfDecimals", -1);
m_NumOfDecimals = parser.ReadInt(section, L"NumOfDecimals", parser.ReadInt(m_StyleName.c_str(), L"NumOfDecimals", -1));
m_Angle = (Gdiplus::REAL)parser.ReadFloat(section, L"Angle", 0.0);
m_Angle = (Gdiplus::REAL)parser.ReadFloat(section, L"Angle", (Gdiplus::REAL)parser.ReadFloat(m_StyleName.c_str(), L"Angle",0.0));
std::wstring scale;
scale = parser.ReadString(section, L"Scale", L"1");
scale = parser.ReadString(section, L"Scale", parser.ReadString(m_StyleName.c_str(), L"Scale", L"1").c_str(),true,true);
if (wcschr(scale.c_str(), '.') == NULL)
{
@ -242,10 +245,11 @@ void CMeterString::ReadConfig(const WCHAR* section)
}
m_Scale = wcstod(scale.c_str(), NULL);
m_FontFace = parser.ReadString(section, L"FontFace", L"Arial");
m_FontFace = parser.ReadString(section, L"FontFace", parser.ReadString(m_StyleName.c_str(), L"FontFace", L"Arial").c_str(),true,true);
std::wstring align;
align = parser.ReadString(section, L"StringAlign", L"LEFT");
align = parser.ReadString(section, L"StringAlign", parser.ReadString(m_StyleName.c_str(), L"StringAlign", L"LEFT").c_str(),true,true);
if(_wcsicmp(align.c_str(), L"LEFT") == 0)
{
@ -265,8 +269,8 @@ void CMeterString::ReadConfig(const WCHAR* section)
}
std::wstring style;
style = parser.ReadString(section, L"StringStyle", L"NORMAL");
style = parser.ReadString(section, L"StringStyle", parser.ReadString(m_StyleName.c_str(), L"StringStyle", L"NORMAL").c_str(),true,true);
if(_wcsicmp(style.c_str(), L"NORMAL") == 0)
{
m_Style = NORMAL;
@ -289,8 +293,8 @@ void CMeterString::ReadConfig(const WCHAR* section)
}
std::wstring effect;
effect = parser.ReadString(section, L"StringEffect", L"NONE");
effect = parser.ReadString(section, L"StringEffect", parser.ReadString(m_StyleName.c_str(), L"StringEffect", L"NONE").c_str(),true,true);
if(_wcsicmp(effect.c_str(), L"NONE") == 0)
{
m_Effect = EFFECT_NONE;
@ -322,6 +326,15 @@ void CMeterString::ReadConfig(const WCHAR* section)
}
}
/*
** Update
**
** Updates the value(s) from the measures.
**
*/
/*
** Update
**