GE Debugger: Actually allow swapping tabs.

This commit is contained in:
Unknown W. Brackets 2022-08-14 10:57:31 -07:00
parent 49679c6a50
commit 6272f3e1d6
5 changed files with 42 additions and 25 deletions

View File

@ -71,17 +71,6 @@ CtrlDisplayListView *CtrlDisplayListView::getFrom(HWND hwnd)
return (CtrlDisplayListView*) GetWindowLongPtr(hwnd, GWLP_USERDATA);
}
CtrlDisplayListView *CtrlDisplayListView::Create(HWND parentWnd) {
DWORD style = WS_CHILD | WS_VISIBLE | WS_BORDER;
RECT tabRect{ 0, 0, 100, 100 };
HWND hWnd = CreateWindowEx(0, windowClass, L"Display List", style,
tabRect.left, tabRect.top, tabRect.right - tabRect.left, tabRect.bottom - tabRect.top,
parentWnd, 0, MainWindow::GetHInstance(), 0);
return new CtrlDisplayListView(hWnd);
}
LRESULT CALLBACK CtrlDisplayListView::wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
CtrlDisplayListView *win = CtrlDisplayListView::getFrom(hwnd);

View File

@ -36,8 +36,6 @@ public:
static void registerClass();
static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
static CtrlDisplayListView * getFrom(HWND wnd);
static CtrlDisplayListView *Create(HWND parentWnd);
HWND GetHWND() {
return wnd;

View File

@ -421,6 +421,7 @@ void CGEDebugger::AddTab(GEDebuggerTab *tab, GETabPosition mask) {
tab->state[index].index = t->Count();
tab->state[index].ptr = tab->add(tab, t, pos, m_hInstance, m_hDlg);
tab->pos |= pos;
t->ShowTab(tab->state[index].index, true);
}
};
@ -433,10 +434,18 @@ void CGEDebugger::RemoveTab(GEDebuggerTab *tab, GETabPosition mask) {
auto doRemove = [&](GETabPosition pos, TabControl *t, GEPanelIndex pindex) {
int index = (int)pindex;
if ((tab->pos & pos) && (mask & pos)) {
_assert_(tab->state[index].ptr != nullptr);
tab->remove(tab, t, pos, tab->state[index].ptr);
auto &state = tab->state[index];
_assert_(state.ptr != nullptr);
t->RemoveTab(state.index);
for (auto &tabState : tabStates_) {
if (tabState.state[index].index > state.index)
--tabState.state[index].index;
}
tab->remove(tab, t, pos, state.ptr);
tab->pos = GETabPosition((int)tab->pos & ~(int)pos);
tab->state[index].index = -1;
state.ptr = nullptr;
state.index = -1;
}
};
@ -1125,30 +1134,42 @@ void CGEDebugger::CheckTabMessage(TabControl *t, GETabPosition pos, LPARAM lPara
int currentPanels = 0;
for (int i = 0; i < (int)GEPanelIndex::COUNT; ++i) {
if (tab && tab->state[i].index != -1 && tab->state[i].ptr)
if (tab->state[i].index != -1 && tab->state[i].ptr)
currentPanels++;
}
HMENU subMenu = GetContextMenu(ContextMenuID::GEDBG_TABS);
static const int itemIDs[] = { ID_GEDBG_SHOWONLEFT, ID_GEDBG_SHOWONRIGHT, ID_GEDBG_SHOWONTOPRIGHT };
for (int i = 0; i < (int)GEPanelIndex::COUNT; ++i) {
bool active = tab && tab->state[i].index != -1 && tab->state[i].ptr;
bool active = tab->state[i].index != -1 && tab->state[i].ptr;
bool disabled = active && currentPanels == 1;
CheckMenuItem(subMenu, itemIDs[i], active ? MF_CHECKED : MF_UNCHECKED);
EnableMenuItem(subMenu, itemIDs[i], disabled ? MF_GRAYED : MF_ENABLED);
}
auto toggleState = [&](GEPanelIndex i, GETabPosition pos) {
auto &state = tab->state[(int)i];
if (state.index != -1 && state.ptr)
RemoveTab(tab, pos);
else
AddTab(tab, pos);
RECT rc;
GetClientRect(m_hDlg, &rc);
UpdateSize(rc.right - rc.left, rc.bottom - rc.top);
};
switch (TriggerContextMenu(ContextMenuID::GEDBG_TABS, m_hDlg, ContextPoint::FromCursor())) {
case ID_GEDBG_SHOWONLEFT:
// TODO
toggleState(GEPanelIndex::LEFT, GETabPosition::LEFT);
break;
case ID_GEDBG_SHOWONRIGHT:
// TODO
toggleState(GEPanelIndex::RIGHT, GETabPosition::RIGHT);
break;
case ID_GEDBG_SHOWONTOPRIGHT:
// TODO
toggleState(GEPanelIndex::TOPRIGHT, GETabPosition::TOPRIGHT);
break;
default:

View File

@ -204,6 +204,7 @@ GenericListControl::GenericListControl(HWND hwnd, const GenericListViewDef& def)
}
GenericListControl::~GenericListControl() {
SetWindowLongPtr(handle, GWLP_USERDATA, (LONG_PTR)nullptr);
// Don't destroy the image list, it's done automatically by the list view.
}
@ -376,6 +377,8 @@ void GenericListControl::ResizeColumns()
LRESULT CALLBACK GenericListControl::wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
GenericListControl* list = (GenericListControl*) GetWindowLongPtr(hwnd,GWLP_USERDATA);
if (!list)
return FALSE;
LRESULT returnValue;
if (list->valid && list->WindowMessage(msg,wParam,lParam,returnValue) == true)

View File

@ -99,11 +99,17 @@ HWND TabControl::RemoveTab(int index) {
--currentTab;
HWND prevHandle = tabs[index].pageHandle;
TabCtrl_DeleteItem(hwnd, index);
tabs.erase(tabs.begin() + index);
if (tabs.size() == 1) {
TabCtrl_DeleteAllItems(hwnd);
tabs.clear();
currentTab = 0;
} else {
TabCtrl_DeleteItem(hwnd, index);
tabs.erase(tabs.begin() + index);
if (prevIndex == index)
ShowTab(currentTab, true);
if (prevIndex == index)
ShowTab(currentTab, true);
}
return prevHandle;
}