Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef _XNV_SELECTABLE_SLIDER_1D_H_
00010 #define _XNV_SELECTABLE_SLIDER_1D_H_
00011
00012 #include "XnVPointControl.h"
00013 #include "XnVMultiItemHysteresis1D.h"
00014 #include "XnVSlider1D.h"
00015
00016 class XnVBorderScrollController1D;
00017
00024 class XNV_NITE_API XnVSelectableSlider1D :
00025 public XnVPointControl
00026 {
00027 public:
00031 typedef void (XN_CALLBACK_TYPE *ItemHoverCB)(XnInt32 nItemIndex, void* pUserCxt);
00035 typedef void (XN_CALLBACK_TYPE *ItemSelectCB)(XnInt32 nItemIndex, XnVDirection nDirection, void* pUserCxt);
00040 typedef void (XN_CALLBACK_TYPE *ScrollCB)(XnFloat fScrollValue, void* pUserCxt);
00045 typedef void (XN_CALLBACK_TYPE *ValueChangeCB)(XnFloat fValue, void* pUserCxt);
00049 typedef void (XN_CALLBACK_TYPE *OffAxisMovementCB)(XnVDirection dir, void* pUserCxt);
00050
00064 XnVSelectableSlider1D(XnInt32 nCount, XnFloat fBorderWidth = 0, XnVAxis eAxis = AXIS_X,
00065 XnBool bRecenter = TRUE,
00066 XnFloat fHysteresisRatio = XnVMultiItemHysteresis1D::ms_fDefaultHysteresisRatio,
00067 XnFloat fPrimarySliderSize = ms_fDefaultPrimarySliderSize, XnFloat fFirstValue = 0.5,
00068 const XnChar* strName = "XnVSelectableSlider1D");
00069
00070 ~XnVSelectableSlider1D();
00071
00078 void OnPrimaryPointCreate(const XnVHandPointContext* pContext, const XnPoint3D& ptFocus);
00085 void OnPrimaryPointUpdate(const XnVHandPointContext* pContext);
00091 void OnPrimaryPointDestroy(XnUInt32 nID);
00092
00093 static const XnFloat ms_fDefaultPrimarySliderSize;
00094
00103 XnCallbackHandle RegisterItemHover(void* cxt, ItemHoverCB pCB);
00112 XnCallbackHandle RegisterItemSelect(void* cxt, ItemSelectCB pCB);
00121 XnCallbackHandle RegisterScroll(void* cxt, ScrollCB pCB);
00130 XnCallbackHandle RegisterValueChange(void* cxt, ValueChangeCB pCB);
00139 XnCallbackHandle RegisterOffAxisMovement(void* cxt, OffAxisMovementCB pCB);
00140
00146 void UnregisterItemHover(XnCallbackHandle handle);
00152 void UnregisterItemSelect(XnCallbackHandle handle);
00158 void UnregisterScroll(XnCallbackHandle handle);
00164 void UnregisterValueChange(XnCallbackHandle handle);
00170 void UnregisterOffAxisMovement(XnCallbackHandle handle);
00171
00177 void ItemHover(XnInt32 nItemIndex);
00183 void ItemSelect(XnVDirection nDirection);
00189 void Scroll(XnFloat fScrollValue);
00190
00196 void Reposition(const XnPoint3D& ptCenter);
00197 void GetCenter(XnPoint3D& ptCenter) const;
00198
00204 XnUInt32 GetItemCount() const;
00210 void SetItemCount(XnUInt32 nItems);
00211
00217 XnFloat GetBorderWidth() const;
00223 XnStatus SetBorderWidth(XnFloat fWidth);
00224
00230 XnFloat GetSliderSize() const;
00236 void SetSliderSize(XnFloat fSliderSize);
00237
00243 void SetValueChangeOnOffAxis(XnBool bReport);
00247 XnBool GetValueChangeOnOffAxis() const;
00248
00255 void SetHysteresisRatio(XnFloat fRatio);
00261 XnFloat GetHysteresisRatio() const;
00262 protected:
00263 XnFloat GetFirstValue() const;
00264
00265 XnFloat GetLeftScrollRegionEnd() const;
00266 XnFloat GetRightScrollRegionEnd() const;
00267
00268 void PointCreated(const XnPoint3D& ptPos);
00269 void PointDeleted(XnBool bReason);
00270 void PointMoved(const XnPoint3D& ptPos, XnFloat fTime);
00271
00272 void SetFirstValue(XnFloat fValue);
00273
00274 void InternalCreateSlider(XnBool bPrimaryAxis, XnVAxis eAxis, const XnPoint3D& ptInitialPoint, XnFloat fInitialValue);
00275
00276
00277 void ValueChange(XnFloat fValue);
00278 void OffAxisMovement(XnVDirection dir);
00279
00280 static void XN_CALLBACK_TYPE PrimarySlider_OffAxisMovement(XnVDirection eDir, void* pContext);
00281 static void XN_CALLBACK_TYPE PrimarySlider_ValueChange(XnFloat fValue, void* pContext);
00282 static void XN_CALLBACK_TYPE SecondarySlider_OffAxisMovement(XnVDirection eDir, void* pContext);
00283 static void XN_CALLBACK_TYPE SecondarySlider_ValueChange(XnFloat fValue, void* pContext);
00284 static void XN_CALLBACK_TYPE Hysteresis_ItemSelected(XnInt32 nItem, void* pContext);
00285 static void XN_CALLBACK_TYPE OffAxisHysteresis_ItemSelected(XnInt32 nItem, void* pContext);
00286 static void XN_CALLBACK_TYPE Scroller_Scrolled(XnFloat fScrollValue, void* pContext);
00287
00288 void PrimarySlider_OffAxisMovement(XnVDirection eDir);
00289 void SecondarySlider_OffAxisMovement(XnVDirection eDir);
00290 void UpdatePrimarySlider(XnFloat fVal);
00291 void UpdateSecondarySlider(XnFloat fVal);
00292 void OffAxisHysteresis_ItemSelected(XnInt32 nItem);
00293
00294 static const XnFloat ms_fSecondarySliderSize;
00295
00296 XnVMultiItemHysteresis1D* m_pHysteresis;
00297 XnVMultiItemHysteresis1D* m_pOffAxisHysteresis;
00298 XnVBorderScrollController1D* m_pScroller;
00299
00300 XnBool m_bPositioned;
00301 XnBool m_bRecenter;
00302
00303 XnBool m_bValueChangeOnOffAxis;
00304
00305 XnVSlider1D* m_pSlider;
00306 XnVSlider1D* m_pPrimarySlider;
00307 XnVSlider1D* m_pSecondarySlider;
00308
00309
00310 XnUInt32 m_nOffAxisHandle;
00311 XnUInt32 m_nValueChangeHandle;
00312
00313 XnFloat m_fPrimarySliderSize;
00314 XnFloat m_fPrimarySliderValueAtChange;
00315
00316 XnFloat m_fFirstValue;
00317 XnBool m_bFirstPointCreated;
00318
00319 XnVAxis m_ePrimaryAxisDirection;
00320 XnUInt32 m_nItemCount;
00321
00322 XnInt32 m_nLastHover;
00323
00324 XnPoint3D m_ptCenter;
00325
00326 XnCallbackHandle m_hPrimaryHysteresisItemSelect;
00327 XnCallbackHandle m_hSecondaryHysteresisItemSelect;
00328 XnCallbackHandle m_hScrollerScroll;
00329
00330 XnCallbackHandle m_hPrimarySliderOffAxis;
00331 XnCallbackHandle m_hPrimarySliderValueChange;
00332 XnCallbackHandle m_hSecondarySliderOffAxis;
00333 XnCallbackHandle m_hSecondarySliderValueChange;
00334
00335 XnVIntSpecificEvent m_ItemHoverCBs;
00336 XnVIntDirectionSpecificEvent m_ItemSelectCBs;
00337 XnVFloatSpecificEvent m_ScrollCBs, m_ValueChangeCBs;
00338 XnVDirectionSpecificEvent m_OffAxisMovementCBs;
00339 };
00340
00341 #endif // _XNV_SELECTABLE_SLIDER_1D_H_