mirror of
https://github.com/beefytech/Beef.git
synced 2025-07-13 03:35:59 +02:00
Initial theme support
This commit is contained in:
parent
b50fbdb51d
commit
657866c3bc
18 changed files with 573 additions and 197 deletions
|
@ -78,7 +78,8 @@ namespace Beefy.theme.dark
|
|||
{
|
||||
using (g.PushColor(mDisabled ? 0x80FFFFFF : Color.White))
|
||||
{
|
||||
DarkTheme.DrawUnderlined(g, mLabel, GS!(2), (mHeight - GS!(20)) / 2 + mLabelYOfs, .Centered, mWidth - GS!(4), .Truncate);
|
||||
using (g.PushColor(DarkTheme.COLOR_TEXT))
|
||||
DarkTheme.DrawUnderlined(g, mLabel, GS!(2), (mHeight - GS!(20)) / 2 + mLabelYOfs, .Centered, mWidth - GS!(4), .Truncate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -132,7 +132,8 @@ namespace Beefy.theme.dark
|
|||
float fontHeight = g.mFont.GetHeight();
|
||||
|
||||
//g.DrawString(label, mLabelX, (mHeight - GS!(24)) / 2, mLabelAlign, mWidth - mLabelX - GS!(24), FontOverflowMode.Ellipsis);
|
||||
g.DrawString(label, mLabelX, (mHeight - fontHeight) / 2 - (int)GS!(3.5f), mLabelAlign, mWidth - mLabelX - GS!(24), FontOverflowMode.Ellipsis);
|
||||
using (g.PushColor(DarkTheme.COLOR_TEXT))
|
||||
g.DrawString(label, mLabelX, (mHeight - fontHeight) / 2 - (int)GS!(3.5f), mLabelAlign, mWidth - mLabelX - GS!(24), FontOverflowMode.Ellipsis);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ namespace Beefy.theme.dark
|
|||
{
|
||||
public float mChildIndent;
|
||||
public DarkTreeOpenButton mOpenButton;
|
||||
public uint32 mTextColor = Color.White;
|
||||
public uint32? mTextColor;
|
||||
public uint32 mFocusColor = DarkTheme.COLOR_MENU_FOCUSED;
|
||||
public uint32 mSelectColor = DarkTheme.COLOR_MENU_SELECTED;
|
||||
public float mTextAreaLengthOffset;
|
||||
|
@ -205,6 +205,9 @@ namespace Beefy.theme.dark
|
|||
for (var child in mChildItems)
|
||||
child.RehupScale(oldScale, newScale);
|
||||
}
|
||||
|
||||
mFocusColor = DarkTheme.COLOR_MENU_FOCUSED;
|
||||
mSelectColor = DarkTheme.COLOR_MENU_SELECTED;
|
||||
}
|
||||
|
||||
protected virtual float GetLabelOffset()
|
||||
|
@ -320,7 +323,7 @@ namespace Beefy.theme.dark
|
|||
wantWidth -= listView.mInsets.mRight;
|
||||
}
|
||||
|
||||
using (g.PushColor(mTextColor))
|
||||
using (g.PushColor(mTextColor ?? DarkTheme.COLOR_TEXT))
|
||||
g.DrawString(mLabel, labelX, 0, .Left, wantWidth, ((nextContentColumn != -1) || (listView.mEndInEllipsis)) ? .Ellipsis : .Overflow);
|
||||
}
|
||||
}
|
||||
|
@ -924,7 +927,8 @@ namespace Beefy.theme.dark
|
|||
var column = mColumns[columnIdx];
|
||||
float drawXOfs = GS!(6);
|
||||
float drawWidth = column.mWidth - drawXOfs - GS!(6);
|
||||
g.DrawString(column.mLabel, drawXOfs, mHeaderLabelYOfs + GS!(2), FontAlign.Left, drawWidth, (columnIdx < mColumns.Count - 1) ? FontOverflowMode.Ellipsis : FontOverflowMode.Overflow);
|
||||
using (g.PushColor(DarkTheme.COLOR_TEXT))
|
||||
g.DrawString(column.mLabel, drawXOfs, mHeaderLabelYOfs + GS!(2), FontAlign.Left, drawWidth, (columnIdx < mColumns.Count - 1) ? FontOverflowMode.Ellipsis : FontOverflowMode.Overflow);
|
||||
|
||||
if (columnIdx != 0)
|
||||
{
|
||||
|
|
|
@ -40,9 +40,12 @@ namespace Beefy.theme.dark
|
|||
leftStr.RemoveToEnd(barIdx);
|
||||
}
|
||||
|
||||
g.DrawString(leftStr, GS!(36), 0);
|
||||
if (!rightStr.IsEmpty)
|
||||
g.DrawString(rightStr, mWidth - GS!(8), 0, .Right);
|
||||
using (g.PushColor(DarkTheme.COLOR_TEXT))
|
||||
{
|
||||
g.DrawString(leftStr, GS!(36), 0);
|
||||
if (!rightStr.IsEmpty)
|
||||
g.DrawString(rightStr, mWidth - GS!(8), 0, .Right);
|
||||
}
|
||||
}
|
||||
|
||||
if (mMenuItem.mIconImage != null)
|
||||
|
|
|
@ -59,7 +59,7 @@ namespace Beefy.theme.dark
|
|||
public bool mIsEndTab;
|
||||
public bool mIsRightTab;
|
||||
public float mObscuredDir; // <0 = left, >0 = right
|
||||
public uint32 mTextColor = Color.White;
|
||||
public uint32? mTextColor;
|
||||
public float mTabWidthOffset = 30;
|
||||
|
||||
public this(bool isEnd = false)
|
||||
|
@ -130,8 +130,8 @@ namespace Beefy.theme.dark
|
|||
if ((mLabel != null) && (drawWidth > GS!(16)))
|
||||
{
|
||||
//using (g.PushColor(((DarkTabbedView)mParent).mTextColor))
|
||||
using (g.PushColor(mTextColor))
|
||||
{
|
||||
using (g.PushColor(mTextColor ?? DarkTheme.COLOR_TEXT))
|
||||
{
|
||||
float textWidth = g.mFont.GetWidth(mLabel);
|
||||
float useWidth = mWidth - GS!(12)*2;
|
||||
|
||||
|
|
|
@ -186,6 +186,7 @@ namespace Beefy.theme.dark
|
|||
COUNT
|
||||
};
|
||||
|
||||
public static uint32 COLOR_TEXT = 0xFFFFFFFF;
|
||||
public static uint32 COLOR_WINDOW = 0xFF595959;
|
||||
public static uint32 COLOR_BKG = 0xFF262626;
|
||||
public static uint32 COLOR_SELECTED_OUTLINE = 0xFFE6A800;
|
||||
|
@ -209,6 +210,17 @@ namespace Beefy.theme.dark
|
|||
public Image mIconWarning ~ delete _;
|
||||
public Image mIconError ~ delete _;
|
||||
|
||||
public String[3] mUIFileNames = .(new String(), new String(), new String()) ~
|
||||
{
|
||||
for (var val in _)
|
||||
delete val;
|
||||
};
|
||||
|
||||
public this()
|
||||
{
|
||||
sDarkTheme = this;
|
||||
}
|
||||
|
||||
public static DesignToolboxEntry[] GetDesignToolboxEntries()
|
||||
{
|
||||
Get();
|
||||
|
@ -320,22 +332,35 @@ namespace Beefy.theme.dark
|
|||
COLOR_MENU_FOCUSED = Color.FromNative(bits[3]);
|
||||
COLOR_MENU_SELECTED = Color.FromNative(bits[4]);
|
||||
|
||||
int scaleIdx = 0;
|
||||
|
||||
String uiFileName = null;
|
||||
switch (sSrcImgScale)
|
||||
{
|
||||
case 1:
|
||||
scaleIdx = 0;
|
||||
uiFileName = "DarkUI.png";
|
||||
case 2:
|
||||
scaleIdx = 1;
|
||||
uiFileName = "DarkUI_2.png";
|
||||
case 4:
|
||||
scaleIdx = 2;
|
||||
uiFileName = "DarkUI_4.png";
|
||||
default:
|
||||
Runtime.FatalError("Invalid scale");
|
||||
}
|
||||
|
||||
String fileName = scope String()..Append(tempStr, BFApp.sApp.mInstallDir, "images/", uiFileName);
|
||||
if (!mUIFileNames[scaleIdx].IsEmpty)
|
||||
fileName.Set(mUIFileNames[scaleIdx]);
|
||||
|
||||
mIconError = LoadSizedImage("IconError");
|
||||
mIconWarning = LoadSizedImage("IconWarning");
|
||||
mThemeImage = Image.LoadFromFile(scope String()..Append(tempStr, BFApp.sApp.mInstallDir, "images/", uiFileName));
|
||||
mThemeImage = Image.LoadFromFile(fileName);
|
||||
if (mThemeImage == null)
|
||||
{
|
||||
// Fail (just crashes now)
|
||||
}
|
||||
|
||||
for (int32 i = 0; i < (int32)ImageIdx.COUNT; i++)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue