Commit 1e120ad8 authored by atraczyk's avatar atraczyk

videopage: move/resize preview image

- Implements moving and resizing of the preview window during a
  video call. The preview window will anchor to the corner it's
  closest to after completing the movement. The preview window can
  be resized.

- Refactors the full-screen mode change to be separated into
  setFullScreenMode and setWindowedMode.

Change-Id: I147094c9c56c15f9e423acab7f09fd3e0f295bb0
Tuleap: #1515
parent 3dbc4021
......@@ -104,7 +104,7 @@ MainPage::MainPage()
_loadingStatus_->Foreground = brush;
});
RingD::instance->toggleFullScreen += ref new RingClientUWP::ToggleFullScreen(this, &RingClientUWP::MainPage::OnToggleFullScreen);
RingD::instance->fullScreenToggled += ref new RingClientUWP::FullScreenToggled(this, &RingClientUWP::MainPage::OnFullScreenToggled);
}
void
......@@ -182,6 +182,7 @@ RingClientUWP::MainPage::showLoadingOverlay(bool load, bool modal)
void
RingClientUWP::MainPage::OnResize(Platform::Object^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ e)
{
RingD::instance->raiseWindowResized();
}
void
......@@ -382,7 +383,7 @@ void RingClientUWP::MainPage::OnvolatileDetailsChanged(const std::string &accoun
showLoadingOverlay(false, false);
}
void RingClientUWP::MainPage::OnToggleFullScreen(bool state)
void RingClientUWP::MainPage::OnFullScreenToggled(bool state)
{
static bool openState;
if (state == true) {
......
......@@ -64,7 +64,7 @@ private:
void _toggleSmartBoxButton__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void showFrame(Windows::UI::Xaml::Controls::Frame^ frame);
void OnsummonMessageTextPage();
void OnToggleFullScreen(bool state);
void OnFullScreenToggled(bool state);
void OnsummonWelcomePage();
void OnsummonPreviewPage();
void OnhidePreviewPage();
......
......@@ -275,6 +275,11 @@ void RingClientUWP::RingD::unPauseCall(const std::string & callId)
tasksList_.push(task);
}
void RingClientUWP::RingD::raiseWindowResized()
{
windowResized();
}
void RingClientUWP::RingD::cancelOutGoingCall2(String ^ callId)
{
MSG_("$1 cancelOutGoingCall2 : " + Utils::toString(callId));
......@@ -950,7 +955,7 @@ RingD::dequeueTasks()
break;
case Request::PlaceCall:
{
auto callId = DRing::placeCall(task->_accountId_new, "ring:" + task->_ringId_new);
auto callId = DRing::placeCall(task->_accountId_new, std::string("ring:" + task->_ringId_new));
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::High,
ref new DispatchedHandler([=]() {
......@@ -1367,21 +1372,28 @@ Vector<String^>^ RingClientUWP::RingD::translateKnownRingDevices(const std::map<
return devicesList;
}
void RingClientUWP::RingD::raiseToggleFullScreen()
void RingClientUWP::RingD::setFullScreenMode()
{
ApplicationView^ view = ApplicationView::GetForCurrentView();
if (view->IsFullScreenMode) {
view->ExitFullScreenMode();
toggleFullScreen(false);
MSG_("Successfully exited fullscreen");
if (ApplicationView::GetForCurrentView()->TryEnterFullScreenMode()) {
MSG_("TryEnterFullScreenMode succeeded");
fullScreenToggled(true);
}
else {
if (view->TryEnterFullScreenMode()) {
MSG_("Successfully entered fullscreen");
toggleFullScreen(true);
}
else {
ERR_("Unsuccessfully entered fullscreen");
}
ERR_("TryEnterFullScreenMode failed");
}
}
void RingClientUWP::RingD::setWindowedMode()
{
ApplicationView::GetForCurrentView()->ExitFullScreenMode();
MSG_("ExitFullScreenMode");
fullScreenToggled(false);
}
void RingClientUWP::RingD::toggleFullScreen()
{
if (isFullScreen)
setWindowedMode();
else
setFullScreenMode();
}
......@@ -25,6 +25,7 @@ using namespace concurrency;
using namespace Windows::UI::Notifications;
using namespace Windows::Data::Xml::Dom;
using namespace Windows::UI::ViewManagement;
namespace RingClientUWP
{
......@@ -54,7 +55,8 @@ delegate void CallsListRecieved(const std::vector<std::string>& callsList);
delegate void AudioMuted(const std::string& callId, bool state);
delegate void VideoMuted(const std::string& callId, bool state);
delegate void NameRegistred(bool status);
delegate void ToggleFullScreen(bool state);
delegate void FullScreenToggled(bool state);
delegate void WindowResized();
delegate void VolatileDetailsChanged(const std::string& accountId, const std::map<std::string, std::string>& details);
using SharedCallback = std::shared_ptr<DRing::CallbackWrapperBase>;
......@@ -64,6 +66,7 @@ public ref class RingD sealed
{
public:
/* functions */
void raiseWindowResized();
/* properties */
static property RingD^ instance
......@@ -91,6 +94,14 @@ public:
}
}
property bool isFullScreen
{
bool get()
{
return ApplicationView::GetForCurrentView()->IsFullScreenMode;
}
}
property bool isOnXBox
{
bool get()
......@@ -140,7 +151,9 @@ internal:
String^ getUserName();
Vector<String^>^ translateKnownRingDevices(const std::map<std::string, std::string> devices);
void raiseToggleFullScreen();
void toggleFullScreen();
void setWindowedMode();
void setFullScreenMode();
void hangUpCall2(String^ callId);
void pauseCall(String ^ callId);
......@@ -186,7 +199,8 @@ internal:
event AudioMuted^ audioMuted;
event VideoMuted^ videoMuted;
event NameRegistred^ nameRegistred;
event ToggleFullScreen^ toggleFullScreen;
event FullScreenToggled^ fullScreenToggled;
event WindowResized^ windowResized;
event VolatileDetailsChanged^ volatileDetailsChanged;
private:
......
......@@ -37,6 +37,19 @@ SmartPanelItemsViewModel::SmartPanelItemsViewModel()
RingD::instance->stateChange += ref new RingClientUWP::StateChange(this, &RingClientUWP::ViewModel::SmartPanelItemsViewModel::OnstateChange);
}
bool
SmartPanelItemsViewModel::isInCall()
{
bool isInCall = false;
for (auto item : itemsList) {
if (item->_callId && item->_callStatus == CallStatus::IN_PROGRESS) {
isInCall = true;
break;
}
}
return isInCall;
}
SmartPanelItem^
SmartPanelItemsViewModel::findItem(String^ callId)
{
......
......@@ -30,6 +30,9 @@ namespace ViewModel {
public ref class SmartPanelItemsViewModel sealed
{
public:
bool isInCall();
internal:
/* singleton */
static property SmartPanelItemsViewModel^ instance
......
......@@ -64,6 +64,13 @@ VideoCaptureManager::VideoCaptureManager():
captureTaskTokenSource = new cancellation_token_source();
}
double
VideoCaptureManager::aspectRatio()
{
auto resolution = activeDevice->currentResolution();
return static_cast<double>(resolution->width()) / static_cast<double>(resolution->height());
}
Map<String^,String^>^
VideoCaptureManager::getSettings(String^ device)
{
......
......@@ -40,12 +40,16 @@ namespace Video
public ref class VideoCaptureManager sealed
{
public:
double aspectRatio();
internal:
property bool isPreviewing
{
bool get() { return isPreviewing_; }
void set(bool value) { isPreviewing_ = value; }
}
property bool isSettingsPreviewing
{
bool get() { return isSettingsPreviewing_; }
......
......@@ -125,7 +125,6 @@
IsTabStop="False"
AutomationProperties.AccessibilityView="Raw"
ZoomMode="Disabled" />
<Button x:Name="_sendBtn_"
Background="Transparent"
BorderThickness="0"
......@@ -152,7 +151,7 @@
<Frame x:Name="_chatPanel_"/>
</SplitView.Pane>
<SplitView.Content>
<Grid>
<Grid x:Name="_videoContent_">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition x:Name="_rowChatBx_" Height="0"/>
......@@ -162,6 +161,7 @@
PointerMoved="_videoControl__PointerMoved">
<StackPanel x:Name="_headerBar_"
Background="{StaticResource SemiTransparentBlack}"
Canvas.ZIndex="99999"
HorizontalAlignment="Stretch"
VerticalAlignment="Top"
Height="50">
......@@ -172,7 +172,7 @@
</StackPanel>
<!-- video -->
<Image Name="IncomingVideoImage"
<Image Name="_IncomingVideoImage_"
Grid.Column="0"
Canvas.ZIndex="-1"
DoubleTapped="IncomingVideoImage_DoubleTapped"
......@@ -189,12 +189,24 @@
Canvas.ZIndex="-1"/>
<!--camera preview-->
<CaptureElement Name="PreviewImage"
Width="200"
VerticalAlignment="Center"
HorizontalAlignment="Right"
Stretch="Uniform"
Grid.Column="0"/>
<Canvas Name="_PreviewImageRect_"
HorizontalAlignment="Right"
VerticalAlignment="Bottom"
PointerReleased="PreviewImage_PointerReleased"
PointerCaptureLost="PreviewImage_PointerReleased">
<Polygon Name="_PreviewImageResizer_"
Visibility="Collapsed"
Fill="#FF3BC1D3"
Points="0,0,20,0,0,20"
Canvas.ZIndex="99999"
ManipulationMode="TranslateY"/>
<CaptureElement Name="_PreviewImage_"
Visibility="Collapsed"
Stretch="Uniform"
Width="20"
Height="20"
ManipulationMode="All"/>
</Canvas>
<StackPanel x:Name="_controlsBar_"
HorizontalAlignment="Center"
......@@ -323,7 +335,6 @@
Tapped="_btnSwitch__Tapped" Visibility="Collapsed">
<SymbolIcon Symbol="Switch"/>
</Button>
<!--Tapped="_btnMicrophone__Tapped"-->
<Button x:Name="_btnMicrophone_"
PointerEntered="btnAny_entered"
PointerExited="btnAny_exited"
......
This diff is collapsed.
......@@ -21,13 +21,15 @@
#include "VideoPage.g.h"
#include "MessageTextPage.xaml.h"
using namespace Platform;
using namespace Concurrency;
using namespace Windows::Media::Capture;
using namespace Windows::UI::Xaml::Navigation;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Media;
using namespace Windows::ApplicationModel::Core;
using namespace Windows::Devices::Enumeration;
using namespace Windows::UI::Xaml::Input;
namespace RingClientUWP
{
......@@ -51,16 +53,9 @@ public:
VideoPage();
void updatePageContent();
property bool barFading
{
bool get()
{
return barFading_;
}
void set(bool value)
{
barFading_ = value;
}
property bool barFading {
bool get(){ return barFading_; }
void set(bool value) { barFading_ = value; }
}
void scrollDown();
......@@ -84,35 +79,56 @@ internal:
private:
bool barFading_;
void _sendBtn__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void _messageTextBox__KeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e);
void sendMessage();
// For transforming the preview image
double userPreviewHeightModifier = 0.0;
bool isResizingPreview = false;
int lastQuadrant = 0;
int quadrant = 0;
TransformGroup^ PreviewImage_transforms;
MatrixTransform^ PreviewImage_previousTransform;
CompositeTransform^ PreviewImage_deltaTransform;
Concurrency::task<void> WriteFrameAsSoftwareBitmapAsync(String^ id, uint8_t* buf, int width, int height);
void Button_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void _btnCancel__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void _btnHangUp__Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e);
void _btnPause__Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e);
void _btnChat__Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e);
void _btnAddFriend__Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e);
void _btnSwitch__Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e);
void _btnMicrophone__Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e);
void _btnMemo__Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e);
void _btnHQ__Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e);
void _btnVideo__Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e);
void _videoControl__PointerMoved(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e);
void btnAny_entered(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e);
void btnAny_exited(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e);
void OnincomingMessage(Platform::String ^callId, Platform::String ^payload);
void _btnVideo__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void OnincomingVideoMuted(Platform::String ^callId, bool state);
void _sendBtn__Click(Platform::Object^ sender, RoutedEventArgs^ e);
void _messageTextBox__KeyDown(Object^ sender, KeyRoutedEventArgs^ e);
void sendMessage();
void Button_Click(Object^ sender, RoutedEventArgs^ e);
void _btnCancel__Click(Object^ sender, RoutedEventArgs^ e);
void _btnHangUp__Tapped(Object^ sender, TappedRoutedEventArgs^ e);
void _btnPause__Tapped(Object^ sender, TappedRoutedEventArgs^ e);
void _btnChat__Tapped(Object^ sender, TappedRoutedEventArgs^ e);
void _btnAddFriend__Tapped(Object^ sender, TappedRoutedEventArgs^ e);
void _btnSwitch__Tapped(Object^ sender, TappedRoutedEventArgs^ e);
void _btnMicrophone__Tapped(Object^ sender, TappedRoutedEventArgs^ e);
void _btnMemo__Tapped(Object^ sender, TappedRoutedEventArgs^ e);
void _btnHQ__Tapped(Object^ sender, TappedRoutedEventArgs^ e);
void _btnVideo__Tapped(Object^ sender, TappedRoutedEventArgs^ e);
void _videoControl__PointerMoved(Object^ sender, PointerRoutedEventArgs^ e);
void btnAny_entered(Object^ sender, PointerRoutedEventArgs^ e);
void btnAny_exited(Object^ sender, PointerRoutedEventArgs^ e);
void _btnVideo__Click(Object^ sender, RoutedEventArgs^ e);
void _btnMicrophone__Click(Object^ sender, RoutedEventArgs^ e);
void IncomingVideoImage_DoubleTapped(Object^ sender, DoubleTappedRoutedEventArgs^ e);
void OnincomingMessage(String ^callId, String ^payload);
void OnincomingVideoMuted(String ^callId, bool state);
void OnstartPreviewing();
void OnstopPreviewing();
void _btnMicrophone__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void OnaudioMuted(const std::string &callId, bool state);
void OnvideoMuted(const std::string &callId, bool state);
void IncomingVideoImage_DoubleTapped(Platform::Object^ sender, Windows::UI::Xaml::Input::DoubleTappedRoutedEventArgs^ e);
// For transforming the preview image
void computeQuadrant();
void arrangeResizer();
void anchorPreview();
void updatePreviewFrameDimensions();
void InitManipulationTransforms();
void PreviewImage_ManipulationDelta(Object^ sender, ManipulationDeltaRoutedEventArgs^ e);
void PreviewImage_ManipulationCompleted(Object^ sender, ManipulationCompletedRoutedEventArgs^ e);
void PreviewImageResizer_ManipulationDelta(Object^ sender, ManipulationDeltaRoutedEventArgs^ e);
void PreviewImageResizer_ManipulationCompleted(Object^ sender, ManipulationCompletedRoutedEventArgs^ e);
void PreviewImage_PointerReleased(Object^ sender, PointerRoutedEventArgs^ e);
void PreviewImageResizer_PointerEntered(Object^ sender, PointerRoutedEventArgs^ e);
void PreviewImageResizer_PointerExited(Object^ sender, PointerRoutedEventArgs^ e);
};
}
}
\ No newline at end of file
......@@ -162,7 +162,7 @@
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
</Link>
<Link>
<AdditionalOptions>/nodefaultlib:libcmt.lib /ignore:4006,4049,4099 %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions>/nodefaultlib:libcmt.lib /ignore:4006,4049,4099,4078 %(AdditionalOptions)</AdditionalOptions>
<GenerateWindowsMetadata>true</GenerateWindowsMetadata>
<WindowsMetadataFile>$(OutDir)RingClientUWP.winmd</WindowsMetadataFile>
</Link>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment