Пример #1
0
void GxFreeLayout::Add(GxWidget* widget)
{
	GxLayout::Add(widget);

	Item item = {widget, GxVec2i(0, 0)};
	myItems.Append(item);
}
Пример #2
0
void GxFreeLayout::Add(GxWidget* widget, int x, int y)
{
	GxLayout::Add(widget);

	Item item = {widget, GxVec2i(x, y)};
	myItems.Append(item);
}
Пример #3
0
void GxFreeLayout::Add(GxWidget* widget, int x, int y, int w, int h)
{
	GxLayout::Add(widget);

	widget->SetAdjustHint(false);
	widget->SetSizeHint(w, h);

	Item item = {widget, GxVec2i(x, y)};
	myItems.Append(item);
}
Пример #4
0
void GxDockArea::myStartResize(GxDock* dock, int x, int y)
{
	myUndock(dock);
	myMoveToTop(dock);

	myFocusDock = dock;
	myResizeDir = dock->myGetResizeDir(x, y);
	myActionDims = dock->myFloatRect;
	myActionPos = GxVec2i(x, y);
	myActionType = FA_RESIZE;
}
Пример #5
0
bool GxTextureDatabaseImp::Create(GxTextureHandle& outHandle, int width, int height, const uchar* pixeldata)
{
	outHandle = 0;

	if(pixeldata && GxRenderInterface::Get()->GenerateTexture(outHandle, width, height, pixeldata))
	{
		myMap.Insert(outHandle, GxVec2i(width, height));
	}
	else
	{
		GxLog(LOG_TAG, GX_LT_WARNING, "Failed to generate texture (%i, %i)", width, height);
	}

	return (outHandle != 0);
}
Пример #6
0
void GxDockArea::myStartDrag(GxDock* dock, int x, int y)
{
	if(!dock->IsFloating())
	{
		GxRecti r = dock->myRect;
		r.x -= myRect.x;
		r.y -= myRect.y;

		GxRecti f = dock->myFloatRect;
		int dx = (x - r.x) - (x - r.x) * f.w / GxMax(r.w, 1);
		dock->SetFloatingPos(r.x + dx, r.y);
	}

	myUndock(dock);
	myMoveToTop(dock);

	myFocusDock = dock;
	myActionDims = dock->myFloatRect;
	myActionPos = GxVec2i(x, y);
	myActionType = FA_DRAG;
}
Пример #7
0
GxVec2i GxRenderInterface::GetViewSize()
{
	return GxVec2i(640, 480);
}
Пример #8
0
void GxDockArea::Tick(float dt)
{
	GxVec2i mpos = GxInput::Get()->GetMousePos();
	mpos.x = GxClamp(mpos.x, 0, myRect.w);
	mpos.y = GxClamp(mpos.y, 0, myRect.h);

	GxVec2i resizeDir = GxVec2i(0, 0);
	bool draggingAction = false;

	if(myHoverDock)
	{
		GxDock::Item item = myHoverDock->myGetItemAt(mpos.x, mpos.y);

		if(item == GxDock::I_BAR)
			draggingAction = true;

		if(item == GxDock::I_FRAME)
			resizeDir = myHoverDock->myGetResizeDir(mpos.x, mpos.y);
	}

	// Handle floating dock dragging action.
	if(myActionType == FA_DRAG)
	{
		draggingAction = true;

		GxRecti r = myActionDims;
		r.x += mpos.x - myActionPos.x;
		r.y += mpos.y - myActionPos.y;

		myFocusDock->myFloatRect = r;
		myFocusDock->myClampFloatSize(GxVec2i());
		myFocusDock->myClampFloatPos(GxVec2i(myRect.w, myRect.h));

		myDragHl = GxMin(1.f, myDragHl + dt * 2);
	}
	else 
	{
		myDragHl = GxMax(0.f, myDragHl - dt * 4);
	}

	// Handle floating dock resize action.
	if(myActionType == FA_RESIZE)
	{
		resizeDir = myResizeDir;
		GxRecti r = myActionDims;
		GxVec2i d = mpos - myActionPos;

		if(myResizeDir.x < 0) r.Expand(-d.x, 0, 0, 0);
		if(myResizeDir.y < 0) r.Expand(0, -d.y, 0, 0);
		if(myResizeDir.x > 0) r.Expand(0, 0, +d.x, 0);
		if(myResizeDir.y > 0) r.Expand(0, 0, 0, +d.y);

		myFocusDock->myFloatRect = r;
		myFocusDock->myClampFloatSize(myResizeDir);
		myFocusDock->myClampFloatPos(GxVec2i(myRect.w, myRect.h));
	}

	// Change the mouse cursor image when resizing.
	if(resizeDir.x != 0 || resizeDir.y != 0)
	{
		GxVec2i d = resizeDir;
		GxCursorImage c = GX_CI_DRAG;

		if(d.x != 0 && d.y == 0) c = GX_CI_SIZE_WE;
		if(d.x == 0 && d.y != 0) c = GX_CI_SIZE_NS;
		if(d.x <  0 && d.y <  0) c = GX_CI_SIZE_NWSE;
		if(d.x >  0 && d.y >  0) c = GX_CI_SIZE_NWSE;
		if(d.x <  0 && d.y >  0) c = GX_CI_SIZE_NESW;
		if(d.x >  0 && d.y <  0) c = GX_CI_SIZE_NESW;

		GetContext()->SetCursor(c);
	}

	// Change the mouse cursor image when dragging.
	if(draggingAction)
	{
		GetContext()->SetCursor(GX_CI_DRAG);
	}

	// Tick the dock bars.
	for(int i=0; i<binCount; ++i)
		if(myBins[i])
			myBins[i]->Tick(dt);

	// Tick the floating docks.
	for(int i=0; i<myDocks.Size(); ++i)
		if(myDocks[i]->IsFloating() && !myDocks[i]->IsHidden())
			myDocks[i]->Tick(dt);
}
Пример #9
0
GxVec2i GxSizePolicy::GetMaxSize() const
{
	const int x = flagsH[GX_SPF_GROW] ? max.x : hint.x;
	const int y = flagsV[GX_SPF_GROW] ? max.y : hint.y;
	return GxVec2i(x, y);
}
Пример #10
0
GxVec2i GxSizePolicy::GetMinSize() const
{
	const int x = flagsH[GX_SPF_SHRINK] ? min.x : hint.x;
	const int y = flagsV[GX_SPF_SHRINK] ? min.y : hint.y;
	return GxVec2i(x, y);
}