BoolItem::BoolItem(char *newLabel, bool newValue, uint32 level, bool expanded) :BaseListItem(B_BOOL_TYPE,level,expanded) { BMessage *inputChanged = new BMessage(ITEM_CHANDED); inputChanged->AddPointer("item",this); svalue = new char[24]; value = new BCheckBox(BRect(0,0,100,10),"checker",NULL,inputChanged); value->SetValue(newValue); label = newLabel; background = ui_color(B_PANEL_BACKGROUND_COLOR); backgroundHi = ui_color(B_KEYBOARD_NAVIGATION_COLOR); foreground = ui_color(B_MENU_ITEM_TEXT_COLOR); ValueChange(); }
XnStatus XnVSlider1D::Update(const XnPoint3D& pt, XnFloat fTime, XnBool bCheckOffAxis) { if (m_pPointBuffer == NULL) { return XN_STATUS_NOT_INIT; } m_pPointBuffer->AddPoint(pt, fTime); if (bCheckOffAxis) { XnVDirection eDir = CheckForOffAxisMovement(pt, fTime); if (eDir != DIRECTION_ILLEGAL) { // Set position and value to "Last Valid" // TODO: Do in a non-crappy way m_ptCurrentPosition = m_pPointBuffer->GetAveragePointByTime(m_nOffAxisDetectionTime, fTime, 1); m_fCurrentOutput = ValueAtPosition(m_ptCurrentPosition); OffAxisMovement(eDir); // don't update values return XN_STATUS_OK; } } m_ptCurrentPosition = pt; // calculate the current value // normalize the on-axis movement according to this scale: //TODO: Off-axis motion detection XnFloat fMajorAxisPosition; switch (m_eAxis) { case AXIS_X: fMajorAxisPosition = pt.X; break; case AXIS_Y: fMajorAxisPosition = pt.Y; break; case AXIS_Z: fMajorAxisPosition = pt.Z; break; default: return XN_STATUS_NITE_UNEXPECTED_DIRECTION; } XnFloat fRelativePosition = (fMajorAxisPosition - m_fMinOutputMajorAxisPosition) / (m_fMaxOutputMajorAxisPosition - m_fMinOutputMajorAxisPosition); XnFloat fTempOutput = m_fOutputMinimum + ((m_fOutputMaximum - m_fOutputMinimum) * fRelativePosition); XnFloat fPreviousOutput = m_fCurrentOutput; // Handle dragging if enabled if ((fMajorAxisPosition > m_fMaxOutputMajorAxisPosition) && m_bIsDraggable) { XnFloat fPositionDelta = fMajorAxisPosition - m_fMaxOutputMajorAxisPosition; m_fMaxOutputMajorAxisPosition = fMajorAxisPosition; m_fMinOutputMajorAxisPosition += fPositionDelta; } else { if ((fMajorAxisPosition < m_fMinOutputMajorAxisPosition) && m_bIsDraggable) { XnFloat fPositionDelta = m_fMinOutputMajorAxisPosition - fMajorAxisPosition; m_fMaxOutputMajorAxisPosition = fMajorAxisPosition; m_fMaxOutputMajorAxisPosition -= fPositionDelta; } } m_fCurrentOutput = XN_MAX(m_fOutputMinimum, XN_MIN(m_fOutputMaximum, fTempOutput)); ValueChange(m_fCurrentOutput); return XN_STATUS_OK; } // XnVSlider1D::Update