• Derma Panels Positioning
    3 replies, posted
Hey. I've been confused with using ScrH and ScrW lately. Further-more, I'm also confused about stuff positioned within the panel. If I do ScrH / 2 / 2, it gives a quarter size panel I assume, what if I did: SetPos(100,600) ?, This would fit on some resolutions but not all. So what is the PROPER way of positioning both the panel and its items so it looks the same on all screens, gaurenteed? Can someone please give an example? Thank you.
[URL="https://dl.dropboxusercontent.com/u/26074909/tutoring/vgui/understanding_hardcoding_of_screensizes.lua.html"]https://dl.dropboxusercontent.com/u/26074909/tutoring/vgui/understanding_hardcoding_of_screensizes.lua.html[/URL] Courtesy of Acecool
The world panel is ScrW( ) wide, and ScrH( ) high. 0, 0 position is top-left position on the screen, and on elements. That is your "Origin"... For Screen: w = 0, h = 0 is origin / top-left w = 0, h = ScrH( ) is bottom-left; w = ScrW( ), h = 0 is top-right; w = ScrW( ), h = ScrH( ) is bottom-right; w = ScrW( ) / 2, h = ScrH( ) / 2 is center; For Panel WHERE panel is the variable containing the reference to the panel: w = 0, h = 0 is origin / top-left of the panel itself regardless of where it is positioned w = 0, h = panel:GetTall( ) is bottom-left of the panel itself regardless of where it is positioned; w = panel:GetWide( ), h = 0 is top-right of the panel itself regardless of where it is positioned; w = panel:GetWide( ), h = panel:GetTall( ) is bottom-right of the panel itself regardless of where it is positioned; w = panel:GetWide( ) / 2, h = panel:GetTall( ) / 2 is center of the panel itself regardless of where it is positioned; If you want half of the screen-size you'd use ScrW( ) / 2; If you want half of the panel width you'd use panel:GetWide( ) / 2; If you want half of the panel height you'd use panel:GetTall( ) / 2; You can also get the parent panel by using panel = otherpanel:GetParent( ) Take a look at this console command which helps when developing vgui ( clearvgui which clears all vgui elements from the screen ): [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_utilities/concommand_clearvgui.lua[/url] All panels are children of the world panel except those that are parented to the hud panel. Those children of the hud panel can't be accessed unless you know the reference because the children function doesn't work ( unless they fixed it ).
[QUOTE=Acecool;46767951]The world panel is ScrW( ) wide, and ScrH( ) high. 0, 0 position is top-left position on the screen, and on elements. That is your "Origin"... For Screen: w = 0, h = 0 is origin / top-left w = 0, h = ScrH( ) is bottom-left; w = ScrW( ), h = 0 is top-right; w = ScrW( ), h = ScrH( ) is bottom-right; w = ScrW( ) / 2, h = ScrH( ) / 2 is center; For Panel WHERE panel is the variable containing the reference to the panel: w = 0, h = 0 is origin / top-left of the panel itself regardless of where it is positioned w = 0, h = panel:GetTall( ) is bottom-left of the panel itself regardless of where it is positioned; w = panel:GetWide( ), h = 0 is top-right of the panel itself regardless of where it is positioned; w = panel:GetWide( ), h = panel:GetTall( ) is bottom-right of the panel itself regardless of where it is positioned; w = panel:GetWide( ) / 2, h = panel:GetTall( ) / 2 is center of the panel itself regardless of where it is positioned; If you want half of the screen-size you'd use ScrW( ) / 2; If you want half of the panel width you'd use panel:GetWide( ) / 2; If you want half of the panel height you'd use panel:GetTall( ) / 2; You can also get the parent panel by using panel = otherpanel:GetParent( ) Take a look at this console command which helps when developing vgui ( clearvgui which clears all vgui elements from the screen ): [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_utilities/concommand_clearvgui.lua[/url] All panels are children of the world panel except those that are parented to the hud panel. Those children of the hud panel can't be accessed unless you know the reference because the children function doesn't work ( unless they fixed it ).[/QUOTE] Cheers mate. I sort of had the idea but I couldn't understand it to the fullest. [editline]22nd December 2014[/editline] [QUOTE=zerf;46767458][URL="https://dl.dropboxusercontent.com/u/26074909/tutoring/vgui/understanding_hardcoding_of_screensizes.lua.html"]https://dl.dropboxusercontent.com/u/26074909/tutoring/vgui/understanding_hardcoding_of_screensizes.lua.html[/URL] Courtesy of Acecool[/QUOTE] Awesome, thanks :)
Sorry, you need to Log In to post a reply to this thread.