Closed siredmar closed 4 years ago
What you mean specific? without layout?
I want to position some widgets for specific coordinates. E.g. i have a window with 800x600 size and want to put a button at position 23, 98. How would i achieve that?
something here auto& btn = wdg
sorry, i guess i did not write correctly what i need. For some widgets i do need to paint them directly on the SDL_Window. I don't need this 'window in a window' thing but rather an full sized widget within my SDL_Window to put the widgets at given coordinates.
class TestScreen : public Screen { public: TestScreen( SDL_Window* pwindow, int rwidth, int rheight ) : Screen( pwindow, Vector2i(rwidth, rheight), "SDL_gui Test") { button("Button").setPosition(Vector2i{15, 15}) } };
main() { .... SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND); TestScreen *screen = new TestWindow(window, winWidth, winHeight);
while(draw)
{
//your code
screen->drawAll();
SDL_RenderPresent(renderer);
}
}
screen it not a window, it specific class which manage all widget it contain
Thanks a lot!
Hi!
I have one more question regarding the imageView widget.
I tried placing an imageView with an valid SDL_Texture* like buttons or labels.
When i do, i get the following error: Caught a fatal error: Widget:internal error (could not find parent window)
Looking at the previous example:
class TestScreen : public Screen
{
public:
TestScreen(SDL_Window* pwindow, int rwidth, int rheight)
: Screen(pwindow, Vector2i(rwidth, rheight), "SDL_gui Test")
{
auto& btn = wdg<Button>("Button");
btn.setPosition(Vector2i{15, 15})
// singlePlayerTexture is valid in this scope
auto& singlePlayerButton = wdg<ImageView>(singlePlayerTexture);
}
};
main()
{
....SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND);
TestScreen* screen = new TestWindow(window, winWidth, winHeight);
while (draw)
{
// your code
screen->drawAll();
SDL_RenderPresent(renderer);
}
}
What am i doing wrong? Why am i asking this? I want to make a clickable image that behaves like a button. Is there another way? I have two SDL_Textures. One for clicked and one for unclicked. I need to specify a callback function and to the Textureswitch when clicked and revert it if click has finished.
Can widgets be placed on specific coordinates? I guess it can be done via AdvancedGridLayout but i currently don't seem to understand the usage properly.