Merge pull request #4005 from Kingcom/Debugger

More debug UI tweaks
This commit is contained in:
Henrik Rydgård 2013-10-01 01:10:19 -07:00
commit e94a67860d
6 changed files with 99 additions and 13 deletions

View File

@ -239,6 +239,7 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename)
debugConfig->Get("FontWidth", &iFontWidth, 8);
debugConfig->Get("FontHeight", &iFontHeight, 12);
debugConfig->Get("DisplayStatusBar", &bDisplayStatusBar, true);
debugConfig->Get("ShowBottomTabTitles",&bShowBottomTabTitles,true);
debugConfig->Get("ShowDeveloperMenu", &bShowDeveloperMenu, false);
IniFile::Section *gleshacks = iniFile.GetOrCreateSection("GLESHacks");
@ -395,6 +396,7 @@ void Config::Save() {
debugConfig->Set("FontWidth", iFontWidth);
debugConfig->Set("FontHeight", iFontHeight);
debugConfig->Set("DisplayStatusBar", bDisplayStatusBar);
debugConfig->Set("ShowBottomTabTitles",bShowBottomTabTitles);
debugConfig->Set("ShowDeveloperMenu", bShowDeveloperMenu);
if (!iniFile.Save(iniFilename_.c_str())) {

View File

@ -165,6 +165,7 @@ public:
int iFontWidth;
int iFontHeight;
bool bDisplayStatusBar;
bool bShowBottomTabTitles;
bool bShowDeveloperMenu;
std::string currentDirectory;

View File

@ -135,6 +135,7 @@ CDisasm::CDisasm(HINSTANCE _hInstance, HWND _hParent, DebugInterface *_cpu) : Di
stackTraceView->loadStackTrace();
bottomTabs->AddTab(stackTraceView->GetHandle(),L"Stack frames");
bottomTabs->SetShowTabTitles(g_Config.bShowBottomTabTitles);
bottomTabs->ShowTab(memHandle);
// init status bar

View File

@ -10,10 +10,15 @@ TabControl::TabControl(HWND handle): hwnd(handle), showTabTitles(true),currentTa
{
SetWindowLongPtr(hwnd,GWLP_USERDATA,(LONG_PTR)this);
oldProc = (WNDPROC) SetWindowLongPtr(hwnd,GWLP_WNDPROC,(LONG_PTR)wndProc);
hasButtons = (GetWindowLong(handle,GWL_STYLE) & TCS_BUTTONS) != 0;
}
HWND TabControl::AddTabWindow(wchar_t* className, wchar_t* title, DWORD style)
{
TabInfo info;
info.hasBorder = (style & WS_BORDER) != 0;
style = (style |WS_CHILD) & tabControlStyleMask;
if (showTabTitles)
AppendPageToControl(title);
@ -27,8 +32,15 @@ HWND TabControl::AddTabWindow(wchar_t* className, wchar_t* title, DWORD style)
HWND tabHandle = CreateWindowEx(0,className,title,style,
tabRect.left,tabRect.top,tabRect.right-tabRect.left,tabRect.bottom-tabRect.top,
GetParent(hwnd),0,MainWindow::GetHInstance(),0);
info.hasClientEdge = (GetWindowLong(tabHandle,GWL_EXSTYLE) & WS_EX_CLIENTEDGE) != 0;
if (hasButtons == false)
{
SetWindowLong(tabHandle, GWL_STYLE, GetWindowLong(tabHandle,GWL_STYLE) & (~WS_BORDER));
SetWindowLong(tabHandle, GWL_EXSTYLE, GetWindowLong(tabHandle,GWL_EXSTYLE) & (~WS_EX_CLIENTEDGE));
}
TabInfo info;
info.lastFocus = tabHandle;
info.pageHandle = tabHandle;
wcscpy(info.title,title);
tabs.push_back(info);
@ -55,11 +67,21 @@ void TabControl::AddTab(HWND handle, wchar_t* title)
TabCtrl_AdjustRect(hwnd, FALSE, &tabRect);
SetParent(handle,GetParent(hwnd));
DWORD style = (GetWindowLong(handle,GWL_STYLE) | WS_CHILD) & tabControlStyleMask;
SetWindowLong(handle, GWL_STYLE, style);
DWORD style = (GetWindowLong(handle,GWL_STYLE) | WS_CHILD);
TabInfo info;
info.hasBorder = (style & WS_BORDER) != 0;
info.hasClientEdge = (GetWindowLong(handle,GWL_EXSTYLE) & WS_EX_CLIENTEDGE) != 0;
if (hasButtons == false)
{
style &= (~WS_BORDER);
SetWindowLong(handle, GWL_EXSTYLE, GetWindowLong(handle,GWL_EXSTYLE) & (~WS_EX_CLIENTEDGE));
}
SetWindowLong(handle, GWL_STYLE, style & tabControlStyleMask);
MoveWindow(handle,tabRect.left,tabRect.top,tabRect.right-tabRect.left,tabRect.bottom-tabRect.top,TRUE);
TabInfo info;
info.lastFocus = handle;
info.pageHandle = handle;
wcscpy(info.title,title);
tabs.push_back(info);
@ -82,23 +104,48 @@ int TabControl::AppendPageToControl(wchar_t* title)
return index;
}
bool OffspringHasFocus(HWND handle)
{
HWND offspring = GetFocus();
HWND start = offspring;
while (offspring != NULL)
{
if (offspring == handle) return true;
offspring = GetParent(offspring);
// no idea if this can potentially go in circles, make sure to stop just in case
if (offspring == start) break;
}
return false;
}
void TabControl::ShowTab(int index, bool setControlIndex)
{
bool oldFocus = OffspringHasFocus(CurrentTabHandle());
if (oldFocus)
tabs[CurrentTabIndex()].lastFocus = GetFocus();
currentTab = index;
for (size_t i = 0; i < tabs.size(); i++)
{
if (oldFocus && i == index)
SetFocus(tabs[i].lastFocus);
ShowWindow(tabs[i].pageHandle,i == index ? SW_NORMAL : SW_HIDE);
}
if (setControlIndex && showTabTitles)
{
TabCtrl_SetCurSel(hwnd,index);
}
}
void TabControl::ShowTab(HWND pageHandle)
{
bool oldFocus = OffspringHasFocus(CurrentTabHandle());
if (oldFocus)
tabs[CurrentTabIndex()].lastFocus = GetFocus();
for (size_t i = 0; i < tabs.size(); i++)
{
if (tabs[i].pageHandle == pageHandle)
@ -106,6 +153,8 @@ void TabControl::ShowTab(HWND pageHandle)
currentTab = i;
if (showTabTitles)
TabCtrl_SetCurSel(hwnd,i);
if (oldFocus)
SetFocus(tabs[i].lastFocus);
}
ShowWindow(tabs[i].pageHandle,tabs[i].pageHandle == pageHandle ? SW_NORMAL : SW_HIDE);
}
@ -126,8 +175,33 @@ void TabControl::SetShowTabTitles(bool enabled)
for (int i = 0; i < (int) tabs.size(); i++)
{
AppendPageToControl(tabs[i].title);
if (hasButtons == false)
{
DWORD style = GetWindowLong(tabs[i].pageHandle,GWL_STYLE) & (~WS_BORDER);
SetWindowLong(tabs[i].pageHandle,GWL_STYLE,style);
DWORD exStyle = GetWindowLong(tabs[i].pageHandle,GWL_EXSTYLE) & (~WS_EX_CLIENTEDGE);
SetWindowLong(tabs[i].pageHandle,GWL_EXSTYLE,exStyle);
}
}
TabCtrl_SetCurSel(hwnd,CurrentTabIndex());
} else if (hasButtons == false)
{
for (int i = 0; i < (int) tabs.size(); i++)
{
if (tabs[i].hasBorder)
{
DWORD style = GetWindowLong(tabs[i].pageHandle,GWL_STYLE) | WS_BORDER;
SetWindowLong(tabs[i].pageHandle,GWL_STYLE,style);
}
if (tabs[i].hasClientEdge)
{
DWORD exStyle = GetWindowLong(tabs[i].pageHandle,GWL_EXSTYLE) | WS_EX_CLIENTEDGE;
SetWindowLong(tabs[i].pageHandle,GWL_EXSTYLE,exStyle);
}
}
}
OnResize();
@ -182,9 +256,13 @@ void TabControl::OnResize()
UpdateWindow(hwnd);
// now resize tab children
int bottom = tabRect.bottom;
TabCtrl_AdjustRect(hwnd, FALSE, &tabRect);
if (ignoreBottomMargin) tabRect.bottom = bottom;
if (showTabTitles)
{
int bottom = tabRect.bottom;
TabCtrl_AdjustRect(hwnd, FALSE, &tabRect);
if (ignoreBottomMargin) tabRect.bottom = bottom;
}
int current = CurrentTabIndex();
for (size_t i = 0; i < tabs.size(); i++)

View File

@ -28,6 +28,9 @@ private:
struct TabInfo
{
bool hasBorder;
bool hasClientEdge;
HWND lastFocus;
HWND pageHandle;
wchar_t title[128];
};
@ -38,4 +41,5 @@ private:
bool showTabTitles;
bool ignoreBottomMargin;
int currentTab;
bool hasButtons;
};

View File

@ -160,10 +160,10 @@ BEGIN
CONTROL "",IDC_LEFTTABS,"SysTabControl32",TCS_BUTTONS | TCS_FOCUSNEVER,1,63,78,15
LISTBOX IDC_FUNCTIONLIST,1,83,103,255,LBS_SORT | LBS_NOINTEGRALHEIGHT | NOT WS_VISIBLE | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "VFPU",IDC_SHOWVFPU,83,63,24,12
CONTROL "",IDC_BREAKPOINTLIST,"SysListView32",LVS_ALIGNLEFT | LVS_SHOWSELALWAYS | LVS_REPORT,1,338,513,93
CONTROL "Custom2",IDC_DEBUGMEMVIEW,"CtrlMemView",0,1,338,513,93
CONTROL "",IDC_THREADLIST,"SysListView32",LVS_ALIGNLEFT | LVS_SHOWSELALWAYS | LVS_REPORT,1,338,513,93
CONTROL "",IDC_STACKFRAMES,"SysListView32",LVS_ALIGNLEFT | LVS_SHOWSELALWAYS | LVS_REPORT,1,338,513,93
CONTROL "",IDC_BREAKPOINTLIST,"SysListView32",LVS_ALIGNLEFT | LVS_SHOWSELALWAYS | LVS_REPORT | WS_BORDER,1,338,513,93
CONTROL "Custom2",IDC_DEBUGMEMVIEW,"CtrlMemView",WS_BORDER,1,338,513,93
CONTROL "",IDC_THREADLIST,"SysListView32",LVS_ALIGNLEFT | LVS_SHOWSELALWAYS | LVS_REPORT | WS_BORDER,1,338,513,93
CONTROL "",IDC_STACKFRAMES,"SysListView32",LVS_ALIGNLEFT | LVS_SHOWSELALWAYS | LVS_REPORT | WS_BORDER,1,338,513,93
CONTROL "",IDC_DEBUG_BOTTOMTABS,"SysTabControl32",TCS_TABS | TCS_FOCUSNEVER,1,338,513,93
END