From bd8238046f1fd861dc0ffed125ea30d2aa9f51bf Mon Sep 17 00:00:00 2001
From: Nicolas Jager <nicolas.jager@savoirfairelinux.com>
Date: Wed, 26 Oct 2016 15:49:27 -0400
Subject: [PATCH] fix : call button sometime appears when it should not

Change-Id: Id7f9c26b0f0ad062013ddebf16ce964f569e9a14
Tuleap: #1252
---
 SmartPanel.xaml     |  2 +-
 SmartPanel.xaml.cpp | 29 ++++++++++++++++++++++++-----
 SmartPanel.xaml.h   |  2 ++
 3 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/SmartPanel.xaml b/SmartPanel.xaml
index df28080..95d8ce8 100644
--- a/SmartPanel.xaml
+++ b/SmartPanel.xaml
@@ -223,7 +223,7 @@
         <!-- template for smartpanelitems. -->
         <DataTemplate x:Key="SmartPanelItemsTemplate"
                       x:DataType="controls:SmartPanelItem">
-            <Grid PointerEntered="Grid_PointerEntered" PointerExited="Grid_PointerExited">
+            <Grid PointerEntered="Grid_PointerEntered" PointerExited="Grid_PointerExited" PointerMoved="Grid_PointerMoved">
                 <Grid.RowDefinitions>
                     <!-- row definition for the contact. -->
                     <RowDefinition Height="auto"/>
diff --git a/SmartPanel.xaml.cpp b/SmartPanel.xaml.cpp
index 51235ed..34f9116 100644
--- a/SmartPanel.xaml.cpp
+++ b/SmartPanel.xaml.cpp
@@ -426,21 +426,22 @@ void RingClientUWP::Views::SmartPanel::_cancelCallBtn__Click(Platform::Object^ s
 void RingClientUWP::Views::SmartPanel::Grid_PointerEntered(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e)
 {
     auto grid = dynamic_cast<Grid^>(sender);
-    auto listBoxItem = dynamic_cast<ListBoxItem^>(sender);
     auto item = dynamic_cast<SmartPanelItem^>(grid->DataContext);
 
-    if (item->_callId->IsEmpty())
-        item->_hovered = Windows::UI::Xaml::Visibility::Visible;
+    for (auto it : SmartPanelItemsViewModel::instance->itemsList)
+        it->_hovered = Windows::UI::Xaml::Visibility::Collapsed;
+
+    item->_hovered = Windows::UI::Xaml::Visibility::Visible;
 }
 
 
 void RingClientUWP::Views::SmartPanel::Grid_PointerExited(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e)
 {
-    auto listBoxItem = dynamic_cast<ListBoxItem^>(sender);
     auto grid = dynamic_cast<Grid^>(sender);
     auto item = dynamic_cast<SmartPanelItem^>(grid->DataContext);
 
-    item->_hovered = Windows::UI::Xaml::Visibility::Collapsed;
+    for each (auto it in SmartPanelItemsViewModel::instance->itemsList)
+        item->_hovered = Windows::UI::Xaml::Visibility::Collapsed;
 }
 
 
@@ -924,3 +925,21 @@ void RingClientUWP::Views::SmartPanel::_selectedAccountAvatarContainer__PointerE
     _photoboothIcon_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
     _shaderPhotoboothIcon_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
 }
+
+
+void RingClientUWP::Views::SmartPanel::_smartList__PointerExited(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e)
+{
+
+}
+
+
+void RingClientUWP::Views::SmartPanel::Grid_PointerMoved(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e)
+{
+    auto grid = dynamic_cast<Grid^>(sender);
+    auto item = dynamic_cast<SmartPanelItem^>(grid->DataContext);
+
+    for (auto it : SmartPanelItemsViewModel::instance->itemsList)
+        it->_hovered = Windows::UI::Xaml::Visibility::Collapsed;
+
+    item->_hovered = Windows::UI::Xaml::Visibility::Visible;
+}
diff --git a/SmartPanel.xaml.h b/SmartPanel.xaml.h
index 3267255..8cf5f7e 100644
--- a/SmartPanel.xaml.h
+++ b/SmartPanel.xaml.h
@@ -136,6 +136,8 @@ private:
     void _selectedAccountAvatarContainer__PointerEntered(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e);
     void _selectedAccountAvatarContainer__PointerReleased(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e);
     void _selectedAccountAvatarContainer__PointerExited(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e);
+    void _smartList__PointerExited(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e);
+    void Grid_PointerMoved(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e);
 };
 }
 }
\ No newline at end of file
-- 
GitLab