FaberView::FaberView() : BGroupView(B_VERTICAL, 0) { fToolBar = new ToolBar(); fTracksContainer = new TracksContainer(); fInfoToolBar = new InfoToolBar(); rgb_color backgroundColor = {120,120,120}; fMenuBar = BuildMainMenuBar(); BLayoutBuilder::Group<>(this, B_VERTICAL, 0) .Add(fMenuBar) .Add(fToolBar) .AddStrut(0.0f) .AddGroup(B_VERTICAL, 0) .Add(fTracksContainer) .End() .AddStrut(10.0f) .Add(fInfoToolBar) .AddStrut(0.5f) .End(); UpdateMenu(); fTracksContainer->SetViewColor(backgroundColor); }
void Pyx::Graphics::Gui::ImGuiImpl::OnFrame() { if (m_isInitialized) { if (!m_isResourcesCreated) CreateResources(); if (m_isResourcesCreated) { auto* pRenderer = GraphicsContext::GetInstance().GetMainRenderer(); if (pRenderer) { auto& io = ImGui::GetIO(); if (Input::InputContext::GetInstance().CursorIsVisible() && pRenderer->GetAttachedWindow() == GetForegroundWindow()) { auto cursorPos = Input::InputContext::GetInstance().GetCursorPosition(); ScreenToClient(pRenderer->GetAttachedWindow(), &cursorPos); io.MousePos.x = cursorPos.x; io.MousePos.y = cursorPos.y; io.MouseDown[0] = GetAsyncKeyState(VK_LBUTTON) != 0; io.MouseDown[1] = GetAsyncKeyState(VK_RBUTTON) != 0; io.MouseDown[2] = GetAsyncKeyState(VK_MBUTTON) != 0; io.KeyCtrl = GetAsyncKeyState(VK_CONTROL) != 0; io.KeyShift = GetAsyncKeyState(VK_SHIFT) != 0; io.KeyAlt = GetAsyncKeyState(VK_MENU) != 0; } switch (pRenderer->GetRendererType()) { case RendererType::D3D9: { ImGui_ImplDX9_NewFrame(); break; } case RendererType::D3D11: { ImGui_ImplDX11_NewFrame(); break; } default: return; } if (m_isVisible) { BuildMainMenuBar(); if (m_showConsole) BuildLogsWindow(); if (m_showDebugWindow) BuildDebugWindow(); GetOnRenderCallbacks().Run(this); Scripting::ScriptingContext::GetInstance().FireCallbacks(XorStringW(L"ImGui.OnRender")); ImGui::Render(); } } static int lastToggleVisibilityTick = 0; if (GetTickCount() - lastToggleVisibilityTick > 250) { bool shouldToggleGui = true; for (auto vKey : PyxContext::GetInstance().GetSettings().GuiToggleVisibilityHotkeys) { if (GetAsyncKeyState(vKey) == NULL) { shouldToggleGui = false; break; } } if (shouldToggleGui) { ToggleVisibility(!IsVisible()); lastToggleVisibilityTick = GetTickCount(); } } static int lastToggleConsoleVisibilityTick = 0; if (GetTickCount() - lastToggleConsoleVisibilityTick > 250) { bool shouldToggleConsole = true; for (auto vKey : PyxContext::GetInstance().GetSettings().ImGuiToggleConsoleHotkeys) { if (GetAsyncKeyState(vKey) == NULL) { shouldToggleConsole = false; break; } } if (shouldToggleConsole) { m_showConsole = !m_showConsole; lastToggleConsoleVisibilityTick = GetTickCount(); } } } } }