Skip to content

Commit

Permalink
c++ headers cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
paulrouget committed Jun 10, 2020
1 parent dd2ebce commit 0d8afd9
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 81 deletions.
22 changes: 11 additions & 11 deletions support/hololens/ServoApp/App.h
Expand Up @@ -6,19 +6,19 @@
#include "App.xaml.g.h"

namespace winrt::ServoApp::implementation {
using namespace winrt::Windows::Foundation;
using namespace winrt::Windows::UI::Xaml;
using namespace winrt::Windows::ApplicationModel;
using namespace winrt::Windows::ApplicationModel::Activation;

struct App : AppT<App> {
App();

void createRootFrame(winrt::Windows::UI::Xaml::Controls::Frame &, bool,
winrt::Windows::Foundation::IInspectable const &);
void OnLaunched(
Windows::ApplicationModel::Activation::LaunchActivatedEventArgs const &);
void App::OnActivated(
Windows::ApplicationModel::Activation::IActivatedEventArgs const &);
void OnSuspending(IInspectable const &,
Windows::ApplicationModel::SuspendingEventArgs const &);
void OnNavigationFailed(
IInspectable const &,
Windows::UI::Xaml::Navigation::NavigationFailedEventArgs const &);
void createRootFrame(Controls::Frame &, bool, IInspectable const &);
void OnLaunched(LaunchActivatedEventArgs const &);
void App::OnActivated(IActivatedEventArgs const &);
void OnSuspending(IInspectable const &, SuspendingEventArgs const &);
void OnNavigationFailed(IInspectable const &,
Navigation::NavigationFailedEventArgs const &);
};
} // namespace winrt::ServoApp::implementation
48 changes: 21 additions & 27 deletions support/hololens/ServoApp/BrowserPage.h
Expand Up @@ -9,7 +9,9 @@

namespace winrt::ServoApp::implementation {

using namespace winrt::Windows;
using namespace winrt::Windows::Foundation;
using namespace winrt::Windows::UI::Xaml;

static const hstring SERVO_SCHEME = L"fxr";
static const hstring SERVO_SCHEME_SLASH_SLASH = L"fxr://";
Expand All @@ -18,38 +20,30 @@ struct BrowserPage : BrowserPageT<BrowserPage> {
public:
BrowserPage();

void OnForwardButtonClicked(Windows::Foundation::IInspectable const &,
Windows::UI::Xaml::RoutedEventArgs const &);
void OnBackButtonClicked(Windows::Foundation::IInspectable const &,
Windows::UI::Xaml::RoutedEventArgs const &);
void OnReloadButtonClicked(Windows::Foundation::IInspectable const &,
Windows::UI::Xaml::RoutedEventArgs const &);
void OnStopButtonClicked(Windows::Foundation::IInspectable const &,
Windows::UI::Xaml::RoutedEventArgs const &);
void OnHomeButtonClicked(Windows::Foundation::IInspectable const &,
Windows::UI::Xaml::RoutedEventArgs const &);
void OnDevtoolsButtonClicked(Windows::Foundation::IInspectable const &,
Windows::UI::Xaml::RoutedEventArgs const &);
void OnURLEdited(Windows::Foundation::IInspectable const &,
Windows::UI::Xaml::Input::KeyRoutedEventArgs const &);
void OnURLFocused(Windows::Foundation::IInspectable const &);
void OnURLKeyboardAccelerator(
Windows::Foundation::IInspectable const &,
Windows::UI::Xaml::Input::KeyboardAcceleratorInvokedEventArgs const &);
void OnForwardButtonClicked(IInspectable const &, RoutedEventArgs const &);
void OnBackButtonClicked(IInspectable const &, RoutedEventArgs const &);
void OnReloadButtonClicked(IInspectable const &, RoutedEventArgs const &);
void OnStopButtonClicked(IInspectable const &, RoutedEventArgs const &);
void OnHomeButtonClicked(IInspectable const &, RoutedEventArgs const &);
void OnDevtoolsButtonClicked(IInspectable const &, RoutedEventArgs const &);
void OnURLEdited(IInspectable const &, Input::KeyRoutedEventArgs const &);
void OnURLFocused(IInspectable const &);
void
OnURLKeyboardAccelerator(IInspectable const &,
Input::KeyboardAcceleratorInvokedEventArgs const &);
void Shutdown();
void LoadServoURI(Windows::Foundation::Uri uri);
void LoadServoURI(Uri uri);
void SetTransientMode(bool);
void SetArgs(hstring);
void OnMediaControlsPlayClicked(Windows::Foundation::IInspectable const &,
Windows::UI::Xaml::RoutedEventArgs const &);
void OnMediaControlsPauseClicked(Windows::Foundation::IInspectable const &,
Windows::UI::Xaml::RoutedEventArgs const &);
void OnPrefererenceSearchboxEdited(
Windows::Foundation::IInspectable const &,
Windows::UI::Xaml::Input::KeyRoutedEventArgs const &);
void OnMediaControlsPlayClicked(IInspectable const &,
RoutedEventArgs const &);
void OnMediaControlsPauseClicked(IInspectable const &,
RoutedEventArgs const &);
void OnPrefererenceSearchboxEdited(IInspectable const &,
Input::KeyRoutedEventArgs const &);

private:
void UpdatePref(ServoApp::Pref, Windows::UI::Xaml::Controls::Control);
void UpdatePref(ServoApp::Pref, Controls::Control);
void BindServoEvents();
void BuildPrefList();
DevtoolsStatus mDevtoolsStatus = DevtoolsStatus::Stopped;
Expand Down
80 changes: 37 additions & 43 deletions support/hololens/ServoApp/ServoControl/Servo.h
Expand Up @@ -17,6 +17,8 @@ extern "C" {
}
} // namespace capi

using namespace capi;

hstring char2hstring(const char *);
std::unique_ptr<char *> hstring2char(hstring);

Expand All @@ -39,65 +41,57 @@ class Servo {
static PrefTuple SetFloatPref(hstring key, double val);
static PrefTuple ResetPref(hstring key);

typedef capi::CMouseButton MouseButton;
typedef capi::CPromptResult PromptResult;
typedef capi::CContextMenuResult ContextMenuResult;
typedef capi::CMediaSessionActionType MediaSessionActionType;
typedef capi::CMediaSessionPlaybackState MediaSessionPlaybackState;
typedef capi::CDevtoolsServerState DevtoolsServerState;
typedef capi::CPrefType CPrefType;

void PerformUpdates() { capi::perform_updates(); }
void DeInit() { capi::deinit(); }
void RequestShutdown() { capi::request_shutdown(); }
void SetBatchMode(bool mode) { capi::set_batch_mode(mode); }
void GoForward() { capi::go_forward(); }
void GoBack() { capi::go_back(); }
void Click(float x, float y) { capi::click(x, y); }
void MouseDown(float x, float y, capi::CMouseButton b) {
capi::mouse_down(x, y, b);
}
void MouseUp(float x, float y, capi::CMouseButton b) {
capi::mouse_up(x, y, b);
}
void TouchDown(float x, float y, int32_t id) { capi::touch_down(x, y, id); }
void TouchUp(float x, float y, int32_t id) { capi::touch_up(x, y, id); }
void TouchMove(float x, float y, int32_t id) { capi::touch_move(x, y, id); }
void TouchCancel(float x, float y, int32_t id) {
capi::touch_cancel(x, y, id);
}
void MouseMove(float x, float y) { capi::mouse_move(x, y); }

void Reload() { capi::reload(); }
void Stop() { capi::stop(); }
bool LoadUri(hstring uri) { return capi::load_uri(*hstring2char(uri)); }
void ChangeVisibility(bool visible) { capi::change_visibility(visible); }
bool IsUriValid(hstring uri) {
return capi::is_uri_valid(*hstring2char(uri));
}
typedef CMouseButton MouseButton;
typedef CPromptResult PromptResult;
typedef CContextMenuResult ContextMenuResult;
typedef CMediaSessionActionType MediaSessionActionType;
typedef CMediaSessionPlaybackState MediaSessionPlaybackState;
typedef CDevtoolsServerState DevtoolsServerState;
typedef CPrefType CPrefType;

void PerformUpdates() { perform_updates(); }
void DeInit() { deinit(); }
void RequestShutdown() { request_shutdown(); }
void SetBatchMode(bool mode) { set_batch_mode(mode); }
void GoForward() { go_forward(); }
void GoBack() { go_back(); }
void Click(float x, float y) { click(x, y); }
void MouseDown(float x, float y, CMouseButton b) { mouse_down(x, y, b); }
void MouseUp(float x, float y, CMouseButton b) { mouse_up(x, y, b); }
void TouchDown(float x, float y, int32_t id) { touch_down(x, y, id); }
void TouchUp(float x, float y, int32_t id) { touch_up(x, y, id); }
void TouchMove(float x, float y, int32_t id) { touch_move(x, y, id); }
void TouchCancel(float x, float y, int32_t id) { touch_cancel(x, y, id); }
void MouseMove(float x, float y) { mouse_move(x, y); }

void Reload() { reload(); }
void Stop() { stop(); }
bool LoadUri(hstring uri) { return load_uri(*hstring2char(uri)); }
void ChangeVisibility(bool visible) { change_visibility(visible); }
bool IsUriValid(hstring uri) { return is_uri_valid(*hstring2char(uri)); }
void Scroll(float dx, float dy, float x, float y) {
capi::scroll((int32_t)dx, (int32_t)dy, (int32_t)x, (int32_t)y);
scroll((int32_t)dx, (int32_t)dy, (int32_t)x, (int32_t)y);
}
void SetSize(GLsizei width, GLsizei height) {
if (width != mWindowWidth || height != mWindowHeight) {
mWindowWidth = width;
mWindowHeight = height;
capi::resize(mWindowWidth, mWindowHeight);
resize(mWindowWidth, mWindowHeight);
}
}
void SendMediaSessionAction(capi::CMediaSessionActionType action) {
capi::media_session_action(action);
void SendMediaSessionAction(CMediaSessionActionType action) {
media_session_action(action);
}
void ContextMenuClosed(capi::CContextMenuResult res, unsigned int idx) {
capi::on_context_menu_closed(res, idx);
void ContextMenuClosed(CContextMenuResult res, unsigned int idx) {
on_context_menu_closed(res, idx);
}

private:
ServoDelegate &mDelegate;
GLsizei mWindowWidth;
GLsizei mWindowHeight;
static void SaveUserPref(PrefTuple);
static PrefTuple WrapPref(capi::CPref cpref);
static PrefTuple WrapPref(CPref cpref);
};

class ServoDelegate {
Expand Down

0 comments on commit 0d8afd9

Please sign in to comment.