@@ -33,55 +33,6 @@ using namespace Input;
3333namespace Im3d
3434{
3535
36- class Im3dInputHandler : public Input ::InputHandler
37- {
38- __DeclareClass (Im3dInputHandler);
39- public:
40- // / constructor
41- Im3dInputHandler () {}
42- // / destructor
43- virtual ~Im3dInputHandler () {}
44-
45- // / capture input to this event handler
46- virtual void BeginCapture ()
47- {
48- Input::InputServer::Instance ()->ObtainMouseCapture (this );
49- Input::InputServer::Instance ()->ObtainKeyboardCapture (this );
50- }
51- // / end input capturing to this event handler
52- virtual void EndCapture ()
53- {
54- Input::InputServer::Instance ()->ReleaseMouseCapture (this );
55- Input::InputServer::Instance ()->ReleaseKeyboardCapture (this );
56- }
57-
58- protected:
59-
60- // / called when an input event should be processed
61- virtual bool OnEvent (const Input::InputEvent& inputEvent)
62- {
63- switch (inputEvent.GetType ())
64- {
65- #ifndef _DEBUG
66- case Input::InputEvent::AppObtainFocus:
67- case Input::InputEvent::AppLoseFocus:
68- #endif
69- case Input::InputEvent::Reset:
70- this ->OnReset ();
71- break ;
72-
73- default :
74- return Im3dContext::HandleInput (inputEvent);
75- }
76- return false ;
77- }
78-
79- private:
80-
81- };
82-
83- __ImplementClass (Im3d::Im3dInputHandler, ' IM3H' , Input::InputHandler);
84-
8536
8637struct Im3dState
8738{
@@ -105,7 +56,6 @@ struct Im3dState
10556 float cellSize = 1 .0f ;
10657 Math::vec4 gridColor{ 1 .0f ,1 .0f ,1 .0f ,0 .3f };
10758 Math::vec2 gridOffset{ 0 , 0 };
108- Ptr<Im3dInputHandler> inputHandler;
10959 Im3d::Id depthLayerId;
11060 byte* vertexPtr;
11161 Math::vec2 viewPortPosition{ 0 .0f , 0 .0f };
@@ -138,9 +88,6 @@ Im3dContext::Create()
13888{
13989 Graphics::GraphicsServer::Instance ()->RegisterGraphicsContext (&__bundle, &__state);
14090
141- imState.inputHandler = Im3dInputHandler::Create ();
142- // Input::InputServer::Instance()->AttachInputHandler(Input::InputPriority::DynUi, imState.inputHandler.upcast<Input::InputHandler>());
143-
14491 // allocate im3d shader
14592 imState.im3dShader = CoreGraphics::ShaderGet (" shd:im3d/shaders/im3d.gplb" );
14693 imState.lines = CoreGraphics::ShaderGetProgram (imState.im3dShader , CoreGraphics::ShaderFeatureMask (" Static|Lines" ));
@@ -205,8 +152,6 @@ Im3dContext::Create()
205152void
206153Im3dContext::Discard ()
207154{
208- Input::InputServer::Instance ()->RemoveInputHandler (imState.inputHandler .upcast <InputHandler>());
209- imState.inputHandler = nullptr ;
210155 CoreGraphics::BufferUnmap (imState.vbo );
211156
212157 CoreGraphics::DestroyBuffer (imState.vbo );
@@ -442,7 +387,7 @@ Im3dContext::OnPrepareView(const Ptr<Graphics::View>& view, const Graphics::Fram
442387 auto const & mouse = Input::InputServer::Instance ()->GetDefaultMouse ();
443388
444389 // window origin is top-left, ndc is bottom-left
445- Math::vec2 mousePos = Math::vec2::divide (mouse->GetScreenPosition () - imState.viewPortPosition , imState.viewPortSize );
390+ Math::vec2 mousePos = Math::vec2::divide (mouse->GetPixelPosition () - imState.viewPortPosition , imState.viewPortSize );
446391
447392 mousePos *= 2 .0f ;
448393 mousePos -= Math::vec2 (1 .0f , 1 .0f );
0 commit comments