Decrease CPU usage of OverflowTextBlock + optimization (#403)
Fixes #402 and #414 Divide by 4 the CPU usage of OverflowTextBlock when buttons are pressed very quickly. Description of the changes: Xaml-side: OverflowTextBlock has some performance issues: double scrollviewer: the listview was in a scrollviewer, while the control already containing one -> it breaks the virtualization of the listview and impacts on UI performance. The listview used a StackPanel, this panel doesn't support virtualization of ListViewItems contrary to ItemsStackPanel No ListView-specific features were used, an ItemsControl is more efficient and lighter. refactor how we manage the visibility of the left/right buttons in OverflowTextBlock, the new version is more reactive and will not display the right arrow when not necessary (see GIF below). remove the ItemContainerSelector ExpressionItemContainerStyle, not really used by OverflowTextBlock remove UI glitches generated by ChangeView when users type fast (control partially hidden and scrolling issues, see the GIF below). only modify the accessibility view when it's necessary ViewModel-side: stop fully refreshing ExpressionTokens in StandardCalculatorViewModel when a new command were sent, instead, use a IObservableVector to only send new tokens to the UI (in average only 1 or 2 UI items are refreshed while the full expression was refreshed before) How changes were validated: Manually
This commit is contained in:
committed by
Daniel Belcher
parent
d21a47d5a1
commit
de65db6197
@@ -1,44 +0,0 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#include "pch.h"
|
||||
#include "ExpressionItemContainerStyle.h"
|
||||
#include "CalcViewModel/Common/DisplayExpressionToken.h"
|
||||
|
||||
using namespace CalculatorApp::Common;
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
namespace Converters
|
||||
{
|
||||
Windows::UI::Xaml::Style^ ExpressionItemContainerStyle::SelectStyleCore(Platform::Object^ item, Windows::UI::Xaml::DependencyObject^ container)
|
||||
{
|
||||
DisplayExpressionToken^ token = dynamic_cast<DisplayExpressionToken^>(item);
|
||||
if (token != nullptr)
|
||||
{
|
||||
Common::TokenType type = token->Type;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case TokenType::Operator:
|
||||
if (token->IsTokenEditable)
|
||||
{
|
||||
return m_editableOperatorStyle;
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_nonEditableOperatorStyle;
|
||||
}
|
||||
case TokenType::Operand:
|
||||
return m_operandStyle;
|
||||
case TokenType::Separator:
|
||||
return m_separatorStyle;
|
||||
default:
|
||||
throw ref new Platform::Exception(E_FAIL, L"Invalid token type");
|
||||
}
|
||||
}
|
||||
|
||||
return m_separatorStyle;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,71 +0,0 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
namespace Converters
|
||||
{
|
||||
[Windows::UI::Xaml::Data::Bindable]
|
||||
public ref class ExpressionItemContainerStyle sealed : public Windows::UI::Xaml::Controls::StyleSelector
|
||||
{
|
||||
public:
|
||||
virtual Windows::UI::Xaml::Style^ SelectStyleCore(Platform::Object^ item, Windows::UI::Xaml::DependencyObject^ container) override;
|
||||
|
||||
property Windows::UI::Xaml::Style^ EditableOperatorStyle
|
||||
{
|
||||
Windows::UI::Xaml::Style^ get()
|
||||
{
|
||||
return m_editableOperatorStyle;
|
||||
}
|
||||
void set(Windows::UI::Xaml::Style^ val)
|
||||
{
|
||||
m_editableOperatorStyle = val;
|
||||
}
|
||||
}
|
||||
|
||||
property Windows::UI::Xaml::Style^ OperandStyle
|
||||
{
|
||||
Windows::UI::Xaml::Style^ get()
|
||||
{
|
||||
return m_operandStyle;
|
||||
}
|
||||
void set(Windows::UI::Xaml::Style^ val)
|
||||
{
|
||||
m_operandStyle = val;
|
||||
}
|
||||
}
|
||||
|
||||
property Windows::UI::Xaml::Style^ SeparatorStyle
|
||||
{
|
||||
Windows::UI::Xaml::Style^ get()
|
||||
{
|
||||
return m_separatorStyle;
|
||||
}
|
||||
void set(Windows::UI::Xaml::Style^ val)
|
||||
{
|
||||
m_separatorStyle = val;
|
||||
}
|
||||
}
|
||||
|
||||
property Windows::UI::Xaml::Style^ NonEditableOperatorStyle
|
||||
{
|
||||
Windows::UI::Xaml::Style^ get()
|
||||
{
|
||||
return m_nonEditableOperatorStyle;
|
||||
}
|
||||
void set(Windows::UI::Xaml::Style^ val)
|
||||
{
|
||||
m_nonEditableOperatorStyle = val;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
Windows::UI::Xaml::Style^ m_editableOperatorStyle;
|
||||
Windows::UI::Xaml::Style^ m_nonEditableOperatorStyle;
|
||||
Windows::UI::Xaml::Style^ m_operandStyle;
|
||||
Windows::UI::Xaml::Style^ m_separatorStyle;
|
||||
};
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user