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

Make Grid row/column definitions styleable #4397

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
ea9a272
make row/col definitions styleable
jmacato Jul 29, 2020
ba3cc0f
make the magic happen
jmacato Jul 29, 2020
a7f5cd5
add null check
jmacato Jul 29, 2020
ee3e5ce
nit fixes
jmacato Jul 29, 2020
0a3c39c
whatever happened there
jmacato Jul 29, 2020
f8df56f
rename
jmacato Jul 29, 2020
a7524ec
Merge branch 'master' into styleable-grid-rowcoldefs
jmacato Jul 29, 2020
db6d99c
nit
jmacato Jul 29, 2020
c0a0469
simplify
jmacato Jul 29, 2020
af197fa
handle non-matching row/col changes
jmacato Jul 29, 2020
d68323c
handle row/col change in definition count
jmacato Jul 29, 2020
7ea79cc
Fix test
jmacato Jul 29, 2020
6eaea94
nits
jmacato Jul 29, 2020
047dea3
Merge branch 'master' into styleable-grid-rowcoldefs
jmacato Jul 30, 2020
50f27f7
Merge branch 'master' into styleable-grid-rowcoldefs
jmacato Aug 6, 2020
5753ff5
add unit test
jmacato Aug 6, 2020
9d14e0b
ugly fix
jmacato Aug 7, 2020
4af4000
revert
jmacato Aug 7, 2020
c144f5f
add more test
jmacato Aug 7, 2020
9bc1ee0
almost passed the tests
jmacato Aug 7, 2020
69d7e88
make stuff work finally gof
jmacato Aug 8, 2020
a346964
make the damn Grid work for once
jmacato Aug 14, 2020
cfd6b1f
Merge branch 'master' into styleable-grid-rowcoldefs
jmacato Aug 14, 2020
5a017af
fix stuff
jmacato Aug 14, 2020
940a691
add checks
jmacato Aug 14, 2020
b262926
remove commented out code
jmacato Aug 14, 2020
949349b
cleanup and move fields up
jmacato Aug 14, 2020
0a89e32
test for ci
jmacato Aug 14, 2020
703e7ef
temporarily remove tests for ci
jmacato Aug 14, 2020
f7bdee3
remove flags
jmacato Aug 14, 2020
67b4805
Merge branch 'master' into styleable-grid-rowcoldefs
jmacato Nov 24, 2020
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
8 changes: 1 addition & 7 deletions samples/ControlCatalog/Pages/SplitViewPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,7 @@
CompactPaneLength="{Binding Value, ElementName=CompactPaneLengthSlider}"
DisplayMode="{Binding CurrentDisplayMode}">
<SplitView.Pane>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid RowDefinitions="Auto,Auto,*,Auto">
<TextBlock Text="PANE CONTENT" FontWeight="Bold" Name="PaneHeader" Margin="5,12,0,0" />
<ComboBox Width="150" Grid.Row="1">
<ComboBoxItem Content="Item1"/>
Expand Down
8 changes: 8 additions & 0 deletions src/Avalonia.Controls/ColumnDefinitions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,13 @@ public override string ToString()
/// <param name="s">The column definitions string.</param>
/// <returns>The <see cref="ColumnDefinitions"/>.</returns>
public static ColumnDefinitions Parse(string s) => new ColumnDefinitions(s);

public override void UpdateParentGrid()
{
if (Parent is null) return;
Parent.ColIsEmpty = this.Count == 0;
Parent.RowOrColumnDefChanged = true;
Parent.Invalidate();
}
}
}
6 changes: 5 additions & 1 deletion src/Avalonia.Controls/DateTimePickers/DatePicker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,11 @@ private void SetGrid()
};

columns.Sort((x, y) => x.Item2 - y.Item2);
_container.ColumnDefinitions.Clear();

if (_container.ColumnDefinitions is null)
_container.ColumnDefinitions = new ColumnDefinitions();
else
_container.ColumnDefinitions.Clear();

var columnIndex = 0;

Expand Down
28 changes: 16 additions & 12 deletions src/Avalonia.Controls/DateTimePickers/DatePickerPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,63 +18,63 @@ public class DatePickerPresenter : PickerPresenterBase
/// Defines the <see cref="Date"/> Property
/// </summary>
public static readonly DirectProperty<DatePickerPresenter, DateTimeOffset> DateProperty =
AvaloniaProperty.RegisterDirect<DatePickerPresenter, DateTimeOffset>(nameof(Date),
AvaloniaProperty.RegisterDirect<DatePickerPresenter, DateTimeOffset>(nameof(Date),
x => x.Date, (x, v) => x.Date = v);

/// <summary>
/// Defines the <see cref="DayFormat"/> Property
/// </summary>
public static readonly DirectProperty<DatePickerPresenter, string> DayFormatProperty =
DatePicker.DayFormatProperty.AddOwner<DatePickerPresenter>(x =>
DatePicker.DayFormatProperty.AddOwner<DatePickerPresenter>(x =>
x.DayFormat, (x, v) => x.DayFormat = v);

/// <summary>
/// Defines the <see cref="DayVisible"/> Property
/// </summary>
public static readonly DirectProperty<DatePickerPresenter, bool> DayVisibleProperty =
DatePicker.DayVisibleProperty.AddOwner<DatePickerPresenter>(x =>
DatePicker.DayVisibleProperty.AddOwner<DatePickerPresenter>(x =>
x.DayVisible, (x, v) => x.DayVisible = v);

/// <summary>
/// Defines the <see cref="MaxYear"/> Property
/// </summary>
public static readonly DirectProperty<DatePickerPresenter, DateTimeOffset> MaxYearProperty =
DatePicker.MaxYearProperty.AddOwner<DatePickerPresenter>(x =>
DatePicker.MaxYearProperty.AddOwner<DatePickerPresenter>(x =>
x.MaxYear, (x, v) => x.MaxYear = v);

/// <summary>
/// Defines the <see cref="MinYear"/> Property
/// </summary>
public static readonly DirectProperty<DatePickerPresenter, DateTimeOffset> MinYearProperty =
DatePicker.MinYearProperty.AddOwner<DatePickerPresenter>(x =>
DatePicker.MinYearProperty.AddOwner<DatePickerPresenter>(x =>
x.MinYear, (x, v) => x.MinYear = v);

/// <summary>
/// Defines the <see cref="MonthFormat"/> Property
/// </summary>
public static readonly DirectProperty<DatePickerPresenter, string> MonthFormatProperty =
DatePicker.MonthFormatProperty.AddOwner<DatePickerPresenter>(x =>
DatePicker.MonthFormatProperty.AddOwner<DatePickerPresenter>(x =>
x.MonthFormat, (x, v) => x.MonthFormat = v);

/// <summary>
/// Defines the <see cref="MonthVisible"/> Property
/// </summary>
public static readonly DirectProperty<DatePickerPresenter, bool> MonthVisibleProperty =
DatePicker.MonthVisibleProperty.AddOwner<DatePickerPresenter>(x =>
DatePicker.MonthVisibleProperty.AddOwner<DatePickerPresenter>(x =>
x.MonthVisible, (x, v) => x.MonthVisible = v);

/// <summary>
/// Defines the <see cref="YearFormat"/> Property
/// </summary>
public static readonly DirectProperty<DatePickerPresenter, string> YearFormatProperty =
DatePicker.YearFormatProperty.AddOwner<DatePickerPresenter>(x =>
DatePicker.YearFormatProperty.AddOwner<DatePickerPresenter>(x =>
x.YearFormat, (x, v) => x.YearFormat = v);

/// <summary>
/// Defines the <see cref="YearVisible"/> Property
/// </summary>
public static readonly DirectProperty<DatePickerPresenter, bool> YearVisibleProperty =
DatePicker.YearVisibleProperty.AddOwner<DatePickerPresenter>(x =>
DatePicker.YearVisibleProperty.AddOwner<DatePickerPresenter>(x =>
x.YearVisible, (x, v) => x.YearVisible = v);

// Template Items
Expand Down Expand Up @@ -360,13 +360,13 @@ private void InitPicker()
_monthSelector.SelectedValue = dt.Month;
_monthSelector.FormatDate = dt.Date;
}

if (YearVisible)
{
_yearSelector.SelectedValue = dt.Year;
_yearSelector.FormatDate = dt.Date;
}

_suppressUpdateSelection = false;

SetInitialFocus();
Expand All @@ -383,7 +383,11 @@ private void SetGrid()
};

columns.Sort((x, y) => x.Item2 - y.Item2);
_pickerContainer.ColumnDefinitions.Clear();

if (_pickerContainer.ColumnDefinitions is null)
_pickerContainer.ColumnDefinitions = new ColumnDefinitions();
else
_pickerContainer.ColumnDefinitions.Clear();

var columnIndex = 0;

Expand Down
10 changes: 7 additions & 3 deletions src/Avalonia.Controls/DefinitionList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public DefinitionList()
CollectionChanged += OnCollectionChanged;
}

internal bool IsDirty = true;
private Grid _parent;

internal Grid Parent
Expand All @@ -35,6 +34,8 @@ private void SetParent(Grid value)

internal void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
UpdateParentGrid();

foreach (var nI in this.Select((d, i) => (d, i)))
nI.d._parentIndex = nI.i;

Expand All @@ -49,9 +50,12 @@ internal void OnCollectionChanged(object sender, NotifyCollectionChangedEventArg
?? Enumerable.Empty<DefinitionBase>())
{
oD.OnExitParentTree();
}
}
}

IsDirty = true;

public virtual void UpdateParentGrid()
{
}
}
}
Loading