Skip to content

Commit b95f23d

Browse files
authored
Imgui multiviewport (#252)
1 parent 9a358e8 commit b95f23d

File tree

100 files changed

+2034
-1054
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+2034
-1054
lines changed

code/addons/dynui/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ fips_files(
1313
imguiinputhandler.h
1414
imguicontext.cc
1515
imguicontext.h
16+
imguidisplayeventhandler.cc
17+
imguidisplayeventhandler.h
1618
)
1719

1820
fips_dir(imgui/shaders)

code/addons/dynui/im3d/im3dcontext.cc

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -33,55 +33,6 @@ using namespace Input;
3333
namespace 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

8637
struct 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()
205152
void
206153
Im3dContext::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);

code/addons/dynui/imgui/shaders/imgui.gpul

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ vsMain(
8282
{
8383
const pos = f32x4(position, 0, 1);
8484
var projPos = ImGUI.TextProjectionModel * pos;
85-
projPos.xy -= f32x2(1.0f);
8685
vertexExportCoordinates(projPos);
8786
Color = color;
8887
UV = uv;

0 commit comments

Comments
 (0)