Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[graphics.mod] TGraphics.Resize() and .Position() only stubs #289

Open
GWRon opened this issue Aug 7, 2023 · 2 comments
Open

[graphics.mod] TGraphics.Resize() and .Position() only stubs #289

GWRon opened this issue Aug 7, 2023 · 2 comments

Comments

@GWRon
Copy link
Contributor

GWRon commented Aug 7, 2023

No backend for now implements Resize() or Position().

	Method Resize(width:Int, height:Int) Override
	End Method
	
	Method Position(x:Int, y:Int) Override
	End Method

So for now there is no way to reposition/resize a windowed Blitzmax-window in a convenient way - despite directly on creation via graphics()

@GWRon
Copy link
Contributor Author

GWRon commented Aug 7, 2023

For Linux we could position like this:
glgraphics.mod/glgraphics.linux.c:

void bbGLGraphicsPosition( int x, int y ){
	if( !_currentContext ) return;
	if( !xdisplay ) return;

	XMoveWindow(xdisplay, _currentContext->window, x, y);
}

glgraphics.mod/source.bmx:

Extern
...
	Function bbGLGraphicsPosition( x:Int, y:Int )


Type TGLGraphics Extends TGraphics
...
	Method Position(x:Int, y:Int) Override
		bbGLGraphicsPosition(x, y)
	End Method

@GWRon
Copy link
Contributor Author

GWRon commented Aug 7, 2023

Windows:
glgraphics.mod/glgraphics.win32.c

void bbGLGraphicsPosition( int x, int y ){
	if( !_currentContext ) return;
	//ignore when in fullscreen
	if( _currentContext->depth != 0) return;

	RECT rect={0,0,0,0};
	rect.left = x + GetSystemMetrics(SM_CXBORDER);
	rect.top = y + GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYFIXEDFRAME);
	rect.right = rect.left + _currentContext->width;
	rect.bottom = rect.top + _currentContext->height;
		
	//same style as in "bbGLGraphicsCreateGraphics()"
	int hwnd_style = WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX;
	
	//calculate new area rect incorporating window styling
	AdjustWindowRectEx( &rect, hwnd_style, 0, 0 );
	
	//adjust position
	SetWindowPos(_currentContext->hwnd, NULL, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER);

	//refresh dimensions
	RECT newRect;
	GetClientRect( _currentContext->hwnd, &newRect );
	_currentContext->width = newRect.right - newRect.left;
	_currentContext->height = newRect.bottom - newRect.top;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant