示例#1
0
//----------------------------------------------------------------------------------------------------
void UIDialogController::run (UTF8StringPtr _templateName, UTF8StringPtr _dialogTitle, UTF8StringPtr _button1, UTF8StringPtr _button2, IController* _dialogController, UIDescription* _description)
{
	collectOpenGLViews (frame);

	templateName = _templateName;
	dialogTitle = _dialogTitle;
	dialogButton1 = _button1;
	dialogButton2 = _button2 != 0 ? _button2 : "";
	dialogController = dynamic_cast<CBaseObject*> (_dialogController);
	dialogDescription = _description;
	CView* view = UIEditController::getEditorDescription ().createView ("dialog", this);
	if (view)
	{
		CRect size = view->getViewSize ();
		size.right += sizeDiff.x;
		size.bottom += sizeDiff.y;
		CRect frameSize = frame->getViewSize ();
		size.centerInside (frameSize);
		size.makeIntegral ();
		view->setViewSize (size);
		view->setMouseableArea (size);

		frame->setModalView (view);
		frame->registerKeyboardHook (this);
		if (button1)
			frame->setFocusView (button1);
		setOpenGLViewsVisible (false);
		dialogController->notify (this, kMsgDialogShow);
	}
	else
	{
		forget ();
	}
}
示例#2
0
	void valueChanged (CControl* pControl)
	{
		if (pControl->getValue ())
		{
			switch (pControl->getTag ())
			{
				case 0:
				{
					CView* view = desc->createView ("ModalView", this);
					if (view)
					{
						CFrame* frame = pControl->getFrame ();
						CPoint center = frame->getViewSize ().getCenter ();
						CRect viewSize = view->getViewSize ();
						viewSize.offset (center.x - viewSize.getWidth () / 2, center.y - viewSize.getHeight () / 2);
						view->setViewSize (viewSize);
						view->setMouseableArea (viewSize);
						frame->setModalView (view);
						view->setAlphaValue (0.f);
						view->addAnimation ("AlphaAnimation", new Animation::AlphaValueAnimation (1.f), new Animation::PowerTimingFunction (240, 2));
						pControl->setValue (0);
						view->forget ();
					}
					break;
				}
				case 1:
				{
					CView* modalView = pControl->getFrame ()->getModalView ();
					modalView->addAnimation ("AlphaAnimation", new RemoveModalViewAnimation (0.f), new Animation::PowerTimingFunction (240, 0.5));
					pControl->setMouseEnabled (false);
					break;
				}
			}
		}
	}
示例#3
0
文件: uiactions.cpp 项目: EQ4/vstgui
//-----------------------------------------------------------------------------
void ViewSizeChangeOperation::undo ()
{
	selection->empty ();
	iterator it = begin ();
	while (it != end ())
	{
		CView* view = (*it).first;
		CRect size ((*it).second);
		view->invalid ();
		(*it).second = view->getViewSize ();
		CViewContainer* container = 0;
		bool oldAutosizing = false;
		if (!autosizing)
		{
			container = dynamic_cast<CViewContainer*> (view);
			if (container)
			{
				oldAutosizing = container->getAutosizingEnabled ();
				container->setAutosizingEnabled (false);
			}
		}
		view->setViewSize (size);
		view->setMouseableArea (size);
		view->invalid ();
		selection->add (view);
		if (!autosizing && container)
		{
			container->setAutosizingEnabled (oldAutosizing);
		}
		it++;
	}
}
示例#4
0
//----------------------------------------------------------------------------------------------------
void UIDialogController::viewSizeChanged (CView* view, const CRect& oldSize)
{
	if (view == frame)
	{
		CView* dialog = frame->getModalView ();
		CRect viewSize = dialog->getViewSize ();
		viewSize.centerInside (frame->getViewSize ());
		dialog->setViewSize (viewSize);
		dialog->setMouseableArea (viewSize);
	}
}
示例#5
0
文件: uiactions.cpp 项目: EQ4/vstgui
//-----------------------------------------------------------------------------
void EmbedViewOperation::undo ()
{
	selection->empty ();
	CRect parentRect = newContainer->getViewSize ();
	const_reverse_iterator it = rbegin ();
	while (it != rend ())
	{
		CView* view = (*it).first;
		newContainer->removeView (view, false);
		CRect r = (*it).second;
		view->setViewSize (r);
		view->setMouseableArea (r);
		parent->addView (view);
		selection->add (view);
		it++;
	}
	parent->removeView (newContainer);
}
示例#6
0
//----------------------------------------------------------------------------------------------------
void UIDialogController::run (UTF8StringPtr _templateName, UTF8StringPtr _dialogTitle, UTF8StringPtr _button1, UTF8StringPtr _button2, IController* _dialogController, UIDescription* _description)
{
	collectOpenGLViews (frame);

	templateName = _templateName;
	dialogTitle = _dialogTitle;
	dialogButton1 = _button1;
	dialogButton2 = _button2 != 0 ? _button2 : "";
	dialogController = dynamic_cast<CBaseObject*> (_dialogController);
	dialogDescription = _description;
	CView* view = UIEditController::getEditorDescription ().createView ("dialog", this);
	if (view)
	{
		CLayeredViewContainer* layeredView = dynamic_cast<CLayeredViewContainer*>(view);
		if (layeredView)
			layeredView->setZIndex (10);

		CRect size = view->getViewSize ();
		size.right += sizeDiff.x;
		size.bottom += sizeDiff.y;
		CRect frameSize = frame->getViewSize ();
		size.centerInside (frameSize);
		size.makeIntegral ();
		view->setViewSize (size);
		view->setMouseableArea (size);
		view->setAlphaValue (0.f);

		frame->setModalView (view);
		frame->registerKeyboardHook (this);
		frame->registerViewListener (this);
		view->registerViewListener (this);
		if (button1)
			frame->setFocusView (button1);
		setOpenGLViewsVisible (false);
		if (dialogController)
			dialogController->notify (this, kMsgDialogShow);

		view->addAnimation ("AlphaAnimation", new Animation::AlphaValueAnimation (1.f), new Animation::LinearTimingFunction (160));
	}
	else
	{
		forget ();
	}
}
示例#7
0
文件: uiactions.cpp 项目: EQ4/vstgui
//-----------------------------------------------------------------------------
void EmbedViewOperation::perform ()
{
	CRect parentRect = newContainer->getViewSize ();
	const_iterator it = begin ();
	while (it != end ())
	{
		CView* view = (*it).first;
		parent->removeView (view, false);
		CRect r = view->getViewSize ();
		r.offset (-parentRect.left, -parentRect.top);
		view->setViewSize (r);
		view->setMouseableArea (r);
		newContainer->addView (view);
		it++;
	}
	parent->addView (newContainer);
	newContainer->remember ();
	selection->setExclusive (newContainer);
}
示例#8
0
文件: uiactions.cpp 项目: EQ4/vstgui
//----------------------------------------------------------------------------------------------------
void UnembedViewOperation::undo ()
{
	CRect containerViewSize = containerView->getViewSize ();
	const_iterator it = begin ();
	while (it != end ())
	{
		CView* view = (*it);
		parent->removeView (view, false);
		CRect viewSize = view->getViewSize ();
		CRect mouseSize = view->getMouseableArea ();
		viewSize.offset (-containerViewSize.left, -containerViewSize.top);
		mouseSize.offset (-containerViewSize.left, -containerViewSize.top);
		view->setViewSize (viewSize);
		view->setMouseableArea (mouseSize);
		containerView->addView (view);
		it++;
	}
	parent->addView (containerView);
	selection->setExclusive (containerView);
}
//----------------------------------------------------------------------------------------------------
SharedPointer<UISelection> UIViewCreatorDataSource::createSelection ()
{
	SharedPointer<UISelection> selection;
	UIAttributes viewAttr;
	viewAttr.setAttribute (UIViewCreator::kAttrClass, getStringList ()->at (static_cast<uint32_t> (mouseDownRow)));
	CView* view = factory->createView (viewAttr, description);
	if (view)
	{
		if (view->getViewSize ().isEmpty ())
		{
			CRect size (CPoint (0, 0), CPoint (20, 20));
			view->setViewSize (size);
			view->setMouseableArea (size);
		}
		selection = owned (new UISelection ());
		selection->add (view);
		view->forget ();
	}
	return selection;
}
示例#10
0
文件: uiactions.cpp 项目: EQ4/vstgui
//----------------------------------------------------------------------------------------------------
void UnembedViewOperation::perform ()
{
	IDependency::DeferChanges dc (selection);
	selection->remove (containerView);
	CRect containerViewSize = containerView->getViewSize ();
	const_reverse_iterator it = rbegin ();
	while (it != rend ())
	{
		CView* view = (*it);
		CRect viewSize = view->getViewSize ();
		CRect mouseSize = view->getMouseableArea ();
		containerView->removeView (view, false);
		viewSize.offset (containerViewSize.left, containerViewSize.top);
		mouseSize.offset (containerViewSize.left, containerViewSize.top);
		view->setViewSize (viewSize);
		view->setMouseableArea (mouseSize);
		if (parent->addView (view))
			selection->add (view);
		it++;
	}
	parent->removeView (containerView, false);
}
示例#11
0
//-----------------------------------------------------------------------------
void UIViewSwitchContainer::setCurrentViewIndex (int32_t viewIndex)
{
	if (controller)
	{
		CView* view = controller->createViewForIndex (viewIndex);
		if (view)
		{
			if (view->getAutosizeFlags () & kAutosizeAll)
			{
				CRect vs (getViewSize ());
				vs.offset (-vs.left, -vs.top);
				view->setViewSize (vs);
				view->setMouseableArea (vs);
			}
			if (animationTime)
			{
				if (getFrame ())
					getFrame ()->getAnimator ()->removeAnimation (this, "UIViewSwitchContainer::setCurrentViewIndex");
				CView* oldView = getView (0);
				if (isAttached () && oldView && getFrame ())
				{
					getFrame ()->getAnimator ()->addAnimation (this, "UIViewSwitchContainer::setCurrentViewIndex", new Animation::ExchangeViewAnimation (oldView, view, Animation::ExchangeViewAnimation::kAlphaValueFade), new Animation::LinearTimingFunction (animationTime));
				}
				else
				{
					removeAll ();
					addView (view);
				}
			}
			else
			{
				CViewContainer::removeAll ();
				CViewContainer::addView (view);
			}
			currentViewIndex = viewIndex;
			invalid ();
		}
	}
}
示例#12
0
//-----------------------------------------------------------------------------
void UIViewSwitchContainer::setCurrentViewIndex (int32_t viewIndex)
{
	if (controller && viewIndex != currentViewIndex)
	{
		CView* view = controller->createViewForIndex (viewIndex);
		if (view)
		{
			if (view->getAutosizeFlags () & kAutosizeAll)
			{
				CRect vs (getViewSize ());
				vs.offset (-vs.left, -vs.top);
				view->setViewSize (vs);
				view->setMouseableArea (vs);
			}
			if (animationTime)
			{
				if (getFrame ())
					getFrame ()->getAnimator ()->removeAnimation (this, "UIViewSwitchContainer::setCurrentViewIndex");
				CView* oldView = getView (0);
				if (isAttached () && oldView && getFrame ())
				{
					Animation::IAnimationTarget* animation = 0;
					switch (animationStyle)
					{
						case kFadeInOut:
						{
							animation = new Animation::ExchangeViewAnimation (oldView, view, Animation::ExchangeViewAnimation::kAlphaValueFade);
							break;
						}
						case kMoveInOut:
						{
							Animation::ExchangeViewAnimation::AnimationStyle style = Animation::ExchangeViewAnimation::kPushInFromLeft;
							if (viewIndex > currentViewIndex)
							{
								style = Animation::ExchangeViewAnimation::kPushInFromRight;
							}
							animation = new Animation::ExchangeViewAnimation (oldView, view, style);
							break;
						}
						case kPushInOut:
						{
							Animation::ExchangeViewAnimation::AnimationStyle style = Animation::ExchangeViewAnimation::kPushInOutFromLeft;
							if (viewIndex > currentViewIndex)
							{
								style = Animation::ExchangeViewAnimation::kPushInOutFromRight;
							}
							animation = new Animation::ExchangeViewAnimation (oldView, view, style);
							break;
						}
					}
					if (animation)
						getFrame ()->getAnimator ()->addAnimation (this, "UIViewSwitchContainer::setCurrentViewIndex", animation, new Animation::LinearTimingFunction (animationTime));
					else
					{
						removeAll ();
						addView (view);
					}
				}
				else
				{
					removeAll ();
					addView (view);
				}
			}
			else
			{
				CViewContainer::removeAll ();
				CViewContainer::addView (view);
			}
			currentViewIndex = viewIndex;
			invalid ();
		}
	}
}
示例#13
0
文件: ctabview.cpp 项目: EQ4/vstgui
//-----------------------------------------------------------------------------
void CTabView::setViewSize (const CRect &rect, bool invalid)
{
	if (rect == getViewSize ())
		return;

	CRect oldSize (getViewSize ());

	CCoord widthDelta = rect.getWidth () - oldSize.getWidth ();
	CCoord heightDelta = rect.getHeight () - oldSize.getHeight ();

	if (widthDelta != 0 || heightDelta != 0)
	{
		uint32_t numSubviews = getNbViews();
		int32_t counter = 1;
		bool treatAsColumn = (getAutosizeFlags () & kAutosizeColumn) ? true : false;
		bool treatAsRow = (getAutosizeFlags () & kAutosizeRow) ? true : false;
		CTabChildView* v = firstChild;
		while (v)
		{
			if (v != currentChild)
			{
				CView* pV = v->view;
				int32_t autosize = pV->getAutosizeFlags ();
				CRect viewSize (pV->getViewSize ());
				CRect mouseSize (pV->getMouseableArea ());
				if (treatAsColumn)
				{
					if (counter)
					{
						viewSize.offset (counter * (widthDelta / (numSubviews)), 0);
						mouseSize.offset (counter * (widthDelta / (numSubviews)), 0);
					}
					viewSize.setWidth (viewSize.getWidth () + (widthDelta / (numSubviews)));
					mouseSize.setWidth (mouseSize.getWidth () + (widthDelta / (numSubviews)));
				}
				else if (widthDelta != 0 && autosize & kAutosizeRight)
				{
					viewSize.right += widthDelta;
					mouseSize.right += widthDelta;
					if (!(autosize & kAutosizeLeft))
					{
						viewSize.left += widthDelta;
						mouseSize.left += widthDelta;
					}
				}
				if (treatAsRow)
				{
					if (counter)
					{
						viewSize.offset (0, counter * (heightDelta / (numSubviews)));
						mouseSize.offset (0, counter * (heightDelta / (numSubviews)));
					}
					viewSize.setHeight (viewSize.getHeight () + (heightDelta / (numSubviews)));
					mouseSize.setHeight (mouseSize.getHeight () + (heightDelta / (numSubviews)));
				}
				else if (heightDelta != 0 && autosize & kAutosizeBottom)
				{
					viewSize.bottom += heightDelta;
					mouseSize.bottom += heightDelta;
					if (!(autosize & kAutosizeTop))
					{
						viewSize.top += heightDelta;
						mouseSize.top += heightDelta;
					}
				}
				if (viewSize != pV->getViewSize ())
				{
					pV->setViewSize (viewSize);
					pV->setMouseableArea (mouseSize);
				}
			}
			v = v->next;
//			counter++;
		}
	}
	
	CViewContainer::setViewSize (rect, invalid);
}