mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
D2D: Removed centering of text within W/H (from 481442b
) due to conflict with different alignments and a meter's defined W/H.
This commit is contained in:
parent
481442bc19
commit
52b5e2584a
@ -309,40 +309,18 @@ void CanvasD2D::DrawTextW(const WCHAR* str, UINT strLen, const TextFormat& forma
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
TextFormatD2D& formatD2D = (TextFormatD2D&)format;
|
||||
const bool right = formatD2D.GetHorizontalAlignment() == Gfx::HorizontalAlignment::Right;
|
||||
const bool bottom = formatD2D.GetVerticalAlignment() == Gfx::VerticalAlignment::Bottom;
|
||||
|
||||
formatD2D.CreateLayout(str, strLen, rect.Width, rect.Height);
|
||||
|
||||
// Center text inside rect
|
||||
DWRITE_TEXT_METRICS metrics;
|
||||
formatD2D.m_TextLayout->GetMetrics(&metrics);
|
||||
|
||||
float xOffset = (rect.Width - metrics.width) / 2.0f;
|
||||
float yOffset = (rect.Height - metrics.height) / 2.0f;
|
||||
|
||||
switch (formatD2D.GetHorizontalAlignment())
|
||||
{
|
||||
case Gfx::HorizontalAlignment::Center:
|
||||
xOffset = xOffset / 2.0f;
|
||||
break;
|
||||
|
||||
case Gfx::HorizontalAlignment::Right:
|
||||
xOffset = -xOffset;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (formatD2D.GetVerticalAlignment())
|
||||
{
|
||||
case Gfx::VerticalAlignment::Center:
|
||||
yOffset = yOffset / 2.0f;
|
||||
break;
|
||||
|
||||
case Gfx::VerticalAlignment::Bottom:
|
||||
yOffset = -yOffset;
|
||||
break;
|
||||
}
|
||||
float xOffset = 0.0f;
|
||||
formatD2D.m_TextLayout->GetFontSize(0, &xOffset);
|
||||
xOffset /= 6.0f;
|
||||
|
||||
m_Target->DrawTextLayout(
|
||||
D2D1::Point2F(m_AccurateText ? rect.X : rect.X + xOffset, rect.Y + yOffset),
|
||||
D2D1::Point2F(m_AccurateText ? rect.X : right ? rect.X - xOffset : rect.X + xOffset,
|
||||
m_AccurateText || !bottom ? rect.Y : rect.Y - 1.0f),
|
||||
formatD2D.m_TextLayout.Get(),
|
||||
solidBrush.Get());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user