void CPropTree::EnsureVisible(CPropTreeItem* pItem) { if (!pItem) return; // item is not scroll visible (expand all parents) if (!IsItemVisible(pItem)) { CPropTreeItem* pParent; pParent = pItem->GetParent(); while (pParent) { pParent->Expand(); pParent = pParent->GetParent(); } UpdatedItems(); UpdateWindow(); } ASSERT(IsItemVisible(pItem)); CRect rc; m_List.GetClientRect(rc); rc.OffsetRect(0, m_Origin.y); rc.bottom -= pItem->GetHeight(); CPoint pt; pt = pItem->GetLocation(); if (!rc.PtInRect(pt)) { LONG oy; if (pt.y < rc.top) oy = pt.y; else oy = pt.y - rc.Height() + pItem->GetHeight(); m_List.OnVScroll(SB_THUMBTRACK, oy, NULL); } }
void MaterialPreviewPropView::OnPropertyChangeNotification(NMHDR *nmhdr, LRESULT *lresult) { idVec3 testColor; int lightId = 0; COLORREF color; NMPROPTREE *nmProp; CPropTreeItem *item; CPropTreeItem *parent; nmProp = (NMPROPTREE *)nmhdr; item = nmProp->pItem; // Determine which light this item modifies parent = item->GetParent(); if (parent) { lightId = parent->GetCtrlID(); } idStr itemLabel = item->GetLabelText(); if (itemLabel == "Model Type") { materialPreview->OnModelChange(item->GetItemValue()); } else if (itemLabel == "Custom Model") { materialPreview->OnCustomModelChange((const char *)item->GetItemValue()); } else if (itemLabel == "Show Lights") { materialPreview->OnShowLightsChange(item->GetItemValue() ? true : false); } else if (itemLabel == "Shader") { CPropTreeItemCombo *combo = (CPropTreeItemCombo *)item; CString materialName; combo->GetLBText(combo->GetCurSel(), materialName); materialPreview->OnLightShaderChange(lightId, materialName.GetBuffer()); } else if (itemLabel == "Radius") { materialPreview->OnLightRadiusChange(lightId, atof((char *)item->GetItemValue())); } else if (itemLabel == "Color") { color = item->GetItemValue(); testColor.x = (float)GetRValue(color) * (float)(1.f/255.f); testColor.y = (float)GetGValue(color) * (float)(1.f/255.f); testColor.z = (float)GetBValue(color) * (float)(1.f/255.f); materialPreview->OnLightColorChange(lightId, testColor); } else if (itemLabel == "Move light") { materialPreview->OnLightAllowMoveChange(lightId, item->GetItemValue() ? true : false); } else if (itemLabel.Left(4) == "parm") { int index; itemLabel.Strip("parm"); index = atoi(itemLabel.c_str()); materialPreview->OnLocalParmChange(index, atof((char *)item->GetItemValue())); } else if (itemLabel.Left(6) == "global") { int index; itemLabel.Strip("global"); index = atoi(itemLabel.c_str()); materialPreview->OnGlobalParmChange(index, atof((char *)item->GetItemValue())); } }