Gave up with CDDS_SUBITEM; it just refuses to play nice with focus rects. Will try drawing focus rects again next commit.
This commit is contained in:
parent
4dc7f4c2de
commit
c2000ea54d
|
@ -654,10 +654,19 @@ static HRESULT drawFocusRects(uiTable *t, NMLVCUSTOMDRAW *nm)
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// normally we would only draw stuff in subitem stages
|
||||||
|
// this broke when we tried drawing focus rects in postpaint; the drawing either kept getting wiped or overdrawn, mouse hovering had something to do with it, and none of the "solutions" to this or similar problems on the internet worked
|
||||||
|
// so now we do everything in the item prepaint stage
|
||||||
|
// TODO consider switching to full-on owner draw
|
||||||
|
// TODO only compute the background brushes once?
|
||||||
|
// TODO integrate the focus rect stuff above
|
||||||
|
// TODO do hr chaining like in tablemetrics.cpp
|
||||||
HRESULT uiprivTableHandleNM_CUSTOMDRAW(uiTable *t, NMLVCUSTOMDRAW *nm, LRESULT *lResult)
|
HRESULT uiprivTableHandleNM_CUSTOMDRAW(uiTable *t, NMLVCUSTOMDRAW *nm, LRESULT *lResult)
|
||||||
{
|
{
|
||||||
struct drawState s;
|
struct drawState s;
|
||||||
uiprivTableColumnParams *p;
|
uiprivTableColumnParams *p;
|
||||||
|
NMLVCUSTOMDRAW b;
|
||||||
|
size_t i, n;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
switch (nm->nmcd.dwDrawStage) {
|
switch (nm->nmcd.dwDrawStage) {
|
||||||
|
@ -665,24 +674,18 @@ HRESULT uiprivTableHandleNM_CUSTOMDRAW(uiTable *t, NMLVCUSTOMDRAW *nm, LRESULT *
|
||||||
*lResult = CDRF_NOTIFYITEMDRAW;
|
*lResult = CDRF_NOTIFYITEMDRAW;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
case CDDS_ITEMPREPAINT:
|
case CDDS_ITEMPREPAINT:
|
||||||
*lResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NOTIFYPOSTPAINT;
|
|
||||||
return S_OK;
|
|
||||||
case CDDS_SUBITEM | CDDS_ITEMPREPAINT:
|
|
||||||
break;
|
break;
|
||||||
case CDDS_ITEMPOSTPAINT:
|
|
||||||
// draw the focus rects only at the end, so they are drawn over subitems
|
|
||||||
hr = drawFocusRects(t, nm);
|
|
||||||
if (hr != S_OK)
|
|
||||||
return hr;
|
|
||||||
*lResult = CDRF_SKIPDEFAULT;
|
|
||||||
return S_OK;
|
|
||||||
default:
|
default:
|
||||||
*lResult = CDRF_DODEFAULT;
|
*lResult = CDRF_DODEFAULT;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
p = (*(t->columns))[nm->iSubItem];
|
n = t->columns->size();
|
||||||
hr = fillDrawState(&s, t, nm, p);
|
b = *nm;
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
b.iSubItem = i;
|
||||||
|
p = (*(t->columns))[i];
|
||||||
|
hr = fillDrawState(&s, t, &b, p);
|
||||||
if (hr != S_OK)
|
if (hr != S_OK)
|
||||||
return hr;
|
return hr;
|
||||||
hr = drawBackgrounds(&s);
|
hr = drawBackgrounds(&s);
|
||||||
|
@ -706,10 +709,12 @@ HRESULT uiprivTableHandleNM_CUSTOMDRAW(uiTable *t, NMLVCUSTOMDRAW *nm, LRESULT *
|
||||||
hr = freeDrawState(&s);
|
hr = freeDrawState(&s);
|
||||||
if (hr != S_OK) // TODO really error out here?
|
if (hr != S_OK) // TODO really error out here?
|
||||||
return hr;
|
return hr;
|
||||||
|
}
|
||||||
*lResult = CDRF_SKIPDEFAULT;
|
*lResult = CDRF_SKIPDEFAULT;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
fail:
|
fail:
|
||||||
// ignore error here
|
// ignore error here
|
||||||
|
// TODO this is awkward cleanup placement for something that only really exists in a for loop
|
||||||
freeDrawState(&s);
|
freeDrawState(&s);
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
#include "uipriv_windows.hpp"
|
#include "uipriv_windows.hpp"
|
||||||
#include "table.hpp"
|
#include "table.hpp"
|
||||||
|
|
||||||
|
// TODOs
|
||||||
|
// - clicking on the same item restarts editing instead of cancels it
|
||||||
|
|
||||||
// this is not how the real list view positions and sizes the edit control, but this is a) close enough b) a lot easier to follow c) something I can actually get working d) something I'm slightly more comfortable including in libui
|
// this is not how the real list view positions and sizes the edit control, but this is a) close enough b) a lot easier to follow c) something I can actually get working d) something I'm slightly more comfortable including in libui
|
||||||
static HRESULT resizeEdit(uiTable *t, WCHAR *wstr, int iItem, int iSubItem)
|
static HRESULT resizeEdit(uiTable *t, WCHAR *wstr, int iItem, int iSubItem)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue