Skip to content

Commit 309f88d

Browse files
committed
big prompt
1 parent 69d9004 commit 309f88d

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

StabilityMatrix.Avalonia/Controls/Inference/PromptCard.axaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
</Style>
3838
</controls:Card.Styles>
3939

40-
<Grid RowDefinitions="*,16,*,16,Auto">
40+
<Grid RowDefinitions="*,16,*,16,Auto"
41+
Name="PART_RootGrid">
4142
<!-- Prompt -->
4243
<Grid ColumnDefinitions="*,Auto" RowDefinitions="Auto,*">
4344
<StackPanel

StabilityMatrix.Avalonia/Controls/Inference/PromptCard.axaml.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using AvaloniaEdit.Utils;
88
using StabilityMatrix.Avalonia.Helpers;
99
using StabilityMatrix.Avalonia.Models;
10+
using StabilityMatrix.Avalonia.ViewModels.Inference;
1011
using StabilityMatrix.Core.Attributes;
1112

1213
namespace StabilityMatrix.Avalonia.Controls;
@@ -19,6 +20,7 @@ protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
1920
{
2021
base.OnApplyTemplate(e);
2122

23+
FixGrids(e);
2224
InitializeEditors(e);
2325
}
2426

@@ -59,4 +61,25 @@ var editor in new[]
5961
}
6062
}
6163
}
64+
65+
private void FixGrids(TemplateAppliedEventArgs e)
66+
{
67+
if (DataContext is not PromptCardViewModel { IsNegativePromptEnabled: false })
68+
{
69+
return;
70+
}
71+
72+
// When negative prompt disabled, rearrange grid
73+
if (e.NameScope.Find<Grid>("PART_RootGrid") is not { } rootGrid)
74+
return;
75+
76+
// Change `*,16,*,16,Auto` to `*,16,Auto` (Remove index 2 and 3)
77+
rootGrid.RowDefinitions.RemoveRange(2, 2);
78+
79+
// Set the last children to row 2
80+
rootGrid.Children[4].SetValue(Grid.RowProperty, 2);
81+
82+
// Remove the negative prompt row and the separator row (index 2 and 3)
83+
rootGrid.Children.RemoveRange(2, 2);
84+
}
6285
}

0 commit comments

Comments
 (0)