mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-29 21:05:59 +02:00
Added buttons to BookmarksPanel
This commit is contained in:
parent
bd048e2fe6
commit
09c31d5db1
8 changed files with 196 additions and 45 deletions
|
@ -3,19 +3,107 @@ using System.Collections;
|
|||
using System.Text;
|
||||
using Beefy.widgets;
|
||||
using Beefy.gfx;
|
||||
using Beefy.geom;
|
||||
|
||||
namespace Beefy.theme.dark
|
||||
{
|
||||
public struct Padding
|
||||
{
|
||||
public float Left;
|
||||
public float Right;
|
||||
public float Top;
|
||||
public float Bottom;
|
||||
|
||||
public this(float padding)
|
||||
{
|
||||
Left = padding;
|
||||
Right = padding;
|
||||
Top = padding;
|
||||
Bottom = padding;
|
||||
}
|
||||
|
||||
public this(float leftRight, float topBottom)
|
||||
{
|
||||
Left = leftRight;
|
||||
Right = leftRight;
|
||||
Top = topBottom;
|
||||
Bottom = topBottom;
|
||||
}
|
||||
|
||||
public this(float left, float right, float top, float bottom)
|
||||
{
|
||||
Left = left;
|
||||
Right = right;
|
||||
Top = top;
|
||||
Bottom = bottom;
|
||||
}
|
||||
}
|
||||
|
||||
public class DarkIconButton : ButtonWidget
|
||||
{
|
||||
public Image mIcon;
|
||||
public float mIconOfsX;
|
||||
public float mIconOfsY;
|
||||
private Image mIcon;
|
||||
|
||||
private Padding mPadding = .(4);
|
||||
|
||||
public Image Icon
|
||||
{
|
||||
get => mIcon;
|
||||
set
|
||||
{
|
||||
if (mIcon == value)
|
||||
return;
|
||||
|
||||
mIcon = value;
|
||||
|
||||
if (mIcon != null)
|
||||
UpdateSize();
|
||||
}
|
||||
}
|
||||
|
||||
public Padding Padding
|
||||
{
|
||||
get => mPadding;
|
||||
set
|
||||
{
|
||||
if (mPadding == value)
|
||||
return;
|
||||
|
||||
mPadding = value;
|
||||
|
||||
UpdateSize();
|
||||
}
|
||||
}
|
||||
|
||||
/// Calculates the size of the button.
|
||||
private void UpdateSize()
|
||||
{
|
||||
float width = mPadding.Left + mIcon.mWidth + mPadding.Right;
|
||||
float height = mPadding.Top + mIcon.mHeight + mPadding.Bottom;
|
||||
|
||||
Resize(0, 0, width, height);
|
||||
}
|
||||
|
||||
public override void Draw(Graphics g)
|
||||
{
|
||||
base.Draw(g);
|
||||
g.Draw(mIcon, mIconOfsX, mIconOfsY);
|
||||
|
||||
bool drawDown = ((mMouseDown && mMouseOver) || (mMouseFlags.HasFlag(MouseFlag.Kbd)));
|
||||
|
||||
Image texture =
|
||||
mDisabled ? DarkTheme.sDarkTheme.GetImage(.BtnUp) :
|
||||
drawDown ? DarkTheme.sDarkTheme.GetImage(.BtnDown) :
|
||||
mMouseOver ? DarkTheme.sDarkTheme.GetImage(.BtnOver) :
|
||||
DarkTheme.sDarkTheme.GetImage(.BtnUp);
|
||||
|
||||
g.DrawBox(texture, 0, 0, mWidth, mHeight);
|
||||
|
||||
if ((mHasFocus) && (!mDisabled))
|
||||
{
|
||||
using (g.PushColor(DarkTheme.COLOR_SELECTED_OUTLINE))
|
||||
g.DrawBox(DarkTheme.sDarkTheme.GetImage(.Outline), 0, 0, mWidth, mHeight);
|
||||
}
|
||||
|
||||
g.Draw(mIcon, mPadding.Left, mPadding.Top);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -185,6 +185,11 @@ namespace Beefy.theme.dark
|
|||
CollapseOpened,
|
||||
|
||||
IconBookmarkDisabled,
|
||||
NewBookmarkFolder,
|
||||
PrevBookmark,
|
||||
NextBookmark,
|
||||
PrevBookmarkInFolder,
|
||||
NextBookmarkInFolder,
|
||||
|
||||
COUNT
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue