mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-14 22:34:09 +02:00
Adding WelcomePanel
This commit is contained in:
parent
5f84a7e4e3
commit
fa0311f849
5 changed files with 152 additions and 2 deletions
|
@ -133,7 +133,6 @@ namespace IDE
|
||||||
public PropertiesPanel mPropertiesPanel;
|
public PropertiesPanel mPropertiesPanel;
|
||||||
public Font mTinyCodeFont ~ delete _;
|
public Font mTinyCodeFont ~ delete _;
|
||||||
public Font mCodeFont ~ delete _;
|
public Font mCodeFont ~ delete _;
|
||||||
public Font mLargeFont ~ delete _;
|
|
||||||
protected bool mInitialized;
|
protected bool mInitialized;
|
||||||
public bool mConfig_NoIR;
|
public bool mConfig_NoIR;
|
||||||
public bool mFailed;
|
public bool mFailed;
|
||||||
|
@ -1440,10 +1439,16 @@ namespace IDE
|
||||||
continue;
|
continue;
|
||||||
if (tabWidget.mContent is DisassemblyPanel)
|
if (tabWidget.mContent is DisassemblyPanel)
|
||||||
continue;
|
continue;
|
||||||
|
if (tabWidget.mContent is WelcomePanel)
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
using (data.CreateObject())
|
using (data.CreateObject())
|
||||||
{
|
{
|
||||||
|
var panel = tabWidget.mContent as Panel;
|
||||||
|
if (!panel.WantsSerialization)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (tabWidget.mIsActive)
|
if (tabWidget.mIsActive)
|
||||||
data.Add("Active", true);
|
data.Add("Active", true);
|
||||||
|
|
||||||
|
@ -1454,7 +1459,7 @@ namespace IDE
|
||||||
{
|
{
|
||||||
watchPanel.Serialize(data, serializeDocs);
|
watchPanel.Serialize(data, serializeDocs);
|
||||||
}
|
}
|
||||||
else if (var panel = tabWidget.mContent as Panel)
|
else if (panel != null)
|
||||||
{
|
{
|
||||||
panel.Serialize(data);
|
panel.Serialize(data);
|
||||||
}
|
}
|
||||||
|
@ -9982,6 +9987,14 @@ namespace IDE
|
||||||
ShowPanel(mOutputPanel, false);
|
ShowPanel(mOutputPanel, false);
|
||||||
UpdateRecentFileMenuItems();
|
UpdateRecentFileMenuItems();
|
||||||
ShowStartupFile();
|
ShowStartupFile();
|
||||||
|
|
||||||
|
if (mIsFirstRun)
|
||||||
|
{
|
||||||
|
WelcomePanel welcomePanel = new .();
|
||||||
|
TabbedView tabbedView = GetDefaultDocumentTabbedView();
|
||||||
|
let tabButton = SetupTab(tabbedView, "Welcome", 0, welcomePanel, true);
|
||||||
|
tabButton.Activate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -216,6 +216,12 @@ namespace IDE.ui
|
||||||
if ((mWidgetWindow == null) || (mWidgetWindow.mRootWidget != this))
|
if ((mWidgetWindow == null) || (mWidgetWindow.mRootWidget != this))
|
||||||
return; // We're being replaced as root
|
return; // We're being replaced as root
|
||||||
|
|
||||||
|
if (let widgetWindow = window as WidgetWindow)
|
||||||
|
{
|
||||||
|
if (widgetWindow.mRootWidget is DarkTooltipContainer)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ((!mIgnoreMove) && (mWidgetWindow != null) && (!mWidgetWindow.mHasClosed))
|
if ((!mIgnoreMove) && (mWidgetWindow != null) && (!mWidgetWindow.mHasClosed))
|
||||||
mAutoComplete.Close();
|
mAutoComplete.Close();
|
||||||
}
|
}
|
||||||
|
@ -2016,6 +2022,9 @@ namespace IDE.ui
|
||||||
|
|
||||||
if (!mClosed)
|
if (!mClosed)
|
||||||
{
|
{
|
||||||
|
if ((DarkTooltipManager.sTooltip != null) && (!DarkTooltipManager.sTooltip.mRequireMouseInside))
|
||||||
|
DarkTooltipManager.CloseTooltip();
|
||||||
|
|
||||||
if (IsInPanel())
|
if (IsInPanel())
|
||||||
{
|
{
|
||||||
gApp.mAutoCompletePanel.Unbind(this);
|
gApp.mAutoCompletePanel.Unbind(this);
|
||||||
|
|
|
@ -132,6 +132,7 @@ namespace IDE.ui
|
||||||
// If we don't yet have a workspace then create one now...
|
// If we don't yet have a workspace then create one now...
|
||||||
if (!app.mWorkspace.IsInitialized)
|
if (!app.mWorkspace.IsInitialized)
|
||||||
{
|
{
|
||||||
|
DeleteAndNullify!(app.mWorkspace.mDir);
|
||||||
app.mWorkspace.mDir = new String(projDirectory);
|
app.mWorkspace.mDir = new String(projDirectory);
|
||||||
app.mWorkspace.mName = new String(projName);
|
app.mWorkspace.mName = new String(projName);
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,14 @@ namespace IDE.ui
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual bool WantsSerialization
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override void GotFocus()
|
public override void GotFocus()
|
||||||
{
|
{
|
||||||
base.GotFocus();
|
base.GotFocus();
|
||||||
|
|
119
IDE/src/ui/WelcomePanel.bf
Normal file
119
IDE/src/ui/WelcomePanel.bf
Normal file
|
@ -0,0 +1,119 @@
|
||||||
|
using Beefy.gfx;
|
||||||
|
using Beefy.theme.dark;
|
||||||
|
using System;
|
||||||
|
using Beefy.widgets;
|
||||||
|
|
||||||
|
namespace IDE.ui
|
||||||
|
{
|
||||||
|
class WelcomePanel : Panel
|
||||||
|
{
|
||||||
|
class SampleButton : Widget
|
||||||
|
{
|
||||||
|
public Image mImage;
|
||||||
|
public String mLabel ~ delete _;
|
||||||
|
public Font mFont;
|
||||||
|
public String mPath ~ delete _;
|
||||||
|
|
||||||
|
public override void Draw(Graphics g)
|
||||||
|
{
|
||||||
|
using (g.PushColor(mMouseOver ? 0xFFFFFFFF : 0x80FFFFFF))
|
||||||
|
using (g.PushScale(DarkTheme.sScale, DarkTheme.sScale))
|
||||||
|
g.Draw(mImage);
|
||||||
|
|
||||||
|
g.SetFont(mFont);
|
||||||
|
g.DrawString(mLabel, 0, GS!(240), .Centered, mWidth);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void MouseEnter()
|
||||||
|
{
|
||||||
|
base.MouseEnter();
|
||||||
|
gApp.SetCursor(.Hand);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void MouseLeave()
|
||||||
|
{
|
||||||
|
base.MouseLeave();
|
||||||
|
gApp.SetCursor(.Pointer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void MouseClicked(float x, float y, int32 btn)
|
||||||
|
{
|
||||||
|
base.MouseClicked(x, y, btn);
|
||||||
|
|
||||||
|
gApp.[Friend]mDeferredOpen = .Workspace;
|
||||||
|
String.NewOrSet!(gApp.[Friend]mDeferredOpenFileName, mPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Font mLargeFont ~ delete _;
|
||||||
|
Font mMedFont ~ delete _;
|
||||||
|
Image mSampleImg0 ~ delete _;
|
||||||
|
Image mSampleImg1 ~ delete _;
|
||||||
|
SampleButton mSampleBtn0;
|
||||||
|
SampleButton mSampleBtn1;
|
||||||
|
|
||||||
|
public override bool WantsSerialization
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public this()
|
||||||
|
{
|
||||||
|
mSampleImg0 = Image.LoadFromFile(scope String()..AppendF(@"{}\images\welcome_sample0.png", gApp.mInstallDir));
|
||||||
|
mSampleImg1 = Image.LoadFromFile(scope String()..AppendF(@"{}\images\welcome_sample1.png", gApp.mInstallDir));
|
||||||
|
|
||||||
|
mSampleBtn0 = new .();
|
||||||
|
mSampleBtn0.mPath = new String()..AppendF(@"\beef_website\Samples\SpaceGame\BeefSpace.toml");
|
||||||
|
mSampleBtn0.mLabel = new String("Space Game");
|
||||||
|
mSampleBtn0.mImage = mSampleImg0;
|
||||||
|
AddWidget(mSampleBtn0);
|
||||||
|
|
||||||
|
mSampleBtn1 = new .();
|
||||||
|
mSampleBtn1.mPath = new String()..AppendF(@"\beef_website\Samples\HelloWorld\BeefSpace.toml");
|
||||||
|
mSampleBtn1.mLabel = new String("Hello World");
|
||||||
|
mSampleBtn1.mImage = mSampleImg1;
|
||||||
|
AddWidget(mSampleBtn1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void RehupScale(float oldScale, float newScale)
|
||||||
|
{
|
||||||
|
base.RehupScale(oldScale, newScale);
|
||||||
|
|
||||||
|
DeleteAndNullify!(mLargeFont);
|
||||||
|
DeleteAndNullify!(mMedFont);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void DrawAll(Graphics g)
|
||||||
|
{
|
||||||
|
if (mLargeFont == null)
|
||||||
|
mLargeFont = new Font()..Load("Segoe UI Bold", 60.0f * DarkTheme.sScale); //8.8
|
||||||
|
if (mMedFont == null)
|
||||||
|
mMedFont = new Font()..Load("Segoe UI Bold", 24.0f * DarkTheme.sScale); //8.8
|
||||||
|
mSampleBtn0.mFont = mMedFont;
|
||||||
|
mSampleBtn1.mFont = mMedFont;
|
||||||
|
|
||||||
|
base.DrawAll(g);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Draw(Graphics g)
|
||||||
|
{
|
||||||
|
g.SetFont(mLargeFont);
|
||||||
|
using (g.PushColor(0xFFE0E0FF))
|
||||||
|
g.DrawString("Welcome to Beef", 0, GS!(48), .Centered, mWidth);
|
||||||
|
|
||||||
|
g.SetFont(mMedFont);
|
||||||
|
g.DrawString("Click on a sample projects below\nor\nCreate a project from the File menu", GS!(32), GS!(148), .Centered, mWidth - GS!(64));
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
mSampleBtn0.Resize(mWidth / 2 - GS!(32 + 320), GS!(300), GS!(320), GS!(240));
|
||||||
|
mSampleBtn1.Resize(mWidth / 2 + GS!(32), GS!(300), GS!(320), GS!(240));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue