示例#1
0
void GUIElementBase::_setActive(bool active)
{
    bool isActive = (mFlags & GUIElem_Inactive) == 0;
    if (isActive == active)
        return;

    if (!active)
    {
        _markLayoutAsDirty();

        mFlags |= GUIElem_Inactive;

        for (auto& child : mChildren)
            child->_setActive(false);
    }
    else
    {
        bool childActiveSelf = (mFlags & GUIElem_InactiveSelf) == 0;
        if (childActiveSelf)
        {
            mFlags &= ~GUIElem_Inactive;
            _markLayoutAsDirty();

            for (auto& child : mChildren)
                child->_setActive(true);
        }
    }
}
	void GUITabbedTitleBar::tabDragged(UINT32 tabIdx, const Vector2I& dragPos)
	{
		INT32 idx = uniqueIdxToSeqIdx(tabIdx);
		if(idx != -1)
		{
			Rect2I bounds = _getLayoutData().area;
			if(bounds.contains(dragPos))
			{
				if(!mDragInProgress)
					startDrag(idx, dragPos);

				mDragBtnOffset = dragPos.x - mInitialDragOffset;

				for(INT32 i = 0; i < idx; i++)
				{
					UINT32 width = mTabButtons[i]->_getLayoutData().area.width;
					INT32 centerX = mTabButtons[i]->_getLayoutData().area.x + width / 2;

					if(dragPos.x < centerX)
					{
						GUITabButton* temp = mTabButtons[i];
						mTabButtons[i] = mTabButtons[idx];
						mTabButtons[idx] = temp;

						break;
					}
				}

				for(UINT32 i = idx + 1; i < (UINT32)mTabButtons.size(); i++)
				{
					UINT32 width = mTabButtons[i]->_getLayoutData().area.width;
					INT32 centerX = mTabButtons[i]->_getLayoutData().area.x + width / 2;

					if(dragPos.x > centerX)
					{
						GUITabButton* temp = mTabButtons[i];
						mTabButtons[i] = mTabButtons[idx];
						mTabButtons[idx] = temp;

						break;
					}
				}

				_markLayoutAsDirty();
			}
			else
			{
				endDrag();
				_markLayoutAsDirty();

				if(!onTabDraggedOff.empty())
					onTabDraggedOff(tabIdx);
			}
		}
	}
示例#3
0
	void GUIElement::resetDimensions()
	{
		mDimensions = GUIDimensions::create();
		mDimensions.updateWithStyle(mStyle);

		_markLayoutAsDirty();
	}
示例#4
0
void GUIElementBase::_setVisible(bool visible)
{
    bool isVisible = (mFlags & GUIElem_Hidden) == 0;
    if (isVisible == visible)
        return;

    if (!visible)
    {
        _markMeshAsDirty();

        mFlags |= GUIElem_Hidden;

        for (auto& child : mChildren)
            child->_setVisible(false);
    }
    else
    {
        bool childVisibleSelf = (mFlags & GUIElem_HiddenSelf) == 0;
        if (childVisibleSelf)
        {
            mFlags &= ~GUIElem_Hidden;
            _markLayoutAsDirty();

            for (auto& child : mChildren)
                child->_setVisible(true);
        }
    }
}
示例#5
0
	void GUIScrollArea::vertScrollUpdate(float scrollPos)
	{
		UINT32 scrollableHeight = (UINT32)std::max(0, INT32(mContentSize.y) - INT32(mVisibleSize.y));
		mVertOffset = scrollableHeight * Math::clamp01(scrollPos);

		_markLayoutAsDirty();
	}
示例#6
0
	void GUIScrollArea::horzScrollUpdate(float scrollPos)
	{
		UINT32 scrollableWidth = (UINT32)std::max(0, INT32(mContentSize.x) - INT32(mVisibleSize.x));
		mHorzOffset = scrollableWidth * Math::clamp01(scrollPos);

		_markLayoutAsDirty();
	}
	void GUIResourceTreeView::dropTargetDragDropped(INT32 x, INT32 y)
	{
		const GUITreeView::InteractableElement* element = findElementUnderCoord(Vector2I(x, y));

		TreeElement* treeElement = nullptr;
		if(element != nullptr)
		{
			if(element->isTreeElement())
				treeElement = element->getTreeElement();
			else
				treeElement = element->parent;
		}

		if(mDropTarget->getDropType() == OSDropType::FileList)
		{
			Vector<WString> fileList = mDropTarget->getFileList();

			mDraggedResources = bs_new<InternalDraggedResources>((UINT32)fileList.size());
			for(UINT32 i = 0; i < (UINT32)fileList.size(); i++)
				mDraggedResources->resourcePaths[i] = fileList[i];

			dragAndDropEnded(treeElement);

			bs_delete(mDraggedResources);
			mDraggedResources = nullptr;

			unselectAll();
		}

		mDragInProgress = false;
		mDropTargetDragActive = false;
		_markLayoutAsDirty();
	}
示例#8
0
	void GUIScrollArea::scrollToHorizontal(float pct)
	{
		mHorzScroll->_setScrollPos(pct);
		mRecalculateHorzOffset = true;

		_markLayoutAsDirty();
	}
示例#9
0
	void GUIScrollArea::scrollToVertical(float pct)
	{
		mVertScroll->_setScrollPos(pct);
		mRecalculateVertOffset = true;

		_markLayoutAsDirty();
	}
示例#10
0
	void GUIPanel::setDepthRange(INT16 depth, UINT16 depthRangeMin, UINT16 depthRangeMax)
	{
		mDepthOffset = depth;
		mDepthRangeMin = depthRangeMin;
		mDepthRangeMax = depthRangeMax;

		_markLayoutAsDirty();
	}
	void GUITabbedTitleBar::tabDragEnd(UINT32 tabIdx, const Vector2I& dragPos)
	{
		endDrag();

		if(mActiveTabIdx != tabIdx)
			tabToggled(tabIdx, true);

		_markLayoutAsDirty();
	}
示例#12
0
	void GUILayout::removeElementAt(UINT32 idx)
	{
		if(idx >= (UINT32)mChildren.size())
			BS_EXCEPT(InvalidParametersException, "Index out of range: " + toString(idx) + ". Valid range: 0 .. " + toString((UINT32)mChildren.size()));

		GUIElementBase* child = mChildren[idx];
		mChildren.erase(mChildren.begin() + idx);

		child->_setParent(nullptr);

		_markLayoutAsDirty();
	}
	void GUIButtonBase::_setState(GUIElementState state)
	{
		Vector2I origSize = mDimensions.calculateSizeRange(_getOptimalSize()).optimal;
		mActiveState = state;
		refreshContentSprite();
		Vector2I newSize = mDimensions.calculateSizeRange(_getOptimalSize()).optimal;

		if (origSize != newSize)
			_markLayoutAsDirty();
		else
			_markContentAsDirty();
	}
示例#14
0
void GUIElementBase::resetDimensions()
{
    bool isFixedBefore = (mDimensions.flags & GUIDF_FixedWidth) != 0 && (mDimensions.flags & GUIDF_FixedHeight) != 0;

    mDimensions = GUIDimensions::create();

    bool isFixedAfter = (mDimensions.flags & GUIDF_FixedWidth) != 0 && (mDimensions.flags & GUIDF_FixedHeight) != 0;

    if (isFixedBefore != isFixedAfter)
        refreshChildUpdateParents();

    _markLayoutAsDirty();
}
	void GUIResourceTreeView::dragAndDropFinalize()
	{
		mDragInProgress = false;
		_markLayoutAsDirty();

		DraggedResources* draggedResources = reinterpret_cast<DraggedResources*>(DragAndDropManager::instance().getDragData());
		bs_delete(draggedResources);

		if(mDraggedResources != nullptr)
		{
			bs_delete(mDraggedResources);
			mDraggedResources = nullptr;
		}
	}
示例#16
0
void GUIElementBase::setHeight(UINT32 height)
{
    bool isFixedBefore = (mDimensions.flags & GUIDF_FixedWidth) != 0 && (mDimensions.flags & GUIDF_FixedHeight) != 0;

    mDimensions.flags |= GUIDF_FixedHeight | GUIDF_OverHeight;
    mDimensions.minHeight = mDimensions.maxHeight = height;

    bool isFixedAfter = (mDimensions.flags & GUIDF_FixedWidth) != 0 && (mDimensions.flags & GUIDF_FixedHeight) != 0;

    if (isFixedBefore != isFixedAfter)
        refreshChildUpdateParents();

    _markLayoutAsDirty();
}
	void GUIButtonBase::setContent(const GUIContent& content)
	{
		Vector2I origSize = mDimensions.calculateSizeRange(_getOptimalSize()).optimal;
		mContent = content;

		refreshContentSprite();

		Vector2I newSize = mDimensions.calculateSizeRange(_getOptimalSize()).optimal;

		if (origSize != newSize)
			_markLayoutAsDirty();
		else
			_markContentAsDirty();
	}
示例#18
0
void GUIElementBase::setWidth(UINT32 width)
{
    bool isFixedBefore = (mDimensions.flags & GUIDF_FixedWidth) != 0 && (mDimensions.flags & GUIDF_FixedHeight) != 0;

    mDimensions.flags |= GUIDF_FixedWidth | GUIDF_OverWidth;
    mDimensions.minWidth = mDimensions.maxWidth = width;

    bool isFixedAfter = (mDimensions.flags & GUIDF_FixedWidth) != 0 && (mDimensions.flags & GUIDF_FixedHeight) != 0;

    if (isFixedBefore != isFixedAfter)
        refreshChildUpdateParents();

    _markLayoutAsDirty();
}
	void GUIWindowFrame::setFocused(bool focused)
	{
		Vector2I origSize = mDimensions.calculateSizeRange(_getOptimalSize()).optimal;

		if(focused)
			mActiveTexture = _getStyle()->focused.texture;
		else
			mActiveTexture = _getStyle()->normal.texture;

		Vector2I newSize = mDimensions.calculateSizeRange(_getOptimalSize()).optimal;

		if (origSize != newSize)
			_markLayoutAsDirty();
		else
			_markContentAsDirty();
	}
示例#20
0
	void GUIElement::_refreshStyle()
	{
		const GUIElementStyle* newStyle = nullptr;
		if(_getParentWidget() != nullptr && !mStyleName.empty())
			newStyle = _getParentWidget()->getSkin().getStyle(mStyleName);
		else
			newStyle = &GUISkin::DefaultStyle;

		if(newStyle != mStyle)
		{
			mStyle = newStyle;
			mDimensions.updateWithStyle(mStyle);
			styleUpdated();

			_markLayoutAsDirty();
		}
	}
	void GUIResourceTreeView::entryAdded(const Path& path)
	{
		Path parentPath = path.getParent();

		ResourceTreeElement* parentElement = findTreeElement(parentPath);
		assert(parentElement != nullptr);

		ResourceTreeElement* newElement = addTreeElement(parentElement, path);
		sortTreeElement(parentElement);

		ProjectLibrary::LibraryEntry* libEntry = gProjectLibrary().findEntry(path);
		
		assert(libEntry != nullptr);
		updateFromProjectLibraryEntry(newElement, libEntry);

		_markLayoutAsDirty();
	}
示例#22
0
void GUIElementBase::_registerChildElement(GUIElementBase* element)
{
    assert(!element->_isDestroyed());

    GUIElementBase* parentElement = element->_getParent();
    if(parentElement != nullptr)
    {
        parentElement->_unregisterChildElement(element);
    }

    element->_setParent(this);
    mChildren.push_back(element);

    element->_setActive(_isActive());
    element->_setVisible(_isVisible());
    element->_setDisabled(_isDisabled());

    _markLayoutAsDirty();
}
示例#23
0
void GUIElementBase::setFlexibleWidth(UINT32 minWidth, UINT32 maxWidth)
{
    if (maxWidth < minWidth)
        std::swap(minWidth, maxWidth);

    bool isFixedBefore = (mDimensions.flags & GUIDF_FixedWidth) != 0 && (mDimensions.flags & GUIDF_FixedHeight) != 0;

    mDimensions.flags |= GUIDF_OverWidth;
    mDimensions.flags &= ~GUIDF_FixedWidth;
    mDimensions.minWidth = minWidth;
    mDimensions.maxWidth = maxWidth;

    bool isFixedAfter = (mDimensions.flags & GUIDF_FixedWidth) != 0 && (mDimensions.flags & GUIDF_FixedHeight) != 0;

    if (isFixedBefore != isFixedAfter)
        refreshChildUpdateParents();

    _markLayoutAsDirty();
}
	void GUIResourceTreeView::dropTargetDragMove(INT32 x, INT32 y)
	{
		mDragPosition = Vector2I(x, y);
		mDragInProgress = true;
		mDropTargetDragActive = true;
		_markLayoutAsDirty();

		if(mBottomScrollBounds.contains(mDragPosition))
		{
			if(mScrollState != ScrollState::Down)
				mScrollState = ScrollState::TransitioningDown;
		}
		else if(mTopScrollBounds.contains(mDragPosition))
		{
			if(mScrollState != ScrollState::Up)
				mScrollState = ScrollState::TransitioningUp;
		}
		else
			mScrollState = ScrollState::None;
	}
示例#25
0
void GUIElementBase::_unregisterChildElement(GUIElementBase* element)
{
    bool foundElem = false;
    for(auto iter = mChildren.begin(); iter != mChildren.end(); ++iter)
    {
        GUIElementBase* child = *iter;

        if (child == element)
        {
            mChildren.erase(iter);
            element->_setParent(nullptr);
            foundElem = true;

            _markLayoutAsDirty();
            break;
        }
    }

    if(!foundElem)
        BS_EXCEPT(InvalidParametersException, "Provided element is not a part of this element.");
}
示例#26
0
void GUIElementBase::_changeParentWidget(GUIWidget* widget)
{
    assert(!_isDestroyed());

    if (mParentWidget != widget)
    {
        if (mParentWidget != nullptr)
            mParentWidget->_unregisterElement(this);

        if (widget != nullptr)
            widget->_registerElement(this);
    }

    mParentWidget = widget;

    for(auto& child : mChildren)
    {
        child->_changeParentWidget(widget);
    }

    _markLayoutAsDirty();
}
示例#27
0
	void GUILayout::insertElement(UINT32 idx, GUIElementBase* element)
	{
		if(idx > (UINT32)mChildren.size())
			BS_EXCEPT(InvalidParametersException, "Index out of range: " + toString(idx) + ". Valid range: 0 .. " + toString((UINT32)mChildren.size()));

		if (element->_isDestroyed())
			return;

		GUIElementBase* parentElement = element->_getParent();
		if(parentElement != nullptr)
		{
			parentElement->_unregisterChildElement(element);
		}

		element->_setParent(this);
		mChildren.insert(mChildren.begin() + idx, element);
		
		element->_setActive(_isActive());
		element->_setVisible(_isVisible());
		element->_setDisabled(_isDisabled());

		_markLayoutAsDirty();
	}
示例#28
0
	void GUIProgressBar::setPercent(float pct)
	{
		mPercent = pct;
		_markLayoutAsDirty();
	}
	void GUIResourceTreeView::dropTargetDragLeave()
	{
		mDragInProgress = false;
		mDropTargetDragActive = false;
		_markLayoutAsDirty();
	}