fork/m-overlay
git clone https://git.julia.blue/fork/m-overlay
27686d7
settings-overhaul
1local PANEL =class . create ( "Frame" , "Panel" ) 2 3PANEL : ACCESSOR ( "Grabbed" , "m_bGrabbed" , false ) 4PANEL : ACCESSOR ( "Draggable" , "m_bDraggable" , true ) 5PANEL : ACCESSOR ( "HideOnClose" , "m_bHideOnClose" , false ) 6 7function PANEL : Frame () 8self : super () -- Initialize our baseclass 9 10self : DockPadding ( 4 , 36 , 4 , 4 ) 11 12self . m_pTitle =self : Add ( "Label" ) 13self . m_pTitle : SetText ( "Window" ) 14self . m_pTitle : SetTextAlignment ( "center" ) 15 16self . m_pClose =self : Add ( "Button" ) 17self . m_pClose : SetText ( "x" ) 18 19gui . skinHook ( "Init" , "ExitButton" , self . m_pClose ) 20 21self . m_pClose . OnClick =function ( this , but ) 22self : OnClosed () 23if self . m_bHideOnClose then 24self : SetVisible ( false ) 25else 26self : Remove () 27end 28end 29end 30 31function PANEL : SetTitle ( s ) 32self . m_pTitle : SetText ( s ) 33end 34 35function PANEL : PerformLayout () 36self . m_pTitle : SetPos ( 2 , 2 ) 37self . m_pTitle : SetSize ( self : GetWidth () - 48 , 28 ) 38 39self . m_pClose : SetPos ( self : GetWidth () - 46 , 4 ) 40self . m_pClose : SetSize ( 42 , 24 ) 41end 42 43function PANEL : Paint ( w , h ) 44gui . skinHook ( "Paint" , "Frame" , self , w , h ) 45end 46 47function PANEL : OnMousePressed ( x , y , but ) 48self : BringToFront () 49if not self . m_bDraggable or not self : HasFocus () then return end 50if y > 32 then return end -- Only allow them to move using the top bar 51self : SetGrabbed ( true ) 52self . m_tGrabbedOffset ={ x =x , y =y } 53end 54 55function PANEL : OnMouseReleased ( x , y , but ) 56if not self . m_bDraggable then return end 57self : SetGrabbed ( false ) 58end 59 60function PANEL : Think ( dt ) 61if not self : IsGrabbed () then return end 62 63local mx , my =love . mouse . getPosition () 64local gx , gy =self . m_tGrabbedOffset . x , self . m_tGrabbedOffset . y 65 66self : SetPos ( mx - gx , my - gy ) 67end 68 69function PANEL : OnClosed () 70-- Override 71end