void RenderWindowManager::_update()
	{
		RenderWindow* newWinInFocus = nullptr;
		Vector<RenderWindow*> movedOrResizedWindows;
		Vector<RenderWindow*> mouseLeftWindows;
		Vector<RenderWindow*> closeRequestedWindows;

		{
			Lock lock(mWindowMutex);
			newWinInFocus = mNewWindowInFocus;

			std::swap(mMovedOrResizedWindows, movedOrResizedWindows);
			std::swap(mMouseLeftWindows, mouseLeftWindows);

			for (auto& dirtyPropertyWindow : mDirtyProperties)
				dirtyPropertyWindow->syncProperties();

			mDirtyProperties.clear();

			std::swap(mCloseRequestedWindows, closeRequestedWindows);
		}

		if(mWindowInFocus != newWinInFocus)
		{
			if(mWindowInFocus != nullptr)
				onFocusLost(*mWindowInFocus);

			if(newWinInFocus != nullptr)
				onFocusGained(*newWinInFocus);

			mWindowInFocus = newWinInFocus;
		}

		for (auto& window : movedOrResizedWindows)
			window->onResized();

		if (!onMouseLeftWindow.empty())
		{
			for (auto& window : mouseLeftWindows)
				onMouseLeftWindow(*window);
		}

		SPtr<RenderWindow> primaryWindow = gCoreApplication().getPrimaryWindow();
		for(auto& entry : closeRequestedWindows)
		{
			// Default behaviour for primary window is to quit the app on close
			if(entry == primaryWindow.get() && entry->onCloseRequested.empty())
			{
				gCoreApplication().quitRequested();
				continue;
			}

			entry->onCloseRequested();
		}
	}
	void DragAndDropManager::startDrag(UINT32 typeId, void* data, std::function<void(bool)> dropCallback, bool needsValidDropTarget)
	{
		if (mIsDragInProgress)
			endDrag(false);

		mDragTypeId = typeId;
		mData = data;
		mNeedsValidDropTarget = needsValidDropTarget;
		addDropCallback(dropCallback);
		mIsDragInProgress = true;

		mCaptureActive.store(false);
		mCaptureChanged.store(false);

		Platform::captureMouse(*gCoreApplication().getPrimaryWindow());
	}
Beispiel #3
0
	HSceneObject Prefab::instantiate()
	{
		if (mRoot == nullptr)
			return HSceneObject();

#if BS_IS_BANSHEE3D
		if (gCoreApplication().isEditor())
		{
			// Update any child prefab instances in case their prefabs changed
			_updateChildInstances();
		}
#endif

		HSceneObject clone = _clone();
		clone->_instantiate();
		
		return clone;
	}
	EditorWindowBase::EditorWindowBase(bool isModal)
		:mOwnsRenderWindow(true), mIsModal(isModal)
	{
		UINT32 width = 200;
		UINT32 height = 200;

		INT32 left = -1;
		INT32 top = -1;

		// If possible open the window in the center of the main editor window
		MainEditorWindow* mainWindow = EditorWindowManager::instance().getMainWindow();
		if(mainWindow != nullptr)
		{
			left = mainWindow->getLeft() + mainWindow->getWidth() / 2 - width / 2;
			top = mainWindow->getTop() + mainWindow->getHeight() / 2 - height / 2;
		}

		RENDER_WINDOW_DESC renderWindowDesc;
		renderWindowDesc.videoMode = VideoMode(width, height);
		renderWindowDesc.title = "EditorWindow";
		renderWindowDesc.fullscreen = false;
		renderWindowDesc.showTitleBar = false;
		renderWindowDesc.showBorder = false;
		renderWindowDesc.allowResize = !isModal;
		renderWindowDesc.toolWindow = true;
		renderWindowDesc.modal = isModal;
		renderWindowDesc.hideUntilSwap = true;
		renderWindowDesc.left = left;
		renderWindowDesc.top = top;
		renderWindowDesc.depthBuffer = false;

		if(EditorWindowManager::instance().areNewWindowsHidden())
			renderWindowDesc.hidden = true;

		mRenderWindow = RenderWindow::create(renderWindowDesc, gCoreApplication().getPrimaryWindow());

		construct(mRenderWindow);
	}