示例#1
0
void nglKernel::CallOnInit()
{
  double now = nglTime();
  ucdata_init_static();
  double then = nglTime();

  printf("ucdata_init_static took %f seconds\n", then - now);

#ifndef _MINUI3_
  NGL_DEBUG( NGL_LOG(_T("kernel"), NGL_LOG_INFO, _T("Init (%d parameter%s)"), GetArgCount(), (GetArgCount() > 1) ? _T("s") : _T("")); )
示例#2
0
// virtual 
bool nuiPadGestureRecognizer::MouseMoved(nuiSize X, nuiSize Y)
{
  bool res = nuiGestureRecognizer::MouseMoved(X, Y);
  
  if (!mClicked)
    return false;
  
	double diffx = mLastX - X;
	double diffy = mLastY - Y;
  double currentTime = nglTime();
  nuiVector v(diffx, diffy, 0);

  double l = v.Length();
  if (l > PAD_ATTENUATOR_THRESHOLD)
    mForce *= 1.0 / l;
  
  mForce += v;

  double length = mForce.Length();

  nuiVector n = mForce;
  //printf("NEW norm: %f - angle: %f\n", GetStrength(), GetDegrees());
 
  mLastX = X;
  mLastY = Y;
  

  UpdateDirection();
  
  return false;
}
示例#3
0
void MainWindow::OnButtonClick(const nuiEvent& rEvent)
{
  nglString message;
  double currentTime = nglTime();
  message.Format(_T("click time: %.2f"), currentTime);
  mMyLabel->SetText(message);
}
示例#4
0
// Received Mouse events:
bool nuiButton::MouseClicked(nuiSize X, nuiSize Y, nglMouseInfo::Flags Button)
{
  if (IsDisabled())
    return false;
  if (Button & nglMouseInfo::ButtonLeft)
  {
//    printf("clicked\n");
    mClicked = true;
    SetPressed(true);
    Invalidate();
    
    if (mAutoRepeat)
    {
      Activated();

      mLastTime = nglTime();
      mCurrentRepeatDelay = mRepeatDelay;
      mUntilRepeat = mCurrentRepeatDelay;

      if (!mpAutoRepeatTimer)
      {
        mpAutoRepeatTimer = nuiAnimation::AcquireTimer();
        mEventSink.Connect(mpAutoRepeatTimer->Tick, &nuiButton::OnAutoRepeat);
      }
    }
    return true;
  }
  return false;
}            
示例#5
0
bool MainWindow::OnButtonClick(const nuiEvent& rEvent)
{
  nglString message;
  double currentTime = nglTime();
  message.Format(_T("click time: %.2f"), currentTime);
  mMyLabel->SetText(message);
  
  return true; // means the event is caught and not broadcasted
}
示例#6
0
bool nuiInit(void* OSHandle = NULL, nuiKernel* pKernel)
{
  //printf("nuiInit(%d)\n", gNUIReferences);
  if (gNUIReferences == 0)
  {
#ifdef WIN32
    WSADATA wsaData;   // if this doesn't work
    //WSAData wsaData; // then try this instead
    // MAKEWORD(1,1) for Winsock 1.1, MAKEWORD(2,0) for Winsock 2.0:
    int res = WSAStartup(MAKEWORD(1,1), &wsaData);
#endif
    
    if (!App)
    {      
#ifdef _WIN32_
      App = new nuiManualKernel(OSHandle, pKernel);
#else
      App = new nuiManualKernel(pKernel);
#endif
      App->CallOnInit();
    }

    // On iOS, init an AutoReleasePool:
#if defined(_UIKIT_)
    nui_autoreleasepool = [[NSAutoreleasePool alloc] init];
#endif

    // Init the texture manager:
    nuiTexture::InitTextures();
    
    
    // Init the font manager:
    
#if (defined _UIKIT_) && (!TARGET_IPHONE_SIMULATOR)
    nglIMemory Memory(gpnuiPhoneFontDB, gnuiPhoneFontDBSize);
    nuiFontManager::LoadManager(Memory, nglTime());
#else
    
    nglPath fontdb(ePathUserAppSettings);
    fontdb += nglString(NUI_FONTDB_PATH);
    
    if (fontdb.Exists() && fontdb.IsLeaf())
    {
      nglIFile db(fontdb);
      nuiFontManager::LoadManager(db, fontdb.GetLastMod());
    }  
    else
    {
      nuiFontManager::GetManager();
    }
    //#endif
#endif
    
    nuiDecoration::InitDecorationEngine();
    
  }
示例#7
0
nuiMimeMultiPart::nuiMimeMultiPart(const nglString& rName, const nglString& rContentType, const nglString& rBoundary)
: mName(rName), 
  mType(rContentType),
  mBoundary(rBoundary)
{
  if (mBoundary.IsEmpty())
  {
    mBoundary.Add(_T("NuiBoundary"));
    mBoundary.Add((uint32)nglTime(), 16);
  }
}
示例#8
0
// virtual 
bool nuiSwipeGestureRecognizer::MouseUnclicked(nuiSize X, nuiSize Y, nglMouseInfo::Flags Button)
{
  bool res = nuiGestureRecognizer::MouseUnclicked(X, Y, Button);
  
  mClicked = false;
  SetState(eGestureRecognizerStatePossible);

  mTime = nglTime();
  mInitiatedTime = 0;
  mStartX = 0;
  mStartY = 0;
  Ungrab();
  
  return false;
}
示例#9
0
// virtual 
bool nuiSwipeGestureRecognizer::MouseClicked(nuiSize X, nuiSize Y, nglMouseInfo::Flags Button)
{
  bool res = nuiGestureRecognizer::MouseClicked(X, Y, Button);
 
  mRecognizedDirection = nuiGestureDirectionNull;
  
  mClicked = true;
  mTime = nglTime();
  mInitiatedTime = 0;
  mStartX = X;
  mStartY = Y;

  Grab();
  return false;
}
示例#10
0
void nuiAnimation::Play(int32 Count, nuiAnimLoop LoopMode)
{
  mCount = Count;
  mLastTime = nglTime();
  mLoopMode = LoopMode;
  if (mLoopMode == eAnimLoopReverse)
    mDirection = -1.0;
  else
    mDirection = 1.0;
  
  mAnimSink.Disconnect(GetTimer()->Tick, &nuiAnimation::OnTick);
  mAnimSink.Connect(GetTimer()->Tick, &nuiAnimation::OnTick);
  mFirstFrameSincePlay = true;

  AnimStart();
}
示例#11
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();
}
示例#12
0
void nuiCoverFlow::SelectImage(int32 index)
{
  if (index == mSelectedImage)
    return;
  
  if (index >= (int32)mImages.size())
    index = mImages.size() - 1;

  if (index < 0)
    index = 0;

  mSelectedImage = index;
  SelectionChanged();
  
  mLastTime = nglTime();
  if (!mTimer.IsRunning())
  {
    mTimer.Start();
  }
}
示例#13
0
void nuiCoverFlow::OnUpdateTime(const nuiEvent& rEvent)
{
  float diff = ((float)mSelectedImage) - mPos;
  double _t = nglTime();
  double t = _t - mLastTime;
  mLastTime = _t;
  const double TIME_RATIO = 8.0f;
  
  if (fabs(diff) < 0.001)
  {
    mPos = mSelectedImage;
    mTimer.Stop();
  }
  else
  {
    mPos += diff * t * TIME_RATIO;
  }
  
  Invalidate();
}
示例#14
0
void nuiStopWatch::AddIntermediate(const nglString& title, bool immediate)
{
  nglTime now;
  if (!immediate)
  {
    mLastTime = nglTime();
    std::pair<nglString, nglTime> point = std::make_pair(title, now);
    mIntermediatePoints.push_back(point);
    return;
  }

  double sec = (double)mLastTime - (double)now;
  nglString log("\t");
  log.Add(title).Add("\t").Add(sec).Add(" s");
  if (mOutputToLog)
  {
    NGL_LOG("StopWatch", NGL_LOG_DEBUG, "%s", log.GetChars());
  }
  else
  {
    App->TimedPrint("%s\n", log.GetChars());
  }

}
示例#15
0
/*
  NUI3 - C++ cross-platform GUI framework for OpenGL based applications
  Copyright (C) 2002-2003 Sebastien Metrot & Vincent Caron

  licence: see nui3/LICENCE.TXT
*/

#include "nui.h"

nglTime          nglPath::mMimeTypeStamp = nglTime();
nglPath::MimeMap nglPath::mMimeType;

#ifdef _CARBON_
bool nglPath::ResolveLink()
{
  if (!mPathName.IsNull())
    return false;

  bool res = false;

  FSRef ref;
  std::string str(mPathName.GetStdString());
  OSStatus status = FSPathMakeRef((const UInt8*)str.c_str(), &ref, NULL);
  if (status == noErr)
  {
    Boolean targetIsAFolder;
    Boolean wasAliased;

		OSErr err = ::FSResolveAliasFileWithMountFlags(&ref,  true, &targetIsAFolder, &wasAliased, 0);
    if ( (err == noErr) && (wasAliased) )
    {
示例#16
0
bool nuiSocket::IsIdle()
{
  if (mMaxIdleTime)
    return ((double)mLastOperationTime + (double)mMaxIdleTime) < (double)nglTime();
  return false;
}
示例#17
0
nglTime nglTimer::GetMinPeriod()
{
  return nglTime(TIMER_MIN_PERIOD);
}
示例#18
0
void nuiSocket::UpdateIdle()
{
  mLastOperationTime = nglTime();
}
示例#19
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);
}
示例#20
0
// virtual 
bool nuiSwipeGestureRecognizer::MouseMoved(nuiSize X, nuiSize Y)
{
  bool res = nuiGestureRecognizer::MouseMoved(X, Y);

  if (!mClicked)
    return false;
  
  if (GetState() == eGestureRecognizerStateEnded)
    return false;
  
	double diffx = mStartX - X;
	double diffy = mStartY - Y;
  double currentTime = nglTime();
  
  // has the swipe gesture been initiated?
  if (GetState() != eGestureRecognizerStateBegan)
  {
    bool initiatedOnX = (abs(diffx) >= SWIPE_INITIATED_THRESHOLD);
    bool initiatedOnY = (abs(diffy) >= SWIPE_INITIATED_THRESHOLD);
    
    // yes, it's been initiated.
    if (initiatedOnX || initiatedOnY)
    {
      mRecognizedDirection = GetGestureDirection(initiatedOnX, initiatedOnY, mStartX, X, mStartY, Y);

      // is this recognizer in charge of the detected gesture?
      if ((mRecognizedDirection & mDirection) 
          && ((currentTime  - mTime) < SWIPE_INITIATED_TIMEOUT))
      {
        // yes. consider that the gesture recognition has began
        mInitiatedTime = currentTime;
        SetState(eGestureRecognizerStateBegan);
      }
      // no, it's not. set data for the next call
      else
      {
        mStartX = X;
        mStartY = Y;
        mTime = currentTime;
      }
    }
  }
  
  // not yet. it's a simple "move" gesture.
  if (GetState() != eGestureRecognizerStateBegan)
    return false;
  
  // swipe has been initiated, is the gesture fully completed?
  bool activatedOnX = (abs(diffx) >= SWIPE_ACTIVATED_THRESHOLD);
  bool activatedOnY = (abs(diffy) >= SWIPE_ACTIVATED_THRESHOLD);
  
  if(activatedOnX || activatedOnY)
	{
    // the swipe gesture has been avorted. let's reset the data and start again
    if ((currentTime  - mInitiatedTime) > SWIPE_ACTIVATED_TIMEOUT)
    {
      mTime = nglTime();
      mInitiatedTime = 0;
      mStartX = X;
      mStartY = Y;
      SetState(eGestureRecognizerStateFailed);
      mRecognizedDirection = nuiGestureDirectionNull;
      
      return false;
    }
    
    // ok! the swipe gesture has been completed!
		SetState(eGestureRecognizerStateEnded);
    
    // let's assume it's no use to compute mDirection here, since it's been done when the swipe gesture has been initiated.
    // we'll see in the future if it's wrong to make that assumption.
    // mDirection = GetGesturePosition(activatedOnX, activatedOnY, mStartX, X, mStartY, Y);
    
    // send synchronous event
    SignalSwipe(mRecognizedDirection);
	}
  
  return false;
}
示例#21
0
bool nuiScrollView::MouseClicked(nuiSize X, nuiSize Y, nglMouseInfo::Flags Button)
{
  bool res = false;
  bool autoHideScrollbars = true;
  bool v = IsKeyDown(NK_LSHIFT) || IsKeyDown(NK_RSHIFT);
  if (Button & nglMouseInfo::ButtonWheelUp)
  {
    if (v)
    {
      if (mpHorizontal && !mForceNoHorizontal)
      {
        mpHorizontal->GetRange().Decrement();
        res = true;
      }
      else if (mpVertical && !mForceNoVertical)
      {
        mpVertical->GetRange().Decrement();
        res = true;
      }
    }
    else
    {
      if (mpVertical && !mForceNoVertical)
      {
        mpVertical->GetRange().Decrement();
        res = true;
      }
      else if (mpHorizontal && !mForceNoHorizontal && !mForceNoSmartScroll)
      {
        mpHorizontal->GetRange().Decrement();
        res = true;
      }
    }

  }
  else if (Button & nglMouseInfo::ButtonWheelDown)
  {
    if (v)
    {
      if (mpHorizontal && !mForceNoHorizontal)
      {
        mpHorizontal->GetRange().Increment();
        res = true;
      }
      else if (mpVertical && !mForceNoVertical)
      {
        mpVertical->GetRange().Increment();
        res = true;
      }

    }
    else
    {
      if (mpVertical && !mForceNoVertical)
      {
        mpVertical->GetRange().Increment();
        res = true;
      }
      else if (mpHorizontal && !mForceNoHorizontal && !mForceNoSmartScroll)
      {
        mpHorizontal->GetRange().Increment();
        res = true;
      }
    }
  }
  else if (Button & nglMouseInfo::ButtonWheelLeft)
  {
    if (mpHorizontal && !mForceNoHorizontal)
    {
      mpHorizontal->GetRange().Decrement();
      res = true;
    }
  }
  else if (Button & nglMouseInfo::ButtonWheelRight)
  {
    if (mpHorizontal && !mForceNoHorizontal)
    {
      mpHorizontal->GetRange().Increment();
      res = true;
    }
  }
  else if (Button & nglMouseInfo::ButtonLeft && mDragEnabled)
  {
    Grab();
    mLeftClick = true;
    mClickX = X;
    mClickY = Y;
    mLastX = X;
    mLastY = Y;
    mClickValueH = GetRange(nuiHorizontal)->GetValue();
    mClickValueV = GetRange(nuiVertical)->GetValue();
    
    if (mHideScrollBars)
    {
      ShowScrollBars();
    }

    res = true;
    autoHideScrollbars = false;
    mLastTime = nglTime();
  }
  
  if (res && mHideScrollBars)
  {
    ShowScrollBars(autoHideScrollbars);
  }
  
  return res;
}
示例#22
0
bool nuiPopupMenu::MouseMoved(nuiSize X, nuiSize Y)
{
  bool IsInside;
  int cpt = SearchRectIndex(X,Y);
  IsInside = cpt >= 0 ? true : false;
  if (IsInside)
  {
    // Do the auto scroll feature:
    nuiMenuRect* pMenuRect = mRects[cpt];
    NGL_ASSERT(pMenuRect);
    if (pMenuRect->mpSBar->IsVisible())
    {
      nuiScrollBar* pSB = pMenuRect->mpSBar;
      NGL_ASSERT(pSB);
      nuiRange& rRange(pSB->GetRange());

      if (Y > mRect.Bottom() - AUTOSCROLL_HEIGHT)
      {
        // Scroll down
        if (rRange.GetValue() + rRange.GetPageSize() < rRange.GetMaximum())
        {
          mScrollUp = false;
          if (!mScrollTimer.IsRunning())
            mScrollTimer.Start(false, false);
          return true;
        }
      }

      if (Y < AUTOSCROLL_HEIGHT)
      {
        // Scroll up
        if (rRange.GetValue() > rRange.GetMinimum())
        {
          mScrollUp = true;
          if (!mScrollTimer.IsRunning())
            mScrollTimer.Start(false, false);
          return true;
        }
      }
    }

    if (mScrollTimer.IsRunning()) // Disable scroll timer if it was still running...
      mScrollTimer.Stop();

    nuiTreeNodePtr pNode = SearchNode(X,Y,cpt);
    if (pNode)
    {
      if (pNode->GetElement()->IsDisabled())
        return true;
      if (!mSelectionTimer.IsRunning())
      {
        if ((!pNode->IsEmpty() && !pNode->IsOpened()) || 
          (mpSelectedNode && ((mpSelectedNode->GetDepth()-1 != pNode->GetDepth()-1) || mpSelectedNode->IsOpened())))
        {  //may be opened, so start the timer
          if (mpSelectedNode && mpSelectedNode != pNode)
          {
            nuiRect WidgetRect = mpSelectedNode->GetElement()->GetRect();
            nuiRect r = WidgetRect;
            nuiMenuRect*  pRect= mRects[mpSelectedNode->GetDepth()-1]; /// get the current menuRect
            nuiSize TreeHandleSize = pRect->mHasNonEmpty ? NUI_POPUP_TREE_HANDLE_SIZE : 0.f;
            r.SetSize(WidgetRect.GetWidth()+TreeHandleSize, WidgetRect.GetHeight());

            mpSelectedNode->Select(false);
            Invalidate(); //(r);
            mpSelectedNode->GetElement()->Invalidate();
          }          

          mpNewSelectedNode = pNode;

          nuiRect WidgetRect = mpNewSelectedNode->GetElement()->GetRect();
          nuiRect r = WidgetRect;
          nuiMenuRect*  pRect= mRects[mpNewSelectedNode->GetDepth()-1]; /// get the current menuRect
          nuiSize TreeHandleSize = pRect->mHasNonEmpty ? NUI_POPUP_TREE_HANDLE_SIZE : 0.f;
          r.SetSize(WidgetRect.GetWidth()+TreeHandleSize, WidgetRect.GetHeight());
          mpNewSelectedNode->Select(true);
          Invalidate(); //(r);
          mpNewSelectedNode->GetElement()->Invalidate();

          mSelectionTimer.SetPeriod(nglTime(TIMER_PERIOD));
          mSelectionTimer.Start(false);        

        }
        else
        { //empty node, no need to time this
          if (mpSelectedNode != pNode)
          {
            if (mpSelectedNode)
            {
              mpSelectedNode->Select(false);
              nuiRect WidgetRect = mpSelectedNode->GetElement()->GetRect();
              nuiRect r = WidgetRect;
              nuiMenuRect*  pRect= mRects[mpSelectedNode->GetDepth()-1]; /// get the current menuRect
              nuiSize TreeHandleSize = pRect->mHasNonEmpty ? NUI_POPUP_TREE_HANDLE_SIZE : 0.f;
              r.SetSize(WidgetRect.GetWidth()+TreeHandleSize, WidgetRect.GetHeight());
              Invalidate(); //(r);

              mpSelectedNode->GetElement()->Invalidate();
            }

            pNode->Select(true);

            nuiRect WidgetRect = pNode->GetElement()->GetRect();
            nuiRect r = WidgetRect;
            nuiMenuRect*  pRect= mRects[pNode->GetDepth()-1]; /// get the current menuRect
            uint32 dbg = pNode->GetDepth()-1;
            nuiSize TreeHandleSize = pRect->mHasNonEmpty ? NUI_POPUP_TREE_HANDLE_SIZE : 0.f;
            r.SetSize(WidgetRect.GetWidth()+TreeHandleSize, WidgetRect.GetHeight());

            Invalidate(); //(r);
            pNode->GetElement()->Invalidate();

            mpSelectedNode = pNode;
          }
        }
      }
      else
      { // Timer is active
        if (mpNewSelectedNode && pNode != mpNewSelectedNode)
        {
          nuiRect WidgetRect = mpNewSelectedNode->GetElement()->GetRect();
          nuiRect r = WidgetRect;
          nuiMenuRect*  pRect= mRects[mpNewSelectedNode->GetDepth()-1]; /// get the current menuRect
          nuiSize TreeHandleSize = pRect->mHasNonEmpty ? NUI_POPUP_TREE_HANDLE_SIZE : 0.f;
          r.SetSize(WidgetRect.GetWidth()+TreeHandleSize, WidgetRect.GetHeight());

          mpNewSelectedNode->Select(false);
          Invalidate(); //(r);
          mpNewSelectedNode->GetElement()->Invalidate();
        }
        mpNewSelectedNode = pNode;
        nuiRect WidgetRect = mpNewSelectedNode->GetElement()->GetRect();
        nuiRect r = WidgetRect;
        nuiMenuRect*  pRect= mRects[mpNewSelectedNode->GetDepth()-1]; /// get the current menuRect
        nuiSize TreeHandleSize = pRect->mHasNonEmpty ? NUI_POPUP_TREE_HANDLE_SIZE : 0.f;
        r.SetSize(WidgetRect.GetWidth()+TreeHandleSize, WidgetRect.GetHeight());

        mpNewSelectedNode->Select(true);
        Invalidate(); //(r);        
        mpNewSelectedNode->GetElement()->Invalidate();        
      }
      return true;
    }
  }    
  return false;
}
示例#23
0
void nuiPopupMenu::OnSelectionTimer(const nuiEvent& rEvent)
{
  mSelectionTimer.Stop();
  mSelectionTimer.SetPeriod(nglTime(TIMER_PERIOD));
  if (!mpNewSelectedNode || (mpSelectedNode && (mpSelectedNode == mpNewSelectedNode))) 
  {
    rEvent.Cancel();
    return;
  }

  nuiTreeNodePtr pParent = GetParentNode(mpTree, mpNewSelectedNode);
  if (pParent)
  {
    pParent->OpenAllChildren(false);
    pParent->SelectAllChildren(false);
  }
  mpNewSelectedNode->Select(true);

  if (!mpNewSelectedNode->IsEmpty())
  {
    mpNewSelectedNode->Open(true);
    if (!mpNewSelectedNode->GetChildrenCount())
    {
      mpNewSelectedNode->Open(false);
    }
    else
    {
      ResetScrolling(mpNewSelectedNode->GetDepth()-1);
      Invalidate();
      InvalidateLayout();
    }

  }

  if (mpSelectedNode)
  {
    nuiRect WidgetRect = mpSelectedNode->GetElement()->GetRect();
    nuiRect r = WidgetRect;
    nuiMenuRect*  pRect= mRects[mpSelectedNode->GetDepth()-1]; /// get the current menuRect
    nuiSize TreeHandleSize = pRect->mHasNonEmpty ? NUI_POPUP_TREE_HANDLE_SIZE : 0.f;
    r.SetSize(WidgetRect.GetWidth()+TreeHandleSize, WidgetRect.GetHeight());

    Invalidate(); //(r);
    mpSelectedNode->GetElement()->Invalidate();
  }
  if (mpNewSelectedNode)
  {
    nuiRect WidgetRect = mpNewSelectedNode->GetElement()->GetRect();
    nuiMenuRect*  pRect= mRects[mpNewSelectedNode->GetDepth()-1]; /// get the current menuRect
    nuiSize TreeHandleSize = pRect->mHasNonEmpty ? NUI_POPUP_TREE_HANDLE_SIZE : 0.f;
    nuiRect r = WidgetRect;
    r.SetSize(WidgetRect.GetWidth()+TreeHandleSize, WidgetRect.GetHeight());

    Invalidate(); //(r);
    mpNewSelectedNode->GetElement()->Invalidate();
  }

  mpSelectedNode = mpNewSelectedNode;
  FillSelectedNodes();

  //Invalidate();
  rEvent.Cancel();
}
示例#24
0
bool nuiPopupMenu::MouseUnclicked(nuiSize X, nuiSize Y, nglMouseInfo::Flags Button)
{
  if (mWheelMoved)
  {
    mWheelMoved = false;
    return true;
  }

  if (nglTime() - mStartTime < mDelayTime)
  {
    return true;
  }

  bool IsInside;
  int cpt = SearchRectIndex(X,Y);
  IsInside = cpt >= 0 ? true : false;

  if (!IsInside)
  { // Out of bounds, had to close menu
    mpTree->OpenAllChildren(false);
    mpTree->SelectAllChildren(false);
    mpSelectedNode = NULL;

    FillSelectedNodes();
    if (!MenuDone())
      Trash();
    else
      RemoveMenu();
    return true;
  }
  else 
  {
    nuiTreeNodePtr pNode = SearchNode(X,Y,cpt);
    if (pNode)
    {
      if (!pNode->IsSelectionEnabled() || pNode->GetElement()->IsDisabled())
        return true;
      if (mpSelectedNode)
      {
        mpSelectedNode->Select(false);
      }

      nuiTreeNodePtr pParent = GetParentNode(mpTree, pNode);
      if (pParent)
      {
        pParent->OpenAllChildren(false);
        pParent->SelectAllChildren(false);
      }
      mpSelectedNode = mpNewSelectedNode = pNode;
      pNode->Select(true);

      if (!pNode->IsEmpty())
      {
        pNode->Open(true);
        if (!pNode->GetChildrenCount())
          pNode->Open(false);
        else
        {
          ResetScrolling(pNode->GetDepth());         
          FillSelectedNodes();
        }
      }
      else
      {
        FillSelectedNodes();
        if (mpSelectedNode)
          mpSelectedNode->Activated();
        if (!MenuDone())
          Trash();
        else
          RemoveMenu();
      }
      Invalidate();
      InvalidateLayout();
    }
    return true;
  }
  return false;
}