fork/m-overlay
git clone https://git.julia.blue/fork/m-overlay
be5d99b
settings-overhaul
1local PANEL =class . create ( "Tab" , "Button" ) 2 3PANEL : ACCESSOR ( "Active" , "m_bActive" , false ) 4PANEL : ACCESSOR ( "Panel" , "m_pPanel" ) 5PANEL : ACCESSOR ( "ActiveColor" , "m_cActiveColor" ) 6 7function PANEL : Tab () 8self : super () 9self : SetDrawButton ( false ) 10self : TextMargin ( 28 , 0 , 0 , 0 ) 11self : SetTextAlignment ( "left" ) 12end 13 14function PANEL : OnClick () 15if self . m_pPanel then 16self . m_pPanel : GetParent (): SetActivePanel ( self . m_pPanel ) 17end 18end 19 20function PANEL : SetImage ( file ) 21if not file then return end 22self . m_pImage =graphics . newImage ( file ) 23end 24 25function PANEL : Paint ( w , h ) 26gui . skinHook ( "Paint" , "Tab" , self , w , h ) 27 28self : super ( "Paint" , w , h ) 29 30if not self . m_pImage then return end 31graphics . setColor ( color_white ) 32graphics . easyDraw ( self . m_pImage , 4 , 4 , 0 , 16 , 16 ) 33end 34 35function PANEL : PaintOverlay ( w , h ) 36gui . skinHook ( "PaintOverlay" , "Button" , self , w , h ) 37end 38 39local PANEL =class . create ( "TabbedPanel" , "Panel" ) 40 41function PANEL : TabbedPanel () 42self : super () 43self : SetDrawPanel ( false ) 44self : DockPadding ( 0 , 0 , 0 , 0 ) 45 46self . m_pTabBar =self : Add ( "Panel" ) 47self . m_pTabBar : Dock ( DOCK_TOP ) 48self . m_pTabBar : DockPadding ( 0 , 0 , 0 , 0 ) 49self . m_pTabBar : DockMargin ( 0 , 0 , 0 , 0 ) 50self . m_pTabBar : SetBorderColor ( color_clear ) 51self . m_pTabBar : SetBackgroundColor ( color_clear ) 52 53self . m_pActivePanel =nil 54end 55 56function PANEL : SetActivePanel ( panel ) 57if self . m_pActivePanel then 58self . m_pActivePanel : SetVisible ( false ) 59self . m_pActivePanel : GetTab (): SetActive ( false ) 60end 61panel : SetVisible ( true ) 62panel : GetTab (): SetActive ( true ) 63self . m_pActivePanel =panel 64end 65 66function PANEL : AddTab ( name , icon , active ) 67local panel =self : Add ( "Panel" ) 68panel : Dock ( DOCK_FILL ) 69panel : DockMargin ( 0 , 0 , 0 , 0 ) 70panel : SetVisible ( false ) 71 72local tab =self . m_pTabBar : Add ( "Tab" ) 73tab : SetBorderColor ( color_clear ) 74tab : SetBackgroundColor ( color_clear ) 75tab : DockMargin ( 0 , 0 , 0 , 0 ) 76tab : Dock ( DOCK_LEFT ) 77tab : SetText ( name ) 78tab : SetPanel ( panel ) 79tab : SetImage ( icon ) 80tab : SetWidth ( 82 ) 81 82ACCESSOR ( panel , "Tab" , "m_pTab" , tab ) 83 84if active then 85self : SetActivePanel ( panel ) 86end 87 88return panel 89end