Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Projects Window resizing #196

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 44 additions & 24 deletions Prowl.Editor/Editor/ProjectsWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public class ProjectsWindow : EditorWindow
private FileDialog _dialog;
private FileDialogContext _dialogContext;


protected override bool Center { get; } = true;
protected override double Width { get; } = 1024;
protected override double Height { get; } = 640;
Expand All @@ -37,6 +36,8 @@ public class ProjectsWindow : EditorWindow
protected override bool LockSize => true;
protected override double Padding => 0;

static readonly Color GrayAlpha = new Color(0, 0, 0, 0.5f);

public ProjectsWindow()
{
Title = FontAwesome6.Book + " Project Window";
Expand All @@ -52,31 +53,34 @@ protected override void Draw()
if (Project.HasProject)
isOpened = false;

using (gui.Node("Content").ExpandWidth().Layout(LayoutType.Row).ScaleChildren().Enter())
// Fill parent (Window in this case).
using (gui.CurrentNode.Left(0).Top(0).ExpandWidth().ExpandHeight().Enter())
{
using (gui.Node("Side").ExpandHeight().MaxWidth(150).Layout(LayoutType.Column).Spacing(5).Enter())
using (gui.Node("Content").ExpandWidth().Layout(LayoutType.Row).ScaleChildren().Enter())
{
using (gui.Node("Name").Scale(150, 50).Enter())
using (gui.Node("Side").ExpandHeight().MaxWidth(150).Layout(LayoutType.Column).Spacing(5).Enter())
{
Rect rect = gui.CurrentNode.LayoutData.Rect;
gui.Draw2D.DrawText(Font.DefaultFont, "Prowl", 40, rect, Color.white);
using (gui.Node("Name").Scale(150, 50).Enter())
{
Rect rect = gui.CurrentNode.LayoutData.Rect;
gui.Draw2D.DrawText(Font.DefaultFont, "Prowl", 40, rect, Color.white);
}

DrawSidePanel();
}

DrawSidePanel();
}
gui.PushID((ulong)_currentTab);

gui.PushID((ulong)_currentTab);
using (gui.Node("TabContent").ExpandHeight().Enter())
{
_tabs[_currentTab].Item2.Invoke();
}

using (gui.Node("TabContent").ExpandHeight().Enter())
{
_tabs[_currentTab].Item2.Invoke();
gui.PopID();
}

gui.PopID();
}
}


private void DrawProjectsTab()
{
Rect rect = gui.CurrentNode.LayoutData.Rect;
Expand Down Expand Up @@ -197,8 +201,9 @@ private void DrawProjectsTab()
}
}

using (gui.Node("Footer").TopLeft(Offset.Percentage(1f, -162), Offset.Percentage(1f, -60)).Scale(162, 60).Enter())
using (gui.Node("OpenButton").TopLeft(Offset.Percentage(1f, -162), Offset.Percentage(1f, -60)).Scale(162, 60).Enter())
{
Rect openButtonRect = gui.CurrentNode.LayoutData.Rect;
Color col = Color.white * 0.4f;

bool isSelectable = _createTabOpen ? !string.IsNullOrEmpty(_createName) && Directory.Exists(ProjectCache.Instance.SavedProjectsFolder) && !Path.Exists(_createName) :
Expand All @@ -216,18 +221,34 @@ private void DrawProjectsTab()
ProjectCache.Instance.AddProject(project);
_createTabOpen = false;
}
else if (Project.Open(SelectedProject))
else if (SelectedProject != null)
{
isOpened = false;
// Display load info (and possibly load bar). Placed in empty space of footer

// Opening project info
// Text pos + offset/padding
Vector2 openInfoTextPos = footer.Position + new Vector2(8f, 8f);
gui.Draw2D.DrawText($"Opening '{SelectedProject.Name}'...", openInfoTextPos);
// Add more information about progress here (even console output)

// Change 'open/create' button text
text = "Opening...";

// Cover controls (fill EditorWindow)
gui.Draw2D.DrawRectFilled(this.Rect, GrayAlpha);

bool projectOpened = Project.Open(SelectedProject);
if (projectOpened)
isOpened = false;
}
}

col = gui.IsNodeActive() ? EditorStylePrefs.Instance.Highlighted :
gui.IsNodeHovered() ? EditorStylePrefs.Instance.Highlighted * 0.8f : EditorStylePrefs.Instance.Highlighted;
}

gui.Draw2D.DrawRectFilled(gui.CurrentNode.LayoutData.Rect, col, (float)EditorStylePrefs.Instance.WindowRoundness, 4);
gui.Draw2D.DrawText(text, gui.CurrentNode.LayoutData.Rect);
col = gui.IsNodeActive() ? EditorStylePrefs.Instance.Highlighted :
gui.IsNodeHovered() ? EditorStylePrefs.Instance.Highlighted * 0.8f : EditorStylePrefs.Instance.Highlighted;

gui.Draw2D.DrawRectFilled(openButtonRect, col, (float)EditorStylePrefs.Instance.WindowRoundness, 4);
gui.Draw2D.DrawText(text, openButtonRect);
}
}

Expand Down Expand Up @@ -491,7 +512,6 @@ private void DrawSidePanel()
}
}


private static string GetFormattedLastModifiedTime(DateTime lastModified)
{
TimeSpan timeSinceLastModified = DateTime.Now - lastModified;
Expand Down
Loading