nuiDialogSelectDirectory::nuiDialogSelectDirectory(nuiMainWindow* pParent, const nglString& rTitle, const nglPath& rPath, const nglPath& rRootPath, nuiSize Left, nuiSize Top, nuiSize Width, nuiSize Height) : nuiDialog(pParent), mpParent(pParent), mPath(rPath), mEventSink(this) { mpContainer = new nuiSimpleContainer(); nuiSize userWidth = (Width == 0.f) ? mpParent->GetWidth() * .8 : Width; nuiSize userHeight = (Height == 0.f) ? mpParent->GetHeight() * .8 : Height; mpContainer->SetUserSize(userWidth, userHeight); mpSelector = new nuiFileSelector(mPath, rRootPath); mpContainer->AddChild(mpSelector); mEventSink.Connect(mpSelector->OK, &nuiDialogSelectDirectory::OnSelectorOK); nuiLabel* pTitle = new nuiLabel(rTitle); pTitle->SetObjectName(_T("nuiDialog::Title")); InitDialog(pTitle, NULL, nuiDialog::eDialogButtonOk + nuiDialog::eDialogButtonCancel); nuiButton* pButton = new nuiButton(_T("New Folder")); pButton->SetObjectName(_T("nuiDialog::Button")); AddButton(pButton, nuiDialog::eDialogButtonCustom); mEventSink.Connect(pButton->Activated, &nuiDialogSelectDirectory::OnCreateNewFolder); SetContents(mpContainer); if ((Top == 0.f) && (Left == 0.f) && (Width == 0.f) && (Height == 0.f)) SetDefaultPos(); else SetUserPos(Left, Top); mEventSink.Connect(DialogDone, &nuiDialogSelectDirectory::OnDialogDone); mpSelector->UpdateLayout(); }
void nuiDialogSelectFile::Init(nuiMainWindow* pParent, const nglString& rTitle, const nglPath& rPath, const nglPath& rRootPath, const nglString& defaultEntry, const std::list<nglString>& rFilters, bool showHiddenFiles, nuiSize Left, nuiSize Top, nuiSize Width, nuiSize Height) { mPath = rPath; mRootPath = rRootPath; nuiSimpleContainer* pEditContainer = new nuiSimpleContainer(); pEditContainer->SetBorder(16,16,10,0); mpEditLine = new nuiEditLine(); mpEditLine->SetObjectName(_T("nuiDialog::EditLine")); mpEditLine->SetObjectClass(_T("nuiDialog::EditLine")); mpEditLine->SetColor(eNormalTextFg, nuiColor(64,64,64)); mpEditLine->SetColor(eSelectedTextFg, nuiColor(64,64,64)); pEditContainer->AddChild(mpEditLine); mpContainer = new nuiSimpleContainer(); mpSelector = new nuiFileSelector(rPath, rRootPath, rFilters, mpEditLine); mpSelector->SetBorder(6,0); mEventSink.Connect(mpSelector->OK, &nuiDialogSelectFile::OnSelectorOK); nuiVBox* pBox = new nuiVBox(); mpContainer->AddChild(mpSelector); pBox->AddCell(mpContainer); pBox->AddCell(pEditContainer); nuiSize userWidth = (Width == 0.f) ? mpParent->GetWidth() * .8 : Width; nuiSize userHeight = (Height == 0.f) ? mpParent->GetHeight() * .8 : Height; mpContainer->SetUserSize(userWidth, userHeight); pBox->SetCellExpand(0, nuiExpandShrinkAndGrow); pBox->SetCellExpand(1, nuiExpandFixed); nuiLabel* pTitle = new nuiLabel(rTitle); // pTitle->SetObjectName(_T("nuiDialogSelectFile::Title")); // pTitle->SetObjectClass(_T("nuiDialogSelectFile::Title")); nuiSimpleContainer* pLayoutPane = new nuiSimpleContainer(); pLayoutPane->SetObjectClass(_T("nuiDialog::Pane")); pLayoutPane->SetObjectName(_T("nuiDialog::Pane")); pLayoutPane->SetColor(eNormalTextFg, nuiColor(0,0,0)); nuiDefaultDecoration::Dialog(pLayoutPane); InitDialog(pTitle, pLayoutPane, nuiDialog::eDialogButtonOk | nuiDialog::eDialogButtonCancel); nuiButton* pButton = new nuiButton(_T("New Folder")); pButton->SetObjectName(_T("nuiDialog::Button")); AddButton(pButton, nuiDialog::eDialogButtonCustom); mEventSink.Connect(pButton->Activated, &nuiDialogSelectFile::OnCreateNewFolder); nuiDialog::GetButtonsGrid()->SetBorder(0,10,0,10); SetContents(pBox, nuiCenter); if ((Top == 0.f) && (Left == 0.f) && (Width == 0.f) && (Height == 0.f)) SetDefaultPos(); else SetUserPos(Left, Top); mEventSink.Connect(DialogDone, &nuiDialogSelectFile::OnDialogDone); mpSelector->UpdateLayout(); mpEditLine->SetText(defaultEntry); }
bool nuiWindow::MouseMoved(nuiSize X, nuiSize Y) { nuiSize dx, dy; LocalToLocal(GetParent(), X, Y); dx = X - mClickX; dy = Y - mClickY; if (mMoving == ePreMove) { if (abs((int)dx) > WINDOW_MINIMOVE || abs((int)dy) > WINDOW_MINIMOVE) { mMoving = eMove; SetAlpha(0.5f); } else return true; } mClickX = X; mClickY = Y; if (mMoving == eMove) { nuiRect wRect = GetIdealRect(); wRect.RoundToNearest(); nuiRect woriginal = wRect; switch (mClickPos) { case nuiCenter: { wRect.Move(dx, dy); } break; case nuiTopLeft: { wRect.mTop += dy; wRect.mLeft += dx; if (wRect.GetHeight() < mMinimumHeight) wRect.mTop += wRect.GetHeight() - mMinimumHeight; if (wRect.GetWidth() < mMinimumWidth) wRect.mLeft += wRect.GetWidth() - mMinimumWidth; } break; case nuiBottomLeft: { wRect.mBottom += dy; wRect.mLeft += dx; if (wRect.GetHeight() < mMinimumHeight) wRect.SetSize(wRect.GetWidth(), mMinimumHeight); if (wRect.GetWidth() < mMinimumWidth) wRect.mLeft += wRect.GetWidth() - mMinimumWidth; } break; case nuiLeft: { wRect.mLeft += dx; if (wRect.GetWidth() < mMinimumWidth) wRect.mLeft += wRect.GetWidth() - mMinimumWidth; } break; case nuiTopRight: { wRect.mTop += dy; wRect.mRight += dx; if (wRect.GetHeight() < mMinimumHeight) wRect.mTop += wRect.GetHeight() - mMinimumHeight; if (wRect.GetWidth() < mMinimumWidth) wRect.SetSize(mMinimumWidth, wRect.GetHeight()); } break; case nuiBottomRight: { wRect.mBottom += dy; wRect.mRight += dx; if (wRect.GetWidth() < mMinimumWidth) wRect.SetSize(mMinimumWidth, wRect.GetHeight()); if (wRect.GetHeight() < mMinimumHeight) wRect.SetSize(wRect.GetWidth(), mMinimumHeight); } break; case nuiRight: { wRect.mRight += dx; if (wRect.GetWidth() < mMinimumWidth) wRect.SetSize(mMinimumWidth, wRect.GetHeight()); } break; case nuiTop: { wRect.mTop += dy; if (wRect.GetHeight() < mMinimumHeight) wRect.mTop += wRect.GetHeight() - mMinimumHeight; } break; case nuiBottom: { wRect.mBottom += dy; if (wRect.GetHeight() < mMinimumHeight) wRect.SetSize(wRect.GetWidth(), mMinimumHeight); } break; default: return true; break; } wRect.RoundToNearest(); if (mpManager) mpManager->ValidateWindowRect(wRect); if (GetRect().GetWidth() == wRect.GetWidth() && GetRect().GetHeight() == wRect.GetHeight()) SetUserPos(wRect.mLeft, wRect.mTop); else SetUserRect(wRect); return true; } else { if (IsInsideFromParent(X,Y)) { nuiRect _Rect = GetRect(); _Rect.Transform(GetMatrix()); nuiTheme* pTheme = GetTheme(); NGL_ASSERT(pTheme); mClickPos= pTheme->GetWindowPart(_Rect, X, Y, GetFlags(), false); pTheme->Release(); SetMouseCursor(eCursorDoNotSet); switch (mClickPos) { case nuiCenter: if (!mNoMove) SetMouseCursor(eCursorHand); break; case nuiTopLeft: if (!mNoResize) SetMouseCursor(eCursorResizeNW); break; case nuiBottomLeft: if (!mNoResize) SetMouseCursor(eCursorResizeSW); break; case nuiLeft: if (!mNoResize) SetMouseCursor(eCursorResizeW); break; case nuiTopRight: if (!mNoResize) SetMouseCursor(eCursorResizeNE); break; case nuiBottomRight: if (!mNoResize) SetMouseCursor(eCursorResizeSE); break; case nuiRight: if (!mNoResize) SetMouseCursor(eCursorResizeE); break; case nuiTop: if (!mNoResize) SetMouseCursor(eCursorResizeN); break; case nuiBottom: if (!mNoResize) SetMouseCursor(eCursorResizeS); break; default: break; } } } return true; // Always block mouse event that are not from this window }