Exemple #1
0
nuiButton::nuiButton(const nglImage& rImage)
  : nuiSimpleContainer(), mEventSink(this)
{
  if (SetObjectClass(_T("nuiButton")))
  {
    InitAttributes();
  }
  mClicked = false;
  mPressed = false;
  mAutoRepeat = false;
  mRepeatDelay = 0.5;
  mRepeatMinDelay = 0.01;
  mpAutoRepeatTimer = NULL;
  mActivationOffset = DEFAULT_ACTIVATION_OFFSET;
  SetRedrawOnHover(true);
  EnableInteractiveDecoration(true);

  nuiImage* pImage = new nuiImage(rImage);
  AddChild(pImage);
  pImage->SetPosition(nuiCenter);
  
  SetBorders(mDefaultBorders);
  SetWantKeyboardFocus(true);
  SetFocusVisible(true);
  mpTask = NULL;
  
  NUI_ADD_EVENT(ButtonPressed);
  NUI_ADD_EVENT(ButtonDePressed);
  NUI_ADD_EVENT(ButtonDePressedInactive);
  NUI_ADD_EVENT(Activated);
}
Exemple #2
0
nuiButton::nuiButton(nuiDecoration* pDeco, bool AlreadyAcquired)
: nuiSimpleContainer(), mEventSink(this)
{
  if (SetObjectClass(_T("nuiButton")))
  {
    InitAttributes();
  }
  mClicked = false;
  mPressed = false;
  mAutoRepeat = false;
  mRepeatDelay = 0.5;
  mRepeatMinDelay = 0.01;
  mpAutoRepeatTimer = NULL;
  mActivationOffset = DEFAULT_ACTIVATION_OFFSET;
  SetRedrawOnHover(true);
  EnableInteractiveDecoration(true);
  
  SetDecoration(pDeco, eDecorationOverdraw, AlreadyAcquired);
  
  SetBorders(mDefaultBorders);
  SetWantKeyboardFocus(true);
  SetFocusVisible(true);
  mpTask = NULL;
  
  NUI_ADD_EVENT(ButtonPressed);
  NUI_ADD_EVENT(ButtonDePressed);
  NUI_ADD_EVENT(ButtonDePressedInactive);
  NUI_ADD_EVENT(Activated);
}
Exemple #3
0
nuiSlider::nuiSlider(nuiOrientation orientation, const nuiRange& rRange)
: nuiSimpleContainer(),
mRange(rRange),
mSliderSink(this)
{
  if (SetObjectClass(_T("nuiSlider")))
    InitAttributes();
  
  mOrientation = orientation;
  mClicked = false;
  mThumbClicked = false;
  mDrawBackground = true;
  mAutoAdjustHandle = true;
  mRange.SetPageSize(0);
  mInteractiveValueChanged = false;
  
  mFineSensitivityRatio = mDefaultFineSensitivityRatio;
  mFineSensitivityKey = mDefaultFineSensitivityKey;
  
  mSliderSink.Connect(mRange.Changed, &nuiSlider::DoInvalidate);
  mSliderSink.Connect(mRange.ValueChanged, &nuiSlider::DoInvalidate);
  
  mpHandle = NULL;
  mpBackground = NULL;
  SetHandleOffset(0);
  SetHandlePosMin(0);
  SetHandlePosMax(100);
  
  SetWantKeyboardFocus(true);
  
  NUI_ADD_EVENT(ValueChanged);
  NUI_ADD_EVENT(InteractiveValueChanged);
}
Exemple #4
0
nuiComboBox::nuiComboBox()
: nuiSimpleContainer(), 
  mpChoicesTree(NULL), 
  mpSelected(NULL), 
  mpOldSelected(NULL), 
  mHandleWidth(DEFAULT_HANDLE_WIDTH), 
  mHandleHeight(DEFAULT_HANDLE_HEIGHT),
  mHandleOffset(DEFAULT_HANDLE_OFFSET),
  mComboBoxEvents(this)
{
  SetObjectClass(_T("nuiComboBox"));
  SetWantKeyboardFocus(true);
}
Exemple #5
0
nuiPopupMenu::nuiPopupMenu(nuiWidget* pParent, nuiTreeNodePtr pTree, const nuiRect& rRect, bool OwnTree)
: nuiSimpleContainer(),
mPopupTreeSink(this),
mpSelectedNode(NULL),
mpNewSelectedNode(NULL),
mOwnTree(OwnTree),
mSelectionTimer(nglTime(TIMER_PERIOD)),
mScrollTimer(1.0f/15.0f),
mDelayTime(DELAY_TIME),
mpOldFocused(NULL)
{
  mTrashRemoval = false;
  SetObjectClass(_T("nuiPopupMenu"));
  nuiRect r = rRect;

  nuiTopLevel* pTop = NULL;
  if (pParent)
    pTop = pParent->GetTopLevel();
  if (pTop)
    pTop->AddChild(this);

  mpTree = pTree;
  mpTree->Acquire();
  ReparentTree(mpTree);
  mSelectedNodes.push_back(mpTree);
  mXdir = 1;
  mYdir = 1;
  if (pParent)
    pParent->LocalToGlobal(r);
  mInitialPos = r;

  mScrollUp = false;
  mPopupTreeSink.Connect(mScrollTimer.Tick, &nuiPopupMenu::OnScrollTimer);
  mPopupTreeSink.Connect(mSelectionTimer.Tick, &nuiPopupMenu::OnSelectionTimer);

  mScrolledFromKeyboard = false;
  mShowFirstNode = true;
  mWheelMoved = false;
  mFirstClick = false;

  //nuiTopLevel* pTopLevel = GetTopLevel();
  //if (pTopLevel)
  //mpOldFocused = pTopLevel->GetFocus();
  SetWantKeyboardFocus(true);
  Focus();
  //  Grab();
}
Exemple #6
0
nuiComboBox::nuiComboBox(nuiTreeNode* pChoicesTree, bool ownTree)
: nuiSimpleContainer(), 
  mpChoicesTree(pChoicesTree), 
  mpSelected(NULL), 
  mpOldSelected(NULL), 
  mHandleWidth(DEFAULT_HANDLE_WIDTH), 
  mHandleHeight(DEFAULT_HANDLE_HEIGHT),
  mHandleOffset(DEFAULT_HANDLE_OFFSET),
  mComboBoxEvents(this)
{
  SetObjectClass(_T("nuiComboBox"));

  if (mpChoicesTree)
    mpChoicesTree->Acquire();
  ReparentTree(mpChoicesTree);
  SetWantKeyboardFocus(true);
}
Exemple #7
0
void nuiKnob::Init(const nuiRange& rRange)
{
  mRange = rRange;
  mpImageSequence = NULL;
  
  mClicked = false;
  mRange.SetPageSize(0);
  mFrameIndex = 0;
  
  mSensitivity = mDefaultSensitivity;
  mFineSensitivityRatio = mDefaultFineSensitivityRatio;
  mFineSensitivityKey = mDefaultFineSensitivityKey;
  
  mKnobSink.Connect(mRange.Changed, &nuiKnob::DoInvalidate);
  //mKnobSink.Connect(mRange.ValueChanged, &nuiKnob::DoInvalidate);
  NUI_ADD_EVENT(ValueChanged);
  NUI_ADD_EVENT(InteractiveValueChanged);  
  
  mSequenceNeedRefresh = false;
  mSequenceNbFrames = 0;
  mSequenceOrientation = nuiVertical;
  
  SetWantKeyboardFocus(true);
}
Exemple #8
0
nuiCoverFlow::nuiCoverFlow()
: mSelectedImage(0),
  mBackground(0, 0, 0, 255),
  mReflectionStart(0.3),
  mReflectionEnd(0.0),
  mDrawBackground(true),
  mYOffset(0.0f),
  mSelectionYOffset(0.0f),
  mAngle(60),
  mSideShift(1.1),
  mSideGap(.19),
  mSideDepth(.7),
  mPos(0.0f),
  mLastTime(nglTime()),
  mTimer(1.0f / 30.0f),
  mFlowSink(this)
{
  if (SetObjectClass(_T("nuiCoverFlow")))
  {
    AddAttribute(new nuiAttribute<int32>
                 (nglString(_T("SelectedImage")), nuiUnitNone,
                  nuiMakeDelegate(this, &nuiCoverFlow::GetSelectedIndex), 
                  nuiMakeDelegate(this, &nuiCoverFlow::SelectImageIndex)));
    
    AddAttribute(new nuiAttribute<int32>
                 (nglString(_T("SelectedImageNow")), nuiUnitNone,
                  nuiMakeDelegate(this, &nuiCoverFlow::GetSelectedIndex), 
                  nuiMakeDelegate(this, &nuiCoverFlow::SelectImageIndexNow)));
    
    AddAttribute(new nuiAttribute<float>
                 (nglString(_T("ReflectionStart")), nuiUnitNone,
                  nuiMakeDelegate(this, &nuiCoverFlow::GetReflectionStart), 
                  nuiMakeDelegate(this, &nuiCoverFlow::SetReflectionStart)));

    AddAttribute(new nuiAttribute<float>
                 (nglString(_T("ReflectionEnd")), nuiUnitNone,
                  nuiMakeDelegate(this, &nuiCoverFlow::GetReflectionEnd), 
                  nuiMakeDelegate(this, &nuiCoverFlow::SetReflectionEnd)));

    AddAttribute(new nuiAttribute<bool>
                 (nglString(_T("DrawBackground")), nuiUnitNone,
                  nuiMakeDelegate(this, &nuiCoverFlow::GetDrawBackground), 
                  nuiMakeDelegate(this, &nuiCoverFlow::SetDrawBackground)));

    AddAttribute(new nuiAttribute<float>
                 (nglString(_T("YOffset")), nuiUnitNone,
                  nuiMakeDelegate(this, &nuiCoverFlow::GetYOffset), 
                  nuiMakeDelegate(this, &nuiCoverFlow::SetYOffset)));
    
    AddAttribute(new nuiAttribute<float>
                 (nglString(_T("SelectionYOffset")), nuiUnitNone,
                  nuiMakeDelegate(this, &nuiCoverFlow::GetSelectionYOffset), 
                  nuiMakeDelegate(this, &nuiCoverFlow::SetSelectionYOffset)));
    
    AddAttribute(new nuiAttribute<float>
                 (nglString(_T("Angle")), nuiUnitNone,
                  nuiMakeDelegate(this, &nuiCoverFlow::GetAngle), 
                  nuiMakeDelegate(this, &nuiCoverFlow::SetAngle)));
    
    AddAttribute(new nuiAttribute<float>
                 (nglString(_T("SideShift")), nuiUnitNone,
                  nuiMakeDelegate(this, &nuiCoverFlow::GetSideShift), 
                  nuiMakeDelegate(this, &nuiCoverFlow::SetSideShift)));
    
    AddAttribute(new nuiAttribute<float>
                 (nglString(_T("SideGap")), nuiUnitNone,
                  nuiMakeDelegate(this, &nuiCoverFlow::GetSideGap), 
                  nuiMakeDelegate(this, &nuiCoverFlow::SetSideGap)));
    
    AddAttribute(new nuiAttribute<float>
                 (nglString(_T("SideDepth")), nuiUnitNone,
                  nuiMakeDelegate(this, &nuiCoverFlow::GetSideDepth), 
                  nuiMakeDelegate(this, &nuiCoverFlow::SetSideDepth)));
    
    AddAttribute(new nuiAttribute<const nuiColor&>
                 (nglString(_T("BackgroundColor")), nuiUnitNone,
                  nuiMakeDelegate(this, &nuiCoverFlow::GetBackgroundColor), 
                  nuiMakeDelegate(this, &nuiCoverFlow::SetBackgroundColor)));
  }
  
  mFlowSink.Connect(mTimer.Tick, &nuiCoverFlow::OnUpdateTime);
  SetWantKeyboardFocus(true);
}