Skip to content

Commit

Permalink
feat(calendar): Initial import of the CalendarView
Browse files Browse the repository at this point in the history
  • Loading branch information
dr1rrb committed Jun 1, 2021
1 parent 1835b12 commit 392e356
Show file tree
Hide file tree
Showing 116 changed files with 16,087 additions and 7,088 deletions.
7 changes: 7 additions & 0 deletions src/SamplesApp/UITests.Shared/UITests.Shared.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\CalendarView\CalendarView_Basics.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\Canvas\Canvas_With_Outer_Clip.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down Expand Up @@ -4791,6 +4795,9 @@
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\Button\Buttons_Native.xaml.cs">
<DependentUpon>Buttons_Native.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\CalendarView\CalendarView_Basics.xaml.cs">
<DependentUpon>CalendarView_Basics.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\Canvas\Canvas_With_Outer_Clip.xaml.cs">
<DependentUpon>Canvas_With_Outer_Clip.xaml</DependentUpon>
</Compile>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Page
x:Class="UITests.Windows_UI_Xaml_Controls.CalendarViewTests.CalendarView_Basics"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UITests.Windows_UI_Xaml_Controls.CalendarViewTests"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Grid>
<CalendarView />
</Grid>
</Page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Uno.UI.Samples.Controls;

// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238

namespace UITests.Windows_UI_Xaml_Controls.CalendarViewTests
{
[Sample]
public sealed partial class CalendarView_Basics : Page
{
public CalendarView_Basics()
{
this.InitializeComponent();
}
}
}
64 changes: 64 additions & 0 deletions src/Uno.UI/DirectUI/BudgetManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.



namespace DirectUI
{
partial class BudgetManager
{
private void Initialize()
{
//bool success = false;

//success = QueryPerformanceFrequency(&m_freq);

//return;
}

private void StoreFrameTime(bool isBeginOfTick)
{
//bool success = false;

//if (isBeginOfTick)
//{
// m_startFrameTime = success = QueryPerformanceCounter();
//}
//else
//{
// m_endFrameTime = success = QueryPerformanceCounter();
//}

//// does all ARM hardware support this
//global::System.Diagnostics.Debug.Assert(success);
}


private void GetElapsedMilliSecondsSinceLastUITickImpl(out int returnValue)
{
//long lTimeCurrent = default;
//bool success = false;

//// todo: switch between end and start time based on whether we trust the tick to be accurate

//success = QueryPerformanceCounter(lTimeCurrent);

//if (success)
//{
// double elapsedSeconds = (double)(lTimeCurrent.QuadPart - m_endFrameTime.QuadPart) / (double)(m_freq.QuadPart);

// returnValue = (int)(elapsedSeconds1000);
//}
//else
//{
// // hardware that doesn't understand QPC?? Very unlikely, but in this case, let's not crash
// // and just return that no time has elapsed. This will trigger people relying on budget to see that they
// // have a lot of budget and atleast not have them encounter a situation where they do not get to perform
// // certain work.
// returnValue = 0;
//}

returnValue = default;
}
}
}
22 changes: 22 additions & 0 deletions src/Uno.UI/DirectUI/BudgetManager.h.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

// Abstract:
// Represents budgetmanager to keep the uitick times

#pragma once


namespace DirectUI
{
internal partial class BudgetManager
{
// The default elapsed time before deferring
private const int BUDGET_MANAGER_DEFAULT_LIMIT = 40;

long m_freq;
long m_startFrameTime;
long m_endFrameTime;
}
}

13 changes: 13 additions & 0 deletions src/Uno.UI/DirectUI/BudgetManager.uno.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Linq;

namespace DirectUI
{
partial class BudgetManager
{
public int GetElapsedMilliSecondsSinceLastUITick()
{
throw new NotImplementedException();
}
}
}
14 changes: 14 additions & 0 deletions src/Uno.UI/DirectUI/CalendarConstants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Linq;

namespace DirectUI
{
internal class CalendarConstants
{
internal const long s_ticksPerDay = 864000000000L; // 24 hours, the regular days
internal const long s_ticksPerHour = 36000000000L; // 1 hour for day light saving
internal const long s_maxTicksPerDay = s_ticksPerDay + s_ticksPerHour;
internal const long s_maxTicksPerMonth = 31 * s_ticksPerDay + s_ticksPerHour;
internal const long s_maxTicksPerYear = 366 * s_ticksPerDay + s_ticksPerHour;
}
}
17 changes: 17 additions & 0 deletions src/Uno.UI/DirectUI/DMManipulationState.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace DirectUI
{
internal enum DMManipulationState
{
DMManipulationStarting = 1,
DMManipulationStarted = 2,
DMManipulationDelta = 3,
DMManipulationLastDelta = 4,
DMManipulationCompleted = 5,
ConstantVelocityScrollStarted = 6,
ConstantVelocityScrollStopped = 7
}
}
70 changes: 70 additions & 0 deletions src/Uno.UI/DirectUI/DXamlCore.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using System.Text;
using Windows.UI.Core;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace DirectUI
{
internal class DXamlCore
{
private static DXamlCore _current;
private ElementSoundPlayerService _elementSoundPlayerServiceNoRef;
private BuildTreeService _buildTreeService;
private BudgetManager _budgetManager;

public static DXamlCore GetCurrent()
=> _current ?? new DXamlCore();

public static DXamlCore GetCurrentNoCreate()
=> _current ?? new DXamlCore();

public string GetLocalizedResourceString(string key)
=> key;

public ElementSoundPlayerService GetElementSoundPlayerServiceNoRef()
=> _elementSoundPlayerServiceNoRef ??= new ElementSoundPlayerService();

public BuildTreeService GetBuildTreeService()
=> _buildTreeService ??= new BuildTreeService();

public BudgetManager GetBudgetManager()
=> _budgetManager ??= new BudgetManager();
}

internal class BuildTreeService
{
public void RegisterWork(ITreeBuilder treeBuilder)
{
treeBuilder.IsRegisteredForCallbacks = true;
CoreDispatcher.Main.RunAsync(CoreDispatcherPriority.High, () =>
{
if (treeBuilder.IsBuildTreeSuspended)
{
RegisterWork(treeBuilder);
return;
}
var workerHasWorkLeft = treeBuilder.BuildTree();
if (workerHasWorkLeft)
{
var workerReRegistered = treeBuilder.IsRegisteredForCallbacks;
if (!workerReRegistered)
{
RegisterWork(treeBuilder);
}
}
});
}
}

internal interface ITreeBuilder
{
public bool IsBuildTreeSuspended { get; }

public bool IsRegisteredForCallbacks { get; set; }

public bool BuildTree();
}
}
Loading

0 comments on commit 392e356

Please sign in to comment.