mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Support Scroll in HoloLens mode
This commit is contained in:
parent
24d2213780
commit
380e54b4f6
5 changed files with 32 additions and 5 deletions
|
@ -35,6 +35,21 @@ void BrowserPage::OnPageLoaded(IInspectable const &, RoutedEventArgs const &) {
|
|||
|
||||
swapChainPanel().PointerReleased(
|
||||
std::bind(&BrowserPage::OnSurfaceClicked, this, _1, _2));
|
||||
|
||||
swapChainPanel().ManipulationDelta(
|
||||
std::bind(&BrowserPage::OnSurfaceManipulationDelta, this, _1, _2));
|
||||
}
|
||||
|
||||
void BrowserPage::OnSurfaceManipulationDelta(
|
||||
IInspectable const &, Input::ManipulationDeltaRoutedEventArgs const &e) {
|
||||
auto x = e.Position().X;
|
||||
auto y = e.Position().Y;
|
||||
auto dx = e.Delta().Translation.X;
|
||||
auto dy = e.Delta().Translation.Y;
|
||||
Event event = {{Event::SCROLL}};
|
||||
event.scrollCoords = {dx, dy, x, y};
|
||||
SendEventToServo(event);
|
||||
e.Handled(true);
|
||||
}
|
||||
|
||||
void BrowserPage::OnSurfaceClicked(IInspectable const &,
|
||||
|
@ -186,10 +201,15 @@ void BrowserPage::Loop(cancellation_token cancel) {
|
|||
for (auto &&e : mEvents) {
|
||||
switch (e.type) {
|
||||
case Event::CLICK: {
|
||||
auto [x, y] = e.coords;
|
||||
auto [x, y] = e.clickCoords;
|
||||
mServo->Click(x, y);
|
||||
break;
|
||||
}
|
||||
case Event::SCROLL: {
|
||||
auto [x, y, dx, dy] = e.scrollCoords;
|
||||
mServo->Scroll(x, y, dx, dy);
|
||||
break;
|
||||
}
|
||||
case Event::FORWARD:
|
||||
mServo->GoForward();
|
||||
break;
|
||||
|
|
|
@ -12,8 +12,9 @@
|
|||
namespace winrt::ServoApp::implementation {
|
||||
|
||||
struct Event {
|
||||
enum { CLICK, BACK, FORWARD } type;
|
||||
std::tuple<float, float> coords;
|
||||
enum { CLICK, SCROLL, BACK, FORWARD } type;
|
||||
std::tuple<float, float> clickCoords;
|
||||
std::tuple<float, float, float, float> scrollCoords;
|
||||
};
|
||||
|
||||
struct BrowserPage : BrowserPageT<BrowserPage> {
|
||||
|
@ -31,6 +32,10 @@ public:
|
|||
OnSurfaceClicked(Windows::Foundation::IInspectable const &,
|
||||
Windows::UI::Xaml::Input::PointerRoutedEventArgs const &);
|
||||
|
||||
void BrowserPage::OnSurfaceManipulationDelta(
|
||||
IInspectable const &,
|
||||
Windows::UI::Xaml::Input::ManipulationDeltaRoutedEventArgs const &e);
|
||||
|
||||
private:
|
||||
void OnVisibilityChanged(
|
||||
Windows::UI::Core::CoreWindow const &,
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
<Button x:Name="immersiveButton" Click="OnImmersiveButtonClicked">Run Immersive</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<SwapChainPanel x:Name="swapChainPanel" MinHeight="200" MinWidth="200" Grid.Row="1">
|
||||
<SwapChainPanel x:Name="swapChainPanel" MinHeight="200" MinWidth="200" Grid.Row="1" ManipulationMode="All">
|
||||
</SwapChainPanel>
|
||||
</Grid>
|
||||
</Page>
|
||||
|
|
|
@ -51,7 +51,7 @@ Servo::Servo(GLsizei width, GLsizei height)
|
|||
|
||||
CInitOptions o;
|
||||
o.args = NULL;
|
||||
o.url = "https://google.com";
|
||||
o.url = "https://servo.org";
|
||||
o.width = mWindowWidth;
|
||||
o.height = mWindowHeight;
|
||||
o.density = 1.0;
|
||||
|
@ -93,3 +93,4 @@ void Servo::SetSize(GLsizei width, GLsizei height) {
|
|||
}
|
||||
|
||||
void Servo::Click(float x, float y) { click(x, y); }
|
||||
void Servo::Scroll(float dx, float dy, float x, float y) { scroll(dx, dy, x, y); }
|
||||
|
|
|
@ -16,6 +16,7 @@ public:
|
|||
~Servo();
|
||||
void PerformUpdates();
|
||||
void Click(float, float);
|
||||
void Scroll(float dx, float dy, float x, float y);
|
||||
void SetSize(GLsizei width, GLsizei height);
|
||||
void SetBatchMode(bool);
|
||||
void GoBack();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue