Skip to content

Commit

Permalink
Revert "TabView fixes (#6632)"
Browse files Browse the repository at this point in the history
This reverts commit f4e6550.
  • Loading branch information
kmahone committed Feb 18, 2022
1 parent 913dcf1 commit a99ef9d
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 40 deletions.
29 changes: 2 additions & 27 deletions dev/TabView/TabView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -691,31 +691,11 @@ void TabView::OnItemsPresenterSizeChanged(const winrt::IInspectable& sender, con
// Presenter size didn't change because of item being removed, so update manually
UpdateScrollViewerDecreaseAndIncreaseButtonsViewState();
UpdateTabWidths();
// Make sure that the selected tab is fully in view and not cut off
BringSelectedTabIntoView();
}
}

void TabView::BringSelectedTabIntoView()
{
if(SelectedItem())
{
auto tvi = SelectedItem().try_as<winrt::TabViewItem>();
if (!tvi)
{
tvi = ContainerFromItem(SelectedItem()).try_as<winrt::TabViewItem>();
}
winrt::get_self<TabViewItem>(tvi)->StartBringTabIntoView();
}
}

void TabView::OnItemsChanged(winrt::IInspectable const& item)
{
if(m_isDragging)
{
return;
}

if (auto args = item.as<winrt::IVectorChangedEventArgs>())
{
m_tabItemsChangedEventSource(*this, args);
Expand Down Expand Up @@ -786,6 +766,8 @@ void TabView::OnItemsChanged(winrt::IInspectable const& item)

void TabView::OnListViewSelectionChanged(const winrt::IInspectable& sender, const winrt::SelectionChangedEventArgs& args)
{


if (auto&& listView = m_listView.get())
{
SelectedIndex(listView.SelectedIndex());
Expand Down Expand Up @@ -854,13 +836,6 @@ void TabView::OnListViewDragItemsCompleted(const winrt::IInspectable& sender, co
{
m_isDragging = false;

// Selection change was disabled during drag, update SelectedIndex now
if (auto&& listView = m_listView.get())
{
SelectedIndex(listView.SelectedIndex());
SelectedItem(listView.SelectedItem());
}

auto item = args.Items().GetAt(0);
auto tab = FindTabViewItemFromDragItem(item);
auto myArgs = winrt::make_self<TabViewTabDragCompletedEventArgs>(args, item, tab);
Expand Down
1 change: 0 additions & 1 deletion dev/TabView/TabView.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ class TabView :

bool RequestCloseCurrentTab();
bool SelectNextTab(int increment);
void BringSelectedTabIntoView();

void UpdateSelectedItem();
void UpdateSelectedIndex();
Expand Down
11 changes: 1 addition & 10 deletions dev/TabView/TabViewItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "SharedHelpers.h"

static constexpr auto c_overlayCornerRadiusKey = L"OverlayCornerRadius"sv;
static constexpr int c_targetRectWidthIncrement = 2;

TabViewItem::TabViewItem()
{
Expand Down Expand Up @@ -152,7 +151,7 @@ void TabViewItem::OnIsSelectedPropertyChanged(const winrt::DependencyObject& sen
if (IsSelected())
{
SetValue(winrt::Canvas::ZIndexProperty(), box_value(20));
StartBringTabIntoView();
StartBringIntoView();
}
else
{
Expand Down Expand Up @@ -502,11 +501,3 @@ void TabViewItem::OnIconSourceChanged()
winrt::VisualStateManager::GoToState(*this, L"NoIcon"sv, false);
}
}

void TabViewItem::StartBringTabIntoView()
{
// we need to set the TargetRect to be slightly wider than the TabViewItem size in order to avoid cutting off the end of the Tab
winrt::BringIntoViewOptions options;
options.TargetRect(winrt::Rect{ 0, 0, DesiredSize().Width + c_targetRectWidthIncrement, DesiredSize().Height});
StartBringIntoView(options);
}
2 changes: 0 additions & 2 deletions dev/TabView/TabViewItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ class TabViewItem :
winrt::TabView GetParentTabView();
void SetParentTabView(winrt::TabView const& tabView);

void StartBringTabIntoView();

private:
tracker_ref<winrt::Button> m_closeButton{ this };
tracker_ref<winrt::ToolTip> m_toolTip{ this };
Expand Down

0 comments on commit a99ef9d

Please sign in to comment.