mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Changed StringAlign on Meter=String to support both horizontal and vertical positioning
This commit is contained in:
parent
817a9369d9
commit
1ec7f71ce7
@ -109,9 +109,15 @@ protected:
|
|||||||
|
|
||||||
enum METER_ALIGNMENT
|
enum METER_ALIGNMENT
|
||||||
{
|
{
|
||||||
ALIGN_LEFT,
|
ALIGN_LEFT, // Same as LeftTop
|
||||||
ALIGN_RIGHT,
|
ALIGN_RIGHT, // Same as RightTop
|
||||||
ALIGN_CENTER
|
ALIGN_CENTER, // Same as CenterTop
|
||||||
|
ALIGN_LEFTBOTTOM,
|
||||||
|
ALIGN_RIGHTBOTTOM,
|
||||||
|
ALIGN_CENTERBOTTOM,
|
||||||
|
ALIGN_LEFTCENTER,
|
||||||
|
ALIGN_RIGHTCENTER,
|
||||||
|
ALIGN_CENTERCENTER
|
||||||
};
|
};
|
||||||
|
|
||||||
enum METER_POSITION
|
enum METER_POSITION
|
||||||
|
@ -103,15 +103,21 @@ int CMeterString::GetX(bool abs)
|
|||||||
{
|
{
|
||||||
switch (m_Align)
|
switch (m_Align)
|
||||||
{
|
{
|
||||||
case ALIGN_CENTER:
|
case ALIGN_CENTER: // Same as ALIGN_CENTERTOP
|
||||||
|
case ALIGN_CENTERBOTTOM:
|
||||||
|
case ALIGN_CENTERCENTER:
|
||||||
x -= m_W / 2;
|
x -= m_W / 2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ALIGN_RIGHT:
|
case ALIGN_RIGHT: // Same as ALIGN_RIGHTTOP
|
||||||
|
case ALIGN_RIGHTBOTTOM:
|
||||||
|
case ALIGN_RIGHTCENTER:
|
||||||
x -= m_W;
|
x -= m_W;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ALIGN_LEFT:
|
case ALIGN_LEFT: // Same as ALIGN_LEFTTOP
|
||||||
|
case ALIGN_LEFTBOTTOM:
|
||||||
|
case ALIGN_LEFTCENTER:
|
||||||
// This is already correct
|
// This is already correct
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -120,6 +126,34 @@ int CMeterString::GetX(bool abs)
|
|||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Returns the Y-coordinate of the meter
|
||||||
|
**
|
||||||
|
*/
|
||||||
|
int CMeterString::GetY(bool abs)
|
||||||
|
{
|
||||||
|
int y = CMeter::GetY();
|
||||||
|
|
||||||
|
if (!abs)
|
||||||
|
{
|
||||||
|
switch (m_Align)
|
||||||
|
{
|
||||||
|
case ALIGN_LEFTCENTER:
|
||||||
|
case ALIGN_RIGHTCENTER:
|
||||||
|
case ALIGN_CENTERCENTER:
|
||||||
|
y -= m_H / 2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ALIGN_LEFTBOTTOM:
|
||||||
|
case ALIGN_RIGHTBOTTOM:
|
||||||
|
case ALIGN_CENTERBOTTOM:
|
||||||
|
y -= m_H;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Create the font that is used to draw the text.
|
** Create the font that is used to draw the text.
|
||||||
@ -341,18 +375,42 @@ void CMeterString::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
|||||||
m_Scale = parser.ParseDouble(scale.c_str(), 1);
|
m_Scale = parser.ParseDouble(scale.c_str(), 1);
|
||||||
|
|
||||||
const WCHAR* align = parser.ReadString(section, L"StringAlign", L"LEFT").c_str();
|
const WCHAR* align = parser.ReadString(section, L"StringAlign", L"LEFT").c_str();
|
||||||
if (_wcsicmp(align, L"LEFT") == 0)
|
if (_wcsicmp(align, L"LEFT") == 0 || _wcsicmp(align, L"LEFTTOP") == 0)
|
||||||
{
|
{
|
||||||
m_Align = ALIGN_LEFT;
|
m_Align = ALIGN_LEFT;
|
||||||
}
|
}
|
||||||
else if (_wcsicmp(align, L"RIGHT") == 0)
|
else if (_wcsicmp(align, L"RIGHT") == 0 || _wcsicmp(align, L"RIGHTTOP") == 0)
|
||||||
{
|
{
|
||||||
m_Align = ALIGN_RIGHT;
|
m_Align = ALIGN_RIGHT;
|
||||||
}
|
}
|
||||||
else if (_wcsicmp(align, L"CENTER") == 0)
|
else if (_wcsicmp(align, L"CENTER") == 0 || _wcsicmp(align, L"CENTERTOP") == 0)
|
||||||
{
|
{
|
||||||
m_Align = ALIGN_CENTER;
|
m_Align = ALIGN_CENTER;
|
||||||
}
|
}
|
||||||
|
else if (_wcsicmp(align, L"LEFTBOTTOM") == 0)
|
||||||
|
{
|
||||||
|
m_Align = ALIGN_LEFTBOTTOM;
|
||||||
|
}
|
||||||
|
else if (_wcsicmp(align, L"RIGHTBOTTOM") == 0)
|
||||||
|
{
|
||||||
|
m_Align = ALIGN_RIGHTBOTTOM;
|
||||||
|
}
|
||||||
|
else if (_wcsicmp(align, L"CENTERBOTTOM") == 0)
|
||||||
|
{
|
||||||
|
m_Align = ALIGN_CENTERBOTTOM;
|
||||||
|
}
|
||||||
|
else if (_wcsicmp(align, L"LEFTCENTER") == 0)
|
||||||
|
{
|
||||||
|
m_Align = ALIGN_LEFTCENTER;
|
||||||
|
}
|
||||||
|
else if (_wcsicmp(align, L"RIGHTCENTER") == 0)
|
||||||
|
{
|
||||||
|
m_Align = ALIGN_RIGHTCENTER;
|
||||||
|
}
|
||||||
|
else if (_wcsicmp(align, L"CENTERCENTER") == 0)
|
||||||
|
{
|
||||||
|
m_Align = ALIGN_CENTERCENTER;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogWithArgs(LOG_ERROR, L"StringAlign=%s is not valid in [%s]", align, m_Name.c_str());
|
LogWithArgs(LOG_ERROR, L"StringAlign=%s is not valid in [%s]", align, m_Name.c_str());
|
||||||
@ -541,16 +599,49 @@ bool CMeterString::DrawString(Graphics& graphics, RectF* rect)
|
|||||||
|
|
||||||
switch (m_Align)
|
switch (m_Align)
|
||||||
{
|
{
|
||||||
case ALIGN_CENTER:
|
case ALIGN_CENTERCENTER:
|
||||||
stringFormat.SetAlignment(StringAlignmentCenter);
|
stringFormat.SetAlignment(StringAlignmentCenter);
|
||||||
|
stringFormat.SetLineAlignment(StringAlignmentCenter);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ALIGN_RIGHT:
|
case ALIGN_RIGHTCENTER:
|
||||||
stringFormat.SetAlignment(StringAlignmentFar);
|
stringFormat.SetAlignment(StringAlignmentFar);
|
||||||
|
stringFormat.SetLineAlignment(StringAlignmentCenter);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ALIGN_LEFT:
|
case ALIGN_LEFTCENTER:
|
||||||
stringFormat.SetAlignment(StringAlignmentNear);
|
stringFormat.SetAlignment(StringAlignmentNear);
|
||||||
|
stringFormat.SetLineAlignment(StringAlignmentCenter);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ALIGN_CENTERBOTTOM:
|
||||||
|
stringFormat.SetAlignment(StringAlignmentCenter);
|
||||||
|
stringFormat.SetLineAlignment(StringAlignmentFar);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ALIGN_RIGHTBOTTOM:
|
||||||
|
stringFormat.SetAlignment(StringAlignmentFar);
|
||||||
|
stringFormat.SetLineAlignment(StringAlignmentFar);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ALIGN_LEFTBOTTOM:
|
||||||
|
stringFormat.SetAlignment(StringAlignmentNear);
|
||||||
|
stringFormat.SetLineAlignment(StringAlignmentFar);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ALIGN_CENTER: // Same as CenterTop
|
||||||
|
stringFormat.SetAlignment(StringAlignmentCenter);
|
||||||
|
stringFormat.SetLineAlignment(StringAlignmentNear);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ALIGN_RIGHT: // Same as RightTop
|
||||||
|
stringFormat.SetAlignment(StringAlignmentFar);
|
||||||
|
stringFormat.SetLineAlignment(StringAlignmentNear);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ALIGN_LEFT: // Same as LeftTop
|
||||||
|
stringFormat.SetAlignment(StringAlignmentNear);
|
||||||
|
stringFormat.SetLineAlignment(StringAlignmentNear);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ public:
|
|||||||
virtual UINT GetTypeID() { return TypeID<CMeterString>(); }
|
virtual UINT GetTypeID() { return TypeID<CMeterString>(); }
|
||||||
|
|
||||||
virtual int GetX(bool abs = false);
|
virtual int GetX(bool abs = false);
|
||||||
|
virtual int GetY(bool abs = false);
|
||||||
|
|
||||||
virtual void Initialize();
|
virtual void Initialize();
|
||||||
virtual bool Update();
|
virtual bool Update();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user