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(); }
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(); }
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(); }
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(); }
void ProjectGenerator::OnSourceTextChanged(const nuiEvent& rEvent) { mpTimer->Stop(); mpTimer->Start(false); rEvent.Cancel(); }
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(); }
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(); }
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(); }
void TimeLabel::OnTimerTick(const nuiEvent& rEvent) { nglString text(GetPosition()); text += (_T(" / ")); text += GetLength(); SetText(text); rEvent.Cancel(); }
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(); }
void nuiColorSelector::SwatchSelected(const nuiEvent& rEvent) { nuiPane* pPane = (nuiPane*) rEvent.mpUser; SetCurrentColor(pPane->GetFillColor()); // send event SwatchColorChanged(); rEvent.Cancel(); }
void nuiDialogSelectFile::OnDialogDone(const nuiEvent& rEvent) { nuiDialog::DialogResult result = GetResult(); if (result == nuiDialog::eDialogAccepted) { OnSelectorOK(rEvent); rEvent.Cancel(); } }
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(); }
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(); }
// // 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(); }
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(); }
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(); }
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(); }
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; }
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(); }
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(); }
// // 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(); }
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()); }
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(); }
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(); }
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(); }
void nuiDialogSelectDirectory::OnCreateNewFolder(const nuiEvent& rEvent) { mpCreateDialog = new nuiDialog(mpParent); nuiSimpleContainer* pContainer = new nuiSimpleContainer(); pContainer->SetUserSize(400, 80); mpCreateEditLine = new nuiEditLine(); mpCreateEditLine->SetPosition(nuiFillHorizontal); pContainer->AddChild(mpCreateEditLine); mpCreateDialog->InitDialog(_T("CREATE A NEW FOLDER"), NULL, nuiDialog::eDialogButtonOk + nuiDialog::eDialogButtonCancel); mpCreateDialog->SetContents(pContainer); mpCreateDialog->SetDefaultPos(); mEventSink.Connect(mpCreateDialog->DialogDone, &nuiDialogSelectDirectory::OnCreateNewFolderDone); mpCreateEditLine->Focus(); rEvent.Cancel(); }
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(); }
// // ask the threads to stop and wait for them to do so // void MainWindow::OnStop(const nuiEvent& rEvent) { if (mpThread1 && mpThread2) { mpThread1->Post(new nuiNotification (NOTIF_KILL)); mpThread2->Post(new nuiNotification (NOTIF_KILL)); mpThread1->Join(); mpThread2->Join(); delete mpThread1; delete mpThread2; mpThread1 = NULL; mpThread2 = NULL; } rEvent.Cancel(); }
void nuiTabBar::OnTabSelected(const nuiEvent& rEvent) { if (!(IsKeyDown(NK_LCTRL) || IsKeyDown(NK_RCTRL))) { std::list<nuiTab*>::const_iterator end = mSelectedTabs.end(); for (std::list<nuiTab*>::const_iterator it = mSelectedTabs.begin(); it != end; ++it) { (*it)->SetSelected(false); } mSelectedTabs.clear(); } nuiTab *tab = (nuiTab*)rEvent.mpUser; tab->SetSelected(true); mSelectedTabs.push_back(tab); Invalidate(); TabsSelected(mSelectedTabs); rEvent.Cancel(); }