//---------------------------------------------------------------------------------------------------- bool EEProgressbar::Update() { if (!EEObject::Update()) return false; UpdateObjectState(); if (m_isPositionDirty) { m_isPositionDirty = false; } if (m_isScaleDirty || m_isLocalZOrderDirty || m_isProgressDirty) { Rect_Float rect( -m_quadWidth / 2, -m_quadHeight / 2, m_quadWidth / 2, m_quadHeight / 2 ); //the value of the z depends on the progress (the scaled end - the scaled width * (1.0f - the progress) rect.z -= (rect.z - rect.x) * (1.0f - m_progress); EEQuad2DVertex vertices[4]; vertices[0].pos = FLOAT3(rect.x, rect.y, m_localZOrder * 0.0001f); vertices[0].tex = FLOAT2(0, 0); vertices[1].pos = FLOAT3(rect.z, rect.y, m_localZOrder * 0.0001f); vertices[1].tex = FLOAT2(m_progress, 0); vertices[2].pos = FLOAT3(rect.x, rect.w, m_localZOrder * 0.0001f); vertices[2].tex = FLOAT2(0, 1); vertices[3].pos = FLOAT3(rect.z, rect.w, m_localZOrder * 0.0001f); vertices[3].tex = FLOAT2(m_progress, 1); ID3D11DeviceContext *deviceContext = EECore::s_EECore->GetDeviceContext(); D3D11_MAPPED_SUBRESOURCE mappedResource; ZeroMemory(&mappedResource, sizeof(D3D11_MAPPED_SUBRESOURCE)); deviceContext->Map(m_quadVB, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource); memcpy(mappedResource.pData, vertices, sizeof(vertices)); deviceContext->Unmap(m_quadVB, 0); if (m_isProgressDirty) { if (m_callbackFunc) { m_callbackFunc(m_progress); } } m_isScaleDirty = false; m_isLocalZOrderDirty = false; m_isProgressDirty = false; } m_progressFrame.Update(); return true; }
void CDragDropListCtrl::DropItem() { RestorePrevDropItemState(); // Drop after currently selected item. m_nDropIndex++; if (m_nDropIndex < 0 || m_nDropIndex > GetItemCount() - 1) { // Fail safe - invalid drop index, so drop at end of list. m_nDropIndex = GetItemCount(); } int nColumns = 1; CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0); if (pHeader) { nColumns = pHeader->GetItemCount(); } // »Øµ÷ if( m_callbackFunc != NULL ) { if( m_callbackFunc(m_nDropIndex, std::tr1::ref(m_anDragIndexes)) == false ) return; } // Move all dragged items to their new positions. for (int nDragItem = 0; nDragItem < m_anDragIndexes.GetSize(); nDragItem++) { int nDragIndex = m_anDragIndexes[nDragItem]; if (nDragIndex > -1 && nDragIndex < GetItemCount()) { // Get information about this drag item. char szText[256]; LV_ITEM lvItem; ZeroMemory(&lvItem, sizeof(LV_ITEM)); lvItem.iItem = nDragIndex; lvItem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE | LVIF_PARAM; lvItem.stateMask = LVIS_DROPHILITED | LVIS_FOCUSED | LVIS_SELECTED | LVIS_STATEIMAGEMASK; lvItem.pszText = szText; lvItem.cchTextMax = sizeof(szText) - 1; GetItem(&lvItem); BOOL bChecked = GetCheck(nDragIndex); // Before moving drag item, make sure it is deselected in its original location, // otherwise GetSelectedCount() will return 1 too many. SetItemState(nDragIndex, static_cast<UINT>(~LVIS_SELECTED), LVIS_SELECTED); // Insert the dragged item at drop index. lvItem.iItem = m_nDropIndex; InsertItem(&lvItem); if (bChecked) { SetCheck(m_nDropIndex); } // Index of dragged item will change if item has been dropped above itself. if (nDragIndex > m_nDropIndex) { nDragIndex++; } // Fill in all the columns for the dragged item. lvItem.mask = LVIF_TEXT; lvItem.iItem = m_nDropIndex; for (int nColumn = 1; nColumn < nColumns; nColumn++) { _tcscpy(lvItem.pszText, (LPCTSTR)(GetItemText(nDragIndex, nColumn))); lvItem.iSubItem = nColumn; SetItem(&lvItem); } // Delete the original item. DeleteItem(nDragIndex); // Need to adjust indexes of remaining drag items. for (int nNewDragItem = nDragItem; nNewDragItem < m_anDragIndexes.GetSize(); nNewDragItem++) { int nNewDragIndex = m_anDragIndexes[nNewDragItem]; if (nDragIndex < nNewDragIndex && nNewDragIndex < m_nDropIndex) { // Item has been removed from above this item, and inserted after it, // so this item moves up the list. m_anDragIndexes[nNewDragItem] = max(nNewDragIndex - 1, 0); } else if (nDragIndex > nNewDragIndex && nNewDragIndex > m_nDropIndex) { // Item has been removed from below this item, and inserted before it, // so this item moves down the list. m_anDragIndexes[nNewDragItem] = nNewDragIndex + 1; } } if (nDragIndex > m_nDropIndex) { // Item has been added before the drop target, so drop target moves down the list. m_nDropIndex++; } } } if (m_dwStyle != NULL) { // Style was modified, so return it back to original style. ModifyStyle(NULL, m_dwStyle); m_dwStyle = NULL; } }