void GLIShaderDebug::UpdateVariableDisplay() { //Delete all existing items propTree->DeleteAllItems(); // Create the watch variables root item CPropTreeItem* pRoot; pRoot = propTree->InsertItem(new CPropTreeItem()); pRoot->SetLabelText(_T("Watch values")); pRoot->Expand(); //Loop for all watch values and add them //Add a empty watch value to enable a new one to be added CPropTreeItem* pItem; pItem = propTree->InsertItem(new CPropTreeItem(), pRoot); pItem->SetLabelText(_T("")); pItem->SetInfoText(_T("")); //Create the uniforms root item pRoot = propTree->InsertItem(new CPropTreeItem()); pRoot->SetLabelText(_T("Uniforms")); pRoot->Expand(); //Loop for all uniforms and add values of the appropiate type for(uint i=0; i<uniformValues.size(); i++) { AddVariableDisplay(pRoot, uniformValues[i]); } }
/** * Initializes the list of properties based on the type (material, stage, special stage). * @param listType The type of list (material, stage, special stage) * @param stageNum The stage from which to get the attributes. */ void MaterialPropTreeView::SetPropertyListType(int listType, int stageNum) { currentListType = listType; currentStage = stageNum; m_Tree.DeleteAllItems(); //idList<MaterialProp_t*>* propList = NULL; MaterialDefList* propList = MaterialDefManager::GetMaterialDefs(currentListType); currentPropDefs = propList; if(!propList) return; CPropTreeItem* pCurrentGroup = NULL; CPropTreeItem* pCurrentNode = NULL; for(int i = 0; i < propList->Num(); i++) { switch((*propList)[i]->type) { case MaterialDef::MATERIAL_DEF_TYPE_GROUP: { pCurrentGroup = m_Tree.InsertItem(new CPropTreeItem()); pCurrentNode = pCurrentGroup; if(!registry.GetBool(va("Expand%d%s", currentListType, (*propList)[i]->displayName.c_str()))) pCurrentGroup->Expand(); } break; case MaterialDef::MATERIAL_DEF_TYPE_BOOL: { CPropTreeItemCheck* pCheck; pCheck = (CPropTreeItemCheck*)m_Tree.InsertItem(new CPropTreeItemCheck(), pCurrentGroup); pCheck->CreateCheckBox(); pCurrentNode = pCheck; } break; case MaterialDef::MATERIAL_DEF_TYPE_STRING: { //pCurrentNode = m_Tree.InsertItem(new CPropTreeItemEdit(), pCurrentGroup); pCurrentNode = m_Tree.InsertItem(new CPropTreeItemFileEdit(), pCurrentGroup); } break; } if(pCurrentNode) { (*propList)[i]->SetViewData(PROP_TREE_VIEW, pCurrentNode->GetCtrlID()); pCurrentNode->SetLabelText((*propList)[i]->displayName); pCurrentNode->SetInfoText((*propList)[i]->displayInfo); } } RefreshProperties(); }
void CPropTreeList::OnLButtonDblClk(UINT, CPoint point) { ASSERT(m_pProp!=NULL); m_pProp->SendNotify(NM_DBLCLK); CPropTreeItem* pItem; CPropTreeItem* pOldFocus; if ((pItem = m_pProp->FindItem(point))!=NULL && pItem->GetChild()) { switch (m_pProp->HitTest(point)) { case HTCOLUMN: break; case HTCHECKBOX: pItem->Check(!pItem->IsChecked()); m_pProp->SendNotify(PTN_CHECKCLICK, pItem); Invalidate(); break; case HTATTRIBUTE: if (!pItem->IsRootLevel()) break; // pass thru to default default: pOldFocus = m_pProp->GetFocusedItem(); m_pProp->SelectItems(NULL, FALSE); m_pProp->SetFocusedItem(pItem); pItem->Select(); if (pItem!=pOldFocus) m_pProp->SendNotify(PTN_SELCHANGE, pItem); // pass thru to HTEXPAND case HTEXPAND: if (!m_pProp->SendNotify(PTN_ITEMEXPANDING, pItem)) { pItem->Expand(!pItem->IsExpanded()); UpdateResize(); Invalidate(); UpdateWindow(); CheckVisibleFocus(); } break; } } }
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); } }
//Create sample data for the preview properties void MaterialPreviewPropView::InitializePropTree(void) { int i; CPropTreeItem *pRoot; CPropTreeItem *pParmRoot; CPropTreeItemCheck *pCheck; CPropTreeItemEdit *pEdit; pRoot = m_Tree.InsertItem(new CPropTreeItem()); pRoot->SetLabelText(_T("Preview Properties")); pRoot->SetInfoText(_T("Properties for the preview window.")); pRoot->Expand(); // have this item expanded by default CPropTreeItemCombo *pCombo; pCombo = (CPropTreeItemCombo *)m_Tree.InsertItem(new CPropTreeItemCombo(), pRoot); pCombo->SetLabelText(_T("Model Type")); pCombo->SetInfoText(_T("Select the type of model on which to preview the material.")); pCombo->CreateComboBox(); pCombo->InsertString(0, "Cube"); pCombo->InsertString(1, "Box - 2:1"); pCombo->InsertString(2, "Box - 4:1"); pCombo->InsertString(3, "Box - 1:2"); pCombo->InsertString(4, "Box - 1:4"); pCombo->InsertString(5, "Cylinder - V"); pCombo->InsertString(6, "Cylinder - H"); pCombo->InsertString(7, "Sphere"); pCombo->SetItemData(0, 0); pCombo->SetItemData(1, 1); pCombo->SetItemData(2, 2); pCombo->SetItemData(3, 3); pCombo->SetItemData(4, 4); pCombo->SetItemData(5, 5); pCombo->SetItemData(6, 6); pCombo->SetItemData(7, 7); pCombo->SetCurSel(0); // Custom model entry /*pEdit = (CPropTreeItemEdit*)m_Tree.InsertItem( new CPropTreeItemEdit(), pRoot ); pEdit->SetLabelText(_T("Custom Model")); pEdit->SetInfoText(_T("Specify any model to display the current material.")); pEdit->SetItemValue((LPARAM)_T(""));*/ CPropTreeItemEditButton *pCutomButton; pCutomButton = (CPropTreeItemEditButton *)m_Tree.InsertItem(new CPropTreeItemEditButton(), pRoot); pCutomButton->SetButtonText(_T("...")); pCutomButton->SetLabelText(_T("Custom Model")); pCutomButton->SetInfoText(_T("Specify any model to display the current material.")); pCutomButton->SetItemValue((LPARAM)_T("")); // Checkbox for showing debug light spheres pCheck = (CPropTreeItemCheck *)m_Tree.InsertItem(new CPropTreeItemCheck(), pRoot); pCheck->SetLabelText(_T("Show Lights")); pCheck->SetInfoText(_T("Show the light origin sphere and number in the preview.")); pCheck->CreateCheckBox(); pCheck->SetCheckState(BST_CHECKED); // Local and Global shader parms pParmRoot = m_Tree.InsertItem(new CPropTreeItem()); pParmRoot->SetLabelText(_T("Local Parms")); pParmRoot->SetInfoText(_T("Local shaderparms for the model being displayed.")); pParmRoot->Expand(FALSE); // have this item NOT expanded by default for (i = 0; i < MAX_ENTITY_SHADER_PARMS; i++) { pEdit = (CPropTreeItemEdit *)m_Tree.InsertItem(new CPropTreeItemEdit(), pParmRoot); pEdit->SetLabelText(_T(va("parm%d", i))); pEdit->SetInfoText(_T("Set the local shaderparm for the model")); if (i < 4) { pEdit->SetItemValue((LPARAM)_T("1")); } else { pEdit->SetItemValue((LPARAM)_T("0")); } } pParmRoot = m_Tree.InsertItem(new CPropTreeItem()); pParmRoot->SetLabelText(_T("Global Parms")); pParmRoot->SetInfoText(_T("Global shaderparms for the renderworld being displayed.")); pParmRoot->Expand(FALSE); // have this item NOT expanded by default for (i = 0; i < MAX_GLOBAL_SHADER_PARMS; i++) { pEdit = (CPropTreeItemEdit *)m_Tree.InsertItem(new CPropTreeItemEdit(), pParmRoot); pEdit->SetLabelText(_T(va("global%d", i))); pEdit->SetInfoText(_T("Set the global shaderparm for the renderworld")); if (i < 4) { pEdit->SetItemValue((LPARAM)_T("1")); } else { pEdit->SetItemValue((LPARAM)_T("0")); } } // Lights pRoot = m_Tree.InsertItem(new CPropTreeItem()); pRoot->SetLabelText(_T("")); pRoot->SetInfoText(_T("")); CPropTreeItemButton *pButton; pButton = (CPropTreeItemButton *)m_Tree.InsertItem(new CPropTreeItemButton()); pButton->SetButtonText(_T(" Add Light ")); pButton->SetLabelText(_T("Preview Lights")); pButton->SetInfoText(_T("Test the button.")); pRoot = m_Tree.InsertItem(new CPropTreeItem()); pRoot->SetLabelText(_T("")); pRoot->SetInfoText(_T("")); AddLight(); }
void CPropTreeList::OnKeyDown(UINT nChar, UINT, UINT) { CPropTreeItem* pItem; ASSERT(m_pProp!=NULL); if (m_pProp->IsDisableInput() || !m_pProp->IsWindowEnabled()) return; switch (nChar) { case VK_RETURN: if ((pItem = m_pProp->GetFocusedItem())!=NULL && !pItem->IsRootLevel() && !pItem->IsReadOnly()) { pItem->Activate(); } break; case VK_HOME: if (m_pProp->FocusFirst()) Invalidate(); break; case VK_END: if (m_pProp->FocusLast()) Invalidate(); break; case VK_LEFT: if ((pItem = m_pProp->GetFocusedItem())!=NULL) { if (!m_pProp->SendNotify(PTN_ITEMEXPANDING, pItem)) { if (pItem->GetChild() && pItem->IsExpanded()) { pItem->Expand(FALSE); UpdateResize(); Invalidate(); UpdateWindow(); CheckVisibleFocus(); break; } } } else break; // pass thru to next case VK_UP case VK_UP: if (m_pProp->FocusPrev()) Invalidate(); break; case VK_RIGHT: if ((pItem = m_pProp->GetFocusedItem())!=NULL) { if (!m_pProp->SendNotify(PTN_ITEMEXPANDING, pItem)) { if (pItem->GetChild() && !pItem->IsExpanded()) { pItem->Expand(); UpdateResize(); Invalidate(); UpdateWindow(); CheckVisibleFocus(); break; } } } else break; // pass thru to next case VK_DOWN case VK_DOWN: if (m_pProp->FocusNext()) Invalidate(); break; } }
void CPropTreeList::OnLButtonDown(UINT, CPoint point) { ASSERT(m_pProp!=NULL); if (m_pProp->IsDisableInput()) return; m_pProp->SendNotify(NM_CLICK); if (!m_pProp->IsWindowEnabled()) return; SetFocus(); LONG nHit = m_pProp->HitTest(point); CPropTreeItem* pItem; CRect rc; CDC* pDC; switch (nHit) { case HTCOLUMN: if (m_pProp->SendNotify(PTN_COLUMNCLICK)) break; m_bColDrag = TRUE; SetCapture(); m_nPrevCol = m_pProp->GetOrigin().x; // paint drag line pDC = GetDC(); GetClientRect(rc); pDC->PatBlt(m_nPrevCol - PROPTREEITEM_COLRNG/2, 0, PROPTREEITEM_COLRNG, rc.bottom, PATINVERT); ReleaseDC(pDC); break; case HTCHECKBOX: if ((pItem = m_pProp->FindItem(point))!=NULL) { pItem->Check(!pItem->IsChecked()); m_pProp->SendNotify(PTN_CHECKCLICK, pItem); Invalidate(); } break; case HTEXPAND: if ((pItem = m_pProp->FindItem(point))!=NULL) { if (pItem->GetChild() && !m_pProp->SendNotify(PTN_ITEMEXPANDING, pItem)) { pItem->Expand(!pItem->IsExpanded()); UpdateResize(); Invalidate(); UpdateWindow(); CheckVisibleFocus(); } } break; default: if ((pItem = m_pProp->FindItem(point))!=NULL) { CPropTreeItem* pOldFocus = m_pProp->GetFocusedItem(); m_pProp->SelectItems(NULL, FALSE); m_pProp->SetFocusedItem(pItem); pItem->Select(); Invalidate(); if (pItem!=pOldFocus) m_pProp->SendNotify(PTN_SELCHANGE, pItem); if (nHit==HTATTRIBUTE && !pItem->IsRootLevel()) { if (!m_pProp->SendNotify(PTN_PROPCLICK, pItem) && !pItem->IsReadOnly()) pItem->Activate(); } } else { m_pProp->SelectItems(NULL, FALSE); m_pProp->SetFocusedItem(NULL); m_pProp->SendNotify(PTN_SELCHANGE); Invalidate(); } break; } }