cassius Posted October 6, 2015 Posted October 6, 2015 I need to show a dialog box in center of screen no matter what size monitor is.Are there screenheight and screenwidth variables available? Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++
Josh Posted October 6, 2015 Posted October 6, 2015 See GetWidth() and GetHeight(): http://www.leadwerks.com/werkspace/page/api-reference/_/context/ Quote My job is to make tools you love, with the features you want, and performance you can't live without.
Slastraf Posted October 7, 2015 Posted October 7, 2015 you take the height and width and divide it by two Quote
cassius Posted October 7, 2015 Author Posted October 7, 2015 Thanks Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++
cassius Posted October 7, 2015 Author Posted October 7, 2015 I need more help on this if possible. I used context->GetHeight(); etc but now the dialog ( image) is showing in the lower right side of the screen if (title_on) { int w = context->GetWidth(); int h = context->GetHeight(); context->SetBlendMode(Blend::Solid); context->DrawImage(title, w/2, h/2); } Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++
cassius Posted October 7, 2015 Author Posted October 7, 2015 if (title_on) { context->SetBlendMode(Blend::Solid); context->DrawImage(title, 0, 0, context->GetWidth()/2, context->GetHeight() / 2); } This displays image top left of screen which is better but I want it in the middle. Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++
macklebee Posted October 7, 2015 Posted October 7, 2015 You have to take into account the width/height of the image as well if you are trying to center it. so essentially (psuedocode): context_w = Context:GetWidth() context_h = Context:GetHeight() image_w = Texture:GetWidth() image_h = Texture:GetHeight() Context:DrawImage( image, (context_w - image_w) / 2 , (context_h - image_h) / 2, image_w, image_h ) 1 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel
Thirsty Panther Posted October 7, 2015 Posted October 7, 2015 if (title_on) { context->SetBlendMode(Blend::Solid); context->DrawImage(title, 0, 0, context->GetWidth()/2, context->GetHeight() / 2); } This displays image top left of screen which is better but I want it in the middle. It's in the top left corner because you are telling it to draw "title" at position 0,0 and its size is half the screen width and half the screen height. For top of the centre of screen - title,W/2,0 For middle of screen - title, w/2,h/2 Rember that this is where the image will start to draw from so you may need to factor an offset so that the size of the image is accounted for. If you check out Aggrors project Saturn health bar he explains it well. Hope this helps. Quote
cassius Posted October 7, 2015 Author Posted October 7, 2015 Thanks mac I can use that. I am using "window" now instead of context but it shouldn;t make much difference. Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++
cassius Posted October 7, 2015 Author Posted October 7, 2015 Thanks thirsy panther. Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++
Josh Posted October 8, 2015 Posted October 8, 2015 If you don't supply the width and height parameters, it will just be the texture's own size, by default. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without.
cassius Posted October 8, 2015 Author Posted October 8, 2015 I have it filling the screen now which is better than my first intention. It looks ok. Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.