Skip to content

Commit

Permalink
Add + button and fix tab column sizing (#902)
Browse files Browse the repository at this point in the history
* Added + button, column sizing fixes, and theme color updates.
  • Loading branch information
teaP authored Jun 21, 2019
1 parent 064f559 commit 508db68
Show file tree
Hide file tree
Showing 14 changed files with 433 additions and 104 deletions.
3 changes: 3 additions & 0 deletions build/Localization/Settings/LocConfig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,8 @@
<File
location="TeachingTip"
path="%LocRoot%\..\..\dev\TeachingTip\Strings\en-us\Resources.resw"/>
<File
location="TabView"
path="%LocRoot%\..\..\dev\TabView\Strings\en-us\Resources.resw"/>
</Module>
</Modules>
36 changes: 35 additions & 1 deletion dev/Generated/TabView.properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@
CppWinRTActivatableClassWithDPFactory(TabView)

GlobalDependencyProperty TabViewProperties::s_CanCloseTabsProperty{ nullptr };
GlobalDependencyProperty TabViewProperties::s_IsAddButtonVisibleProperty{ nullptr };
GlobalDependencyProperty TabViewProperties::s_LeftCustomContentProperty{ nullptr };
GlobalDependencyProperty TabViewProperties::s_LeftCustomContentTemplateProperty{ nullptr };
GlobalDependencyProperty TabViewProperties::s_RightCustomContentProperty{ nullptr };
GlobalDependencyProperty TabViewProperties::s_RightCustomContentTemplateProperty{ nullptr };
GlobalDependencyProperty TabViewProperties::s_TabWidthModeProperty{ nullptr };

TabViewProperties::TabViewProperties()
: m_tabClosingEventSource{static_cast<TabView*>(this)}
: m_addButtonClickEventSource{static_cast<TabView*>(this)}
, m_tabClosingEventSource{static_cast<TabView*>(this)}
{
EnsureProperties();
}
Expand All @@ -34,6 +36,17 @@ void TabViewProperties::EnsureProperties()
ValueHelper<bool>::BoxValueIfNecessary(true),
nullptr);
}
if (!s_IsAddButtonVisibleProperty)
{
s_IsAddButtonVisibleProperty =
InitializeDependencyProperty(
L"IsAddButtonVisible",
winrt::name_of<bool>(),
winrt::name_of<winrt::TabView>(),
false /* isAttached */,
ValueHelper<bool>::BoxValueIfNecessary(true),
nullptr);
}
if (!s_LeftCustomContentProperty)
{
s_LeftCustomContentProperty =
Expand Down Expand Up @@ -94,6 +107,7 @@ void TabViewProperties::EnsureProperties()
void TabViewProperties::ClearProperties()
{
s_CanCloseTabsProperty = nullptr;
s_IsAddButtonVisibleProperty = nullptr;
s_LeftCustomContentProperty = nullptr;
s_LeftCustomContentTemplateProperty = nullptr;
s_RightCustomContentProperty = nullptr;
Expand All @@ -119,6 +133,16 @@ bool TabViewProperties::CanCloseTabs()
return ValueHelper<bool>::CastOrUnbox(static_cast<TabView*>(this)->GetValue(s_CanCloseTabsProperty));
}

void TabViewProperties::IsAddButtonVisible(bool value)
{
static_cast<TabView*>(this)->SetValue(s_IsAddButtonVisibleProperty, ValueHelper<bool>::BoxValueIfNecessary(value));
}

bool TabViewProperties::IsAddButtonVisible()
{
return ValueHelper<bool>::CastOrUnbox(static_cast<TabView*>(this)->GetValue(s_IsAddButtonVisibleProperty));
}

void TabViewProperties::LeftCustomContent(winrt::IInspectable const& value)
{
static_cast<TabView*>(this)->SetValue(s_LeftCustomContentProperty, ValueHelper<winrt::IInspectable>::BoxValueIfNecessary(value));
Expand Down Expand Up @@ -169,6 +193,16 @@ winrt::TabViewWidthMode TabViewProperties::TabWidthMode()
return ValueHelper<winrt::TabViewWidthMode>::CastOrUnbox(static_cast<TabView*>(this)->GetValue(s_TabWidthModeProperty));
}

winrt::event_token TabViewProperties::AddButtonClick(winrt::TypedEventHandler<winrt::TabView, winrt::IInspectable> const& value)
{
return m_addButtonClickEventSource.add(value);
}

void TabViewProperties::AddButtonClick(winrt::event_token const& token)
{
m_addButtonClickEventSource.remove(token);
}

winrt::event_token TabViewProperties::TabClosing(winrt::TypedEventHandler<winrt::TabView, winrt::TabViewTabClosingEventArgs> const& value)
{
return m_tabClosingEventSource.add(value);
Expand Down
8 changes: 8 additions & 0 deletions dev/Generated/TabView.properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ class TabViewProperties
void CanCloseTabs(bool value);
bool CanCloseTabs();

void IsAddButtonVisible(bool value);
bool IsAddButtonVisible();

void LeftCustomContent(winrt::IInspectable const& value);
winrt::IInspectable LeftCustomContent();

Expand All @@ -28,22 +31,27 @@ class TabViewProperties
winrt::TabViewWidthMode TabWidthMode();

static winrt::DependencyProperty CanCloseTabsProperty() { return s_CanCloseTabsProperty; }
static winrt::DependencyProperty IsAddButtonVisibleProperty() { return s_IsAddButtonVisibleProperty; }
static winrt::DependencyProperty LeftCustomContentProperty() { return s_LeftCustomContentProperty; }
static winrt::DependencyProperty LeftCustomContentTemplateProperty() { return s_LeftCustomContentTemplateProperty; }
static winrt::DependencyProperty RightCustomContentProperty() { return s_RightCustomContentProperty; }
static winrt::DependencyProperty RightCustomContentTemplateProperty() { return s_RightCustomContentTemplateProperty; }
static winrt::DependencyProperty TabWidthModeProperty() { return s_TabWidthModeProperty; }

static GlobalDependencyProperty s_CanCloseTabsProperty;
static GlobalDependencyProperty s_IsAddButtonVisibleProperty;
static GlobalDependencyProperty s_LeftCustomContentProperty;
static GlobalDependencyProperty s_LeftCustomContentTemplateProperty;
static GlobalDependencyProperty s_RightCustomContentProperty;
static GlobalDependencyProperty s_RightCustomContentTemplateProperty;
static GlobalDependencyProperty s_TabWidthModeProperty;

winrt::event_token AddButtonClick(winrt::TypedEventHandler<winrt::TabView, winrt::IInspectable> const& value);
void AddButtonClick(winrt::event_token const& token);
winrt::event_token TabClosing(winrt::TypedEventHandler<winrt::TabView, winrt::TabViewTabClosingEventArgs> const& value);
void TabClosing(winrt::event_token const& token);

event_source<winrt::TypedEventHandler<winrt::TabView, winrt::IInspectable>> m_addButtonClickEventSource;
event_source<winrt::TypedEventHandler<winrt::TabView, winrt::TabViewTabClosingEventArgs>> m_tabClosingEventSource;

static void EnsureProperties();
Expand Down
2 changes: 2 additions & 0 deletions dev/ResourceHelper/ResourceAccessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ class ResourceAccessor sealed
#define SR_TeachingTipCustomLandmarkName L"TeachingTipCustomLandmarkName"
#define SR_TeachingTipNotification L"TeachingTipNotification"
#define SR_TeachingTipNotificationWithoutAppName L"TeachingTipNotificationWithoutAppName"
#define SR_TabViewAddButtonName L"TabViewAddButtonName"
#define SR_TabViewAddButtonTooltip L"TabViewAddButtonTooltip"

#define IR_NoiseAsset_256X256_PNG L"NoiseAsset_256X256_PNG"

Expand Down
26 changes: 24 additions & 2 deletions dev/TabView/InteractionTests/TabViewTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,14 @@ public void SelectionTest()
}
}

[TestMethod]
// TODO: This test doesn't pass because it can't find the tab content -- this is an acc bug.
//[TestMethod]
public void AddRemoveTest()
{
using (var setup = new TestSetupHelper("TabView Tests"))
{
Log.Comment("Adding tab.");
Button addTabButton = FindElement.ByName<Button>("AddTabButton");
Button addTabButton = FindElement.ByName<Button>("Add New Tab");
addTabButton.InvokeAndWait();

ElementCache.Refresh();
Expand Down Expand Up @@ -213,6 +214,27 @@ public void CancelTabClosingTest()
}
}

// TODO: This test doesn't pass because it can't find the tab content -- this is an acc bug.
//[TestMethod]
public void AddButtonTest()
{
using (var setup = new TestSetupHelper("TabView Tests"))
{
Log.Comment("Add new tab button should be visible.");
var addButton = FindElement.ByName("Add New Tab");
Verify.IsNotNull(addButton);

CheckBox isAddButtonVisibleCheckBox = FindElement.ByName<CheckBox>("IsAddButtonVisibleCheckBox");
isAddButtonVisibleCheckBox.Uncheck();
Wait.ForIdle();

ElementCache.Refresh();
Log.Comment("Add new tab button should not be visible.");
addButton = TryFindElement.ByName("Add New Tab");
Verify.IsNull(addButton);
}
}

Button FindCloseButton(UIObject tabItem)
{
foreach (UIObject elem in tabItem.Children)
Expand Down
128 changes: 128 additions & 0 deletions dev/TabView/Strings/en-us/Resources.resw
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="TabViewAddButtonName" xml:space="preserve">
<value>Add New Tab</value>
<comment>Automation name for the add new tab button.</comment>
</data>
<data name="TabViewAddButtonTooltip" xml:space="preserve">
<value>Add new tab</value>
<comment>Tooltip for the add new tab button.</comment>
</data>
</root>
Loading

0 comments on commit 508db68

Please sign in to comment.