Esempio n. 1
0
void nuiMatrixView::Renamed(const nuiEvent& rEvent)
{
  NGL_ASSERT(rEvent.mpUser);
  nuiLabelRenamer* renamer = (nuiLabelRenamer*)rEvent.mpUser;
  nglString contents = renamer->GetText();
  contents.Trim();
  if (contents.IsEmpty())
  { 
    rEvent.Cancel();
    return;
  }
    
  double value = contents.GetCDouble();
  
  // report the new value to all selected items
  if (mSelectedItems.size() != 0)
  {
    std::map<nuiMatrixViewItem*, bool>::iterator it;
    for (it = mSelectedItems.begin(); it != mSelectedItems.end(); ++it)
    {
      nuiMatrixViewItem* item = it->first;
      item->SetValue(value);
    }
  }
  
  // report the new value to the single targeted item
  else
    mClickedItem->SetValue(value);
    
  ValueChanged();
        
  rEvent.Cancel();
}
Esempio n. 2
0
bool nuiEventSource::SendEvent(const nuiEvent& rEvent)
{
  if (IsEnabled() && !mpTargets.empty())
  {
    rEvent.SetSource(this);
    std::vector<nuiEventTargetBase*> targets(mpTargets);
    std::vector<nuiEventTargetBase*>::const_iterator it = targets.begin();
    std::vector<nuiEventTargetBase*>::const_iterator end = targets.end();

    mEnumerating++;
    bool handled = false;
    while (it != end && !handled)
    {
      nuiEventTargetBase* pETB = *it;
      if (mGraveYard.find(pETB) == mGraveYard.end())
      {
        pETB->OnEvent(rEvent);
        handled = rEvent.IsCanceled();
      }
      ++it;
    }

    mEnumerating--;
    mGraveYard.clear();
    return handled;
  }

  return false;
}
Esempio n. 3
0
bool nuiEventTargetBase::CallEvent(void* pTarget, nuiDelegateMemento pFunc, const nuiEvent& rEvent)
{
  Delegate del;
  del.SetMemento(pFunc);
  del(rEvent);
  return rEvent.IsCanceled();
}
Esempio n. 4
0
void ThreadInspectorTest::CreateLLThread(const nuiEvent& rEvent)
{
  // create thread
  nglString name;
  name.Format(_T("LLtest%d"), mThreadCount);
  mThreadCount++;
  TITLLthread* pThread = new TITLLthread(name);

  // create UI control in the list
  nuiHBox* pBox = new nuiHBox(0);
  mpLLList->AddChild(pBox);
  pBox->SetBorder(0, 3);

  // store the relation widget box -> thread
  mLLThreads[pBox] = pThread;

  pThread->Start();

  nglString label;
  label.Format(_T("LLthread '%ls' [0x%x]"), pThread->GetName().GetChars(), pThread->GetID());
  nuiLabel* pLabel = new nuiLabel(label);
  pBox->AddCell(pLabel);

  pBox->AddCell(pThread->InitGUI());

  rEvent.Cancel();
}
Esempio n. 5
0
void MainWindow::OnButtonPressed(const nuiEvent& rEvent)
{
  NGL_OUT("MainWindow::OnButtonPressed");
  int64 tag = (int64)rEvent.mpUser;

  nglString msg;

  switch (tag)
  {
    case TAG_BUTTON1:
      msg = _T("a simple button\nwith a 'nuiCenter' position");
      break;
    case TAG_BUTTON2:
      msg = _T("the same simple button\nbut with a 'nuiFill' position");
      break;
    case TAG_BUTTON3:
      msg = _T("a simple button\nwith an image inside");
      break;
    case TAG_BUTTON4:
      msg = _T("a rollover button\nusing three decorations");
      break;
  }

  mpLabel->SetText(msg);

  rEvent.Cancel();
}
Esempio n. 6
0
void MainWindow::OnTogglePressed(const nuiEvent& rEvent)
{
  NGL_OUT("MainWindow::OnTogglePressed");
  int64 tag = (int64)rEvent.mpUser;

  nglString msg;

  switch (tag)
  {
    case TAG_TOGGLEBUTTON1:
      msg = _T("a simple togglebutton, pressed");
      break;
    case TAG_TOGGLEBUTTON2:
      msg = _T("a simple togglebutton, released");
      break;
    case TAG_TOGGLEBUTTON3:
      msg = _T("a checkbox, pressed");
      break;
    case TAG_TOGGLEBUTTON4:
      msg = _T("a checkbox, released");
      break;
  }

  mpLabel->SetText(msg);

  rEvent.Cancel();
}
Esempio n. 7
0
void ProjectGenerator::OnSourceTextChanged(const nuiEvent& rEvent)
{
  mpTimer->Stop();
  mpTimer->Start(false);
    
  rEvent.Cancel();
}
Esempio n. 8
0
void MainWindow::OnMenuCommand(const nuiEvent& rEvent)
{
  uint64 ID = (uint64)rEvent.mpUser;
  nglString msg;
  msg.Format(_T("event item New%d"), ID);
  MyCommand(msg);
  rEvent.Cancel();
}
Esempio n. 9
0
void ProjectGenerator::OnBrowseTarget(const nuiEvent& rEvent)
{
  nglPath path = nglPath(mProjectTargetPath).GetParent();
  
  nuiDialogSelectDirectory* pDialog = new nuiDialogSelectDirectory(GetMainWindow(), _T("ENTER THE NEW PROJECT TARGET"), path, nglPath(_T("/")));
  mEventSink.Connect(pDialog->DirectorySelected, &ProjectGenerator::OnTargetSelected, (void*)pDialog);
  rEvent.Cancel();
}
Esempio n. 10
0
void nuiPopupMenu::OnScrollBarChange(const nuiEvent& rEvent)
{
  nuiMenuRect* pMenuRect = (nuiMenuRect*)(rEvent.mpUser);

  if (mScrolledFromKeyboard)
  {
    mScrolledFromKeyboard = false;
    rEvent.Cancel();
    return;
  }
  pMenuRect->mpFromNode->OpenAllChildren(false);
  pMenuRect->mpFromNode->SelectAllChildren(false);

  Invalidate();
  InvalidateLayout();
  rEvent.Cancel();
}
Esempio n. 11
0
void ProjectGenerator::OnTargetSelected(const nuiEvent& rEvent)
{
  nuiDialogSelectDirectory* pDialog = (nuiDialogSelectDirectory*)rEvent.mpUser;
  mProjectTargetPath = pDialog->GetSelectedDirectory();
  mpProjectTarget->SetText(mProjectTargetPath);
  
  nglPath path(mProjectTargetPath);
  
  OnTargetTextChanged(rEvent);
  if (!rEvent.IsCanceled())
  {
    rEvent.Cancel();
    return;
  }
  
  GetPreferences().SetString(PREFERENCES_PROJECTGENERATOR, _T("nuiTargetPath"), path.GetParent().GetPathName());  
}
Esempio n. 12
0
void TimeLabel::OnTimerTick(const nuiEvent& rEvent)
{
  nglString text(GetPosition());
  text += (_T(" / "));
  text += GetLength();
  
  SetText(text);
  rEvent.Cancel();
}
Esempio n. 13
0
void FrameEditor::OnFrameMouseMoved(const nuiEvent& rEvent)
{
	nuiMouseMovedEvent* pEvent = (nuiMouseMovedEvent*)&rEvent;
	// set the information nuiAttribute. It will automatically update the gui
	nuiPoint point(pEvent->mX, pEvent->mY);

	GetMainWindow()->mAttributeMouseCoord.Set(point);
  rEvent.Cancel();
}
Esempio n. 14
0
void nuiColorSelector::SwatchSelected(const nuiEvent& rEvent)
{
  nuiPane* pPane = (nuiPane*) rEvent.mpUser;
  SetCurrentColor(pPane->GetFillColor());
  
  // send event
  SwatchColorChanged(); 
  rEvent.Cancel();
}
Esempio n. 15
0
void MainWindow::OnRadioPressed(const nuiEvent& rEvent)
{
  int64 index = (int64)rEvent.mpUser;

  nglString msg;
  msg.Format(_T("radio button #%d"), index);
  mpLabel->SetText(msg);

  rEvent.Cancel();
}
Esempio n. 16
0
void nuiDialogSelectFile::OnDialogDone(const nuiEvent& rEvent)
{
  nuiDialog::DialogResult result = GetResult();
  
  if (result == nuiDialog::eDialogAccepted)
  {
    OnSelectorOK(rEvent);
    rEvent.Cancel();
  }
}
Esempio n. 17
0
void MainWindow::OnItemActivated(const nuiEvent& rEvent)
{
  uint32 token;
  nuiGetTokenValue<uint32>(mpList->GetSelectedToken(), token);
  
  nglString message;
  message.Format(_T("activated item num %d"), token);
  mpOutput->SetText(message);

  rEvent.Cancel();
}
Esempio n. 18
0
//
// just a trick to make the two scrollbars move together
//
void MainWindow::OnScrollbarMoved(const nuiEvent& rEvent)
{
  // get the scrollbar given as the event's user parameter
  nuiScrollView* pView = (nuiScrollView*)rEvent.mpUser;
  
  // guess who is the other scrollbar
  nuiScrollView* pOtherView = (pView == mpViews[0])? mpViews[1] : mpViews[0];
  
  // ask the other one to take the position that the first one is giving
  pOtherView->GetScrollBar(nuiVertical)->GetRange().SetValue(pView->GetScrollBar(nuiVertical)->GetRange().GetValue());
  rEvent.Cancel();
}
Esempio n. 19
0
bool nuiEventSource::SendEvent(const nuiEvent& rEvent)
{
  if (IsEnabled() && !mpTargets.empty())
  {
    rEvent.SetSource(this);
    std::vector<nuiEventTargetBase*> targets(mpTargets);
    std::vector<nuiEventTargetBase*>::const_iterator it = targets.begin();
    std::vector<nuiEventTargetBase*>::const_iterator end = targets.end();

    bool handled = false;
    while (it != end && !handled)
    {
      ((*it)->OnEvent(rEvent));
      handled = rEvent.IsCanceled();
      ++it;
    }

    return handled;
  }

  return false;
}
Esempio n. 20
0
void nuiColorSelector::RGBSliderChanged(const nuiEvent& rEvent)
{
  nuiSize red = (float)mpRedSlider->GetRange().GetValue();
  nuiSize green = (float)mpGreenSlider->GetRange().GetValue();
  nuiSize blue = (float)mpBlueSlider->GetRange().GetValue();
  nuiSize alpha = (float)mpRGBAlphaSlider->GetRange().GetValue();
  
  SetCurrentColor(nuiColor(red, green, blue, alpha));
  
  // send event
  RGBColorChanged();
  
  rEvent.Cancel();
}
Esempio n. 21
0
void ThreadInspectorTest::RemoveLLThread(const nuiEvent& rEvent)
{
  nuiWidget* pWidget = mpLLList->GetSelected();
  if (!pWidget)
  {
    rEvent.Cancel();
    return;
  }

  // retrieve thread associated to the selected widget from the list
  std::map<nuiWidget*, TITLLthread*>::iterator it = mLLThreads.find(pWidget);
  NGL_ASSERT(it != mLLThreads.end());

  // request stop to the thread
  TITLLthread* pThread = it->second;
  pThread->Stop();

  // clean
  delete pThread;
  mpLLList->DelChild(pWidget);
  mLLThreads.erase(it);

  rEvent.Cancel();
}
Esempio n. 22
0
void MainWindow::OnAddItem(const nuiEvent& rEvent)
{
  uint32 ID = mUniqueID;
  mUniqueID++;

  nglString name;
  name.Format(_T("New%d"), ID);
  nuiMainMenuItem* pNew = new nuiMainMenuItem(name);
  mpCurrentTestMenu->AddChild(pNew);
  mEventSink.Connect(pNew->Activated, &MainWindow::OnMenuCommand, (void*)ID);

  mpLastItem = pNew;

  rEvent.Cancel();
}
Esempio n. 23
0
void ProjectGenerator::OnBrowseSource(const nuiEvent& rEvent)
{
  mNuiSourcePath.Trim();
  if (mNuiSourcePath == nglString::Null)
  {
    nglPath path(ePathUser);
    mNuiSourcePath = path.GetPathName();
  }

  nuiDialogSelectDirectory* pDialog = new nuiDialogSelectDirectory(GetMainWindow(), _T("SELECT THE NUI SOURCE DIRECTORY"), mNuiSourcePath, nglPath(_T("/")));
  mEventSink.Connect(pDialog->DirectorySelected, &ProjectGenerator::OnSourceSelected, (void*)pDialog);
  
  rEvent.Cancel();
  return;
}
Esempio n. 24
0
void nuiColorSelector::HSVSliderChanged(const nuiEvent& rEvent)
{
  nuiSize h = (float)mpHueSlider->GetRange().GetValue();
  nuiSize s = (float)mpSaturationSlider->GetRange().GetValue();
  nuiSize v = (float)mpValueSlider->GetRange().GetValue();
  nuiSize alpha = (float)mpHSVAlphaSlider->GetRange().GetValue();
  
  nuiColor c;
  c.SetHSV(h, s, v, alpha);
  SetCurrentColor(c);
  
  // send event
  HSVColorChanged();
  
  rEvent.Cancel();
}
Esempio n. 25
0
void ProjectGenerator::OnIconUpdate(const nuiEvent& rEvent)
{
  nuiToggleButton* pBtn = (nuiToggleButton*)rEvent.mpUser;
  nuiImage* pIcon;
  nglString objectName;
  
  nuiGetTokenValue<nuiImage*>(pBtn->GetToken(), pIcon);
  nuiGetTokenValue<nglString>(pIcon->GetToken(), objectName);
  
  if (!pBtn->IsPressed())
    objectName += nglString(_T("::Disabled"));

  pIcon->SetObjectName(objectName);
  
  rEvent.Cancel();
}
Esempio n. 26
0
void ProjectGenerator::OnTargetTextChanged(const nuiEvent& rEvent)
{
  nglString text = mpProjectTarget->GetText();
  text.Trim();
  
  mpIconProjectDirectory->SetObjectName(_T("Icon::ProjectDirectory"));
  
  nglPath path(text);
  
  nglString newtext = text + _T("/") + path.GetNodeName() + _T(".xcodeproj");
  mpProjectFilename->SetText(newtext);
  
  mpTimer->Stop();
  mpTimer->Start(false);
  
  rEvent.Cancel();
}
Esempio n. 27
0
//
// launch the threads
//
void MainWindow::OnStart(const nuiEvent& rEvent)
{
  mLabels[0] = _T("THREAD1 : hey I wanna play!\n");
  mLabels[1] = _T("THREAD2 : yeah, let's play ping pong!\n");

  mpThread1 = new MessageQueueThread(0);
  mpThread2 = new MessageQueueThread(1);
  
  mpThread1->SetInterlocutor(mpThread2); // thread1 will send the messages to thread2
  mpThread2->SetInterlocutor(mpThread1); // thread2 will send the messages to thread1
  
  // launch the threads    
  mpThread1->Start();
  mpThread2->Start();  
  
  rEvent.Cancel();
}
Esempio n. 28
0
void nuiFileTree::OnNodeActivated(const nuiEvent& rEvent)
{
  nuiFileSelectorNode* pNode = (nuiFileSelectorNode*)rEvent.mpUser;
  nglPath path(pNode->GetProperty(_T("Path")));
  
  mActivatedPath = path;
  
  // send signal
  bool res = Activated();
  
  if (!res && !path.IsLeaf() && !path.IsBundle())
  {
    SetRootPath(path);
    SetPath(path);    
  }
  
  rEvent.Cancel();
}
Esempio n. 29
0
void nuiColorSelector::OnTabSelected(const nuiEvent& rEvent)
{
  uint tabIndex = mpTabView->GetSelectedTab();
  switch (tabIndex)
  {
    case 0: //RGB
      Tab_RGB_Update();
      break;
    case 1: //HSV
      Tab_HSV_Update();
      break;
    case 2: //Swatches
      break;
    default:
      break;
  }
  rEvent.Cancel();
}
Esempio n. 30
0
void nuiFileTree::OnGotoParentFolder(const nuiEvent& rEvent)
{
  nglPath path = mRootPath;
 
  nglPath parent = mRootPath.GetParent();
  
   // hack to see "/Volumes" as the ROOTPATH_ALLVOLUMES
  if ((mRootPath.GetPathName() == _T("/")) || ((mRootPath.GetPathName().GetLength() > 1) && (mRootPath.GetPathName().Extract(mRootPath.GetPathName().GetLength()-2, 2) == _T(":/"))))
  {
    parent = ROOTPATH_ALLVOLUMES;
    path = nglPath(_T("/"));
  }
  
  SetRootPath(parent);
  
  SetPath(path);
  
  rEvent.Cancel();
}