fork/m-overlay
git clone https://git.julia.blue/fork/m-overlay
27686d7
settings-overhaul
1local PANEL =class . create ( "ToolTip" , "BasePanel" ) 2 3PANEL : ACCESSOR ( "Enabled" , "m_bEnabled" , true ) 4PANEL : ACCESSOR ( "ArrowX" , "m_iArrowX" , 0 ) 5PANEL : ACCESSOR ( "ArrowY" , "m_iArrowY" , 0 ) 6 7PANEL . ToolTipColor =color ( 240 , 240 , 240 ) 8 9function PANEL : ToolTip () 10self : super () -- Initialize our baseclass 11self : SetFocusable ( false ) -- Ignore focus 12 13self : SetSize ( 256 , 256 ) 14self : DockPadding ( 8 , 8 , 8 , 0 ) 15 16self . m_pTitle =self : Add ( "Label" ) 17self . m_pTitle : Dock ( DOCK_TOP ) 18self . m_pTitle : SetLineHeight ( 0.75 ) 19self . m_pTitle : SetTextColor ( color_red ) 20 21self . m_pBody =self : Add ( "Label" ) 22self . m_pBody : Dock ( DOCK_FILL ) 23self . m_pBody : SetWrapped ( true ) 24self . m_pBody : SetFont ( "fonts/melee.otf" , 10 ) 25self . m_pBody : SetLineHeight ( 0.75 ) 26self . m_pBody : SetPos ( 8 , 16 + 24 ) 27self . m_pBody : SetSize ( 236 , 228 ) 28end 29 30function PANEL : SetArrowPos ( x , y ) 31self . m_iArrowX =x 32self . m_iArrowY =y 33end 34 35function PANEL : GetArrowPos () 36return math . max ( 5 , math . min ( self : GetWidth () - 5 , self . m_iArrowX )), math . max ( 5 , math . min ( self : GetHeight () - 5 , self . m_iArrowY )) 37end 38 39function PANEL : SetTitle ( str ) 40self . m_pTitle : SetText ( str ) 41end 42 43function PANEL : SetBody ( str ) 44self . m_pBody : SetText ( str ) 45self . m_pBody : HeightToText () 46self : SizeToChildren ( false , true ) 47end 48 49function PANEL : Paint ( w , h ) 50graphics . setColor ( color_black ) 51graphics . roundRect ( 4 , 4 , w - 8 , h - 8 , 4 ) 52 53local s1 =5.65685424949 -- sqrt(4^2+4^2) 54local s2 =7.07106781187 -- sqrt(5^2+5^2) 55 56graphics . setColor ( self . ToolTipColor ) 57 58graphics . push () 59graphics . translate ( self : GetArrowPos ()) -- move relative (0,0) to (x,y) 60graphics . rotate ( math . rad ( 45 )) -- rotate coordinate system around relative (0,0) (absolute (x,y)) 61 62graphics . setColor ( color_black ) 63graphics . rectangle ( "fill" , - s2 / 2 , - s2 / 2 , s2 , s2 ) -- draw rectangle centered around relative (0,0) 64 65graphics . setColor ( self . ToolTipColor ) 66graphics . rectangle ( "fill" , - s1 / 2 , - s1 / 2 , s1 , s1 ) -- draw rectangle centered around relative (0,0) 67graphics . pop () 68 69graphics . setColor ( self . ToolTipColor ) 70graphics . roundRect ( 5 , 5 , w - 10 , h - 10 , 4 ) 71end