Skip to content

Commit

Permalink
[ImGui]Replace InputBox and Select
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGondos committed Jan 15, 2025
1 parent a27c76b commit 495ced5
Show file tree
Hide file tree
Showing 4 changed files with 205 additions and 1,084 deletions.
3 changes: 1 addition & 2 deletions Src/Orbiter/Mfd.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "Vessel.h"
#include "Element.h"
#include "Select.h"
#include <d3d.h>

#define ELN 256 // polygon resolution for orbit trajectory
#define ELNH (ELN/2)
Expand All @@ -42,8 +43,6 @@ struct MFDMODE { // MFD mode (for builtin and user-defined modes)
};

class Pane;
class InputBox;
class Select;
class oapi::GraphicsClient;

static char work_kstate[256];
Expand Down
49 changes: 6 additions & 43 deletions Src/Orbiter/Orbiter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -761,10 +761,11 @@ HWND Orbiter::CreateRenderWindow (Config *pCfg, const char *scenario)
pDlgMgr = new DialogManager (this, hRenderWnd);

// global dialog resources
InlineDialog::GlobalInit (gclient);
g_select = new Select (gclient, hRenderWnd); TRACENEW
g_input = new InputBox (gclient, hRenderWnd, 256); TRACENEW

g_select = new Select(); TRACENEW
pDlgMgr->AddEntry(g_select);
g_input = new InputBox(); TRACENEW
pDlgMgr->AddEntry(g_input);

// playback screen annotation manager
snote_playback = gclient->clbkCreateAnnotation ();
}
Expand Down Expand Up @@ -899,7 +900,6 @@ void Orbiter::CloseSession ()
snote = NULL;
nsnote = 0;
}
InlineDialog::GlobalExit (gclient);

if (g_input) { delete g_input; g_input = 0; }
if (g_select) { delete g_select; g_select = 0; }
Expand Down Expand Up @@ -1775,8 +1775,6 @@ VOID Orbiter::Output2DData ()
for (DWORD i = 0; i < nsnote; i++)
snote[i]->Render();
if (snote_playback && pConfig->CfgRecPlayPrm.bShowNotes) snote_playback->Render();
if (g_select->IsActive()) g_select->Display(0/*oclient->m_pddsRenderTarget*/);
if (g_input->IsActive()) g_input->Display(0/*oclient->m_pddsRenderTarget*/);
}
}

Expand Down Expand Up @@ -2506,10 +2504,6 @@ bool Orbiter::MouseEvent (UINT event, DWORD state, DWORD x, DWORD y)
if (event == WM_MOUSEMOVE) return false; // may be lifted later

if (bRunning) {
if (event == WM_LBUTTONDOWN || event == WM_RBUTTONDOWN) {
if (g_input && g_input->IsActive()) g_input->Close();
if (g_select && g_select->IsActive()) g_select->Clear (true);
}
if (g_pane->ProcessMouse_OnRunning (event, state, x, y, simkstate)) return true;
}
if (g_pane->ProcessMouse_System(event, state, x, y, simkstate)) return true;
Expand Down Expand Up @@ -2564,50 +2558,19 @@ LRESULT Orbiter::MsgProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
if (ImGui_ImplWin32_WndProcHandler(hWnd, uMsg, wParam, lParam))
return true;

WORD kmod;

switch (uMsg) {

case WM_ACTIVATE:
bActive = (wParam != WA_INACTIVE);
return 0;

case WM_CHAR:
if (ImGuiIO& io = ImGui::GetIO(); io.WantCaptureKeyboard) {
return 0;
}

// make dialogs modal to avoid complications
if (g_input && g_input->IsActive()) {
if (g_input->ConsumeKey (uMsg, wParam) != Select::key_ignore) bRenderOnce = TRUE;
return 0;
}
if (g_select && g_select->IsActive()) {
if (g_select->ConsumeKey (uMsg, wParam) != Select::key_ignore) bRenderOnce = TRUE;
return 0;
}
break;

// *** User Keyboard Input ***
case WM_CHAR:
case WM_KEYDOWN:
if (ImGuiIO& io = ImGui::GetIO(); io.WantCaptureKeyboard) {
return 0;
}

// modifiers
kmod = 0;
if (GetKeyState (VK_SHIFT) & 0x8000) kmod |= 0x01;
if (GetKeyState (VK_CONTROL) & 0x8000) kmod |= 0x02;

// make dialogs modal to avoid complications
if (g_input && g_input->IsActive()) {
if (g_input->ConsumeKey (uMsg, wParam, kmod) != Select::key_ignore) bRenderOnce = TRUE;
return 0;
}
if (g_select && g_select->IsActive()) {
if (g_select->ConsumeKey (uMsg, wParam, kmod) != Select::key_ignore) bRenderOnce = TRUE;
return 0;
}
break;

// Mouse event handler
Expand Down
Loading

0 comments on commit 495ced5

Please sign in to comment.