-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
83 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
namespace Editor; | ||
|
||
/// <summary> | ||
/// Contains extension methods for <see cref="Layout"/>. | ||
/// </summary> | ||
internal static class LayoutExtensions | ||
{ | ||
/// <summary> | ||
/// Adds a child <see cref="Layout"/>. | ||
/// </summary> | ||
/// <param name="parentLayout">The parent <see cref="Layout"/> to add the newly created one to.</param> | ||
/// <param name="layoutMode">The mode that the layout should use.</param> | ||
/// <param name="stretch">The stretch value to pass to QT.</param> | ||
/// <returns>The newly created <see cref="Layout"/>.</returns> | ||
internal static Layout Add( this Layout parentLayout, LayoutMode layoutMode, int stretch = default ) | ||
{ | ||
var childLayout = layoutMode.CreateLayout(); | ||
parentLayout.Add( childLayout, stretch ); | ||
return childLayout; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace Editor; | ||
|
||
/// <summary> | ||
/// Defines a mode for a <see cref="Layout"/> to follow. | ||
/// </summary> | ||
internal enum LayoutMode : byte | ||
{ | ||
TopToBottom, | ||
BottomToTop, | ||
LeftToRight, | ||
RightToLeft | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
|
||
namespace Editor; | ||
|
||
/// <summary> | ||
/// Contains extension methods for <see cref="LayoutMode"/>. | ||
/// </summary> | ||
internal static class LayoutModeExtensions | ||
{ | ||
/// <summary> | ||
/// Creates a new <see cref="Layout"/> based on the mode. | ||
/// </summary> | ||
/// <param name="layoutMode">The mode for the <see cref="Layout"/> to follow.</param> | ||
/// <returns>The newly created <see cref="Layout"/>.</returns> | ||
/// <exception cref="ArgumentException">Thrown when the <see cref="LayoutMode"/> provided is invalid.</exception> | ||
internal static Layout CreateLayout( this LayoutMode layoutMode ) => layoutMode switch | ||
{ | ||
LayoutMode.TopToBottom => Layout.Column(), | ||
LayoutMode.BottomToTop => Layout.Column( true ), | ||
LayoutMode.LeftToRight => Layout.Row(), | ||
LayoutMode.RightToLeft => Layout.Row( true ), | ||
_ => throw new ArgumentException( $"Unrecognized {nameof( LayoutMode )} \"{layoutMode}\"", nameof( layoutMode ) ) | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
namespace Editor; | ||
|
||
/// <summary> | ||
/// Contains extension methods for <see cref="Widget"/>. | ||
/// </summary> | ||
internal static class WidgetExtensions | ||
{ | ||
/// <summary> | ||
/// Sets the <see cref="Layout"/> of the <see cref="Widget"/>. | ||
/// </summary> | ||
/// <param name="widget">The <see cref="Widget"/> whose <see cref="Layout"/> to set.</param> | ||
/// <param name="layoutMode">The mode to use on the <see cref="Layout"/>.</param> | ||
/// <returns>The newly created <see cref="Layout"/>.</returns> | ||
internal static Layout SetLayout( this Widget widget, LayoutMode layoutMode ) | ||
{ | ||
var layout = layoutMode.CreateLayout(); | ||
widget.Layout = layout; | ||
return layout; | ||
} | ||
} |