| 14 | using namespace Windows::UI::Composition; |
| 15 | |
| 16 | struct App : implements<App, IFrameworkViewSource, IFrameworkView> |
| 17 | { |
| 18 | CompositionTarget m_target{nullptr}; |
| 19 | VisualCollection m_visuals{nullptr}; |
| 20 | Visual m_selected{nullptr}; |
| 21 | float2 m_offset{}; |
| 22 | bool runFirst = true; |
| 23 | wd::common::Logging logthing; |
| 24 | |
| 25 | IFrameworkView CreateView() |
| 26 | { |
| 27 | return *this; |
| 28 | } |
| 29 | |
| 30 | void Initialize(CoreApplicationView const &) |
| 31 | { |
| 32 | } |
| 33 | |
| 34 | void Load(hstring const &) |
| 35 | { |
| 36 | } |
| 37 | |
| 38 | void Uninitialize() |
| 39 | { |
| 40 | } |
| 41 | |
| 42 | void Run() |
| 43 | { |
| 44 | CoreWindow window = CoreWindow::GetForCurrentThread(); |
| 45 | window.Activate(); |
| 46 | |
| 47 | CoreDispatcher dispatcher = window.Dispatcher(); |
| 48 | dispatcher.ProcessEvents(CoreProcessEventsOption::ProcessUntilQuit); |
| 49 | } |
| 50 | |
| 51 | void SetWindow(CoreWindow const &window) |
| 52 | { |
| 53 | Compositor compositor; |
| 54 | ContainerVisual root = compositor.CreateContainerVisual(); |
| 55 | m_target = compositor.CreateTargetForCurrentView(); |
| 56 | m_target.Root(root); |
| 57 | m_visuals = root.Children(); |
| 58 | |
| 59 | window.PointerPressed({this, &App::OnPointerPressed}); |
| 60 | window.PointerMoved({this, &App::OnPointerMoved}); |
| 61 | |
| 62 | window.PointerReleased([&](auto &&...) { m_selected = nullptr; }); |
| 63 | } |
| 64 | |
| 65 | void OnPointerPressed(IInspectable const &, PointerEventArgs const &args) |
| 66 | { |
| 67 | float2 const point = args.CurrentPoint().Position(); |
| 68 | |
| 69 | for (Visual visual : m_visuals) |
| 70 | { |
| 71 | float3 const offset = visual.Offset(); |
| 72 | float2 const size = visual.Size(); |
| 73 |
nothing calls this directly
no outgoing calls
no test coverage detected