MCPcopy Create free account
hub / github.com/BobbyAnguelov/Esoterica / DrawButton

Function DrawButton

Code/Engine/Input/Debug/DebugView_Input.cpp:35–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33 static void DrawButton( ImDrawList* pDrawList, Float2 const& position, Float2 const& dimensions, char const* const pLabel, bool IsHeldDown, uint32_t buttonColor = g_controlOutlineColor, uint32_t pressedColor = g_controlFillColor )
34 {
35 EE_ASSERT( pDrawList != nullptr );
36 Float2 const buttonTopLeft = position;
37 Float2 const buttonBottomRight = buttonTopLeft + dimensions;
38 pDrawList->AddRect( buttonTopLeft, buttonBottomRight, buttonColor, g_buttonBorderRounding, g_buttonBorderThickness, ImDrawFlags_RoundCornersAll );
39
40 if ( IsHeldDown )
41 {
42 pDrawList->AddRectFilled( buttonTopLeft + g_buttonBorderOffset, buttonTopLeft + dimensions - g_buttonBorderOffset, pressedColor, g_buttonBorderRounding - 1, ImDrawFlags_RoundCornersAll );
43 }
44
45 if ( pLabel != nullptr )
46 {
47 Float2 const textDimensions = ImGui::CalcTextSize( pLabel );
48 Float2 const textPos = Float2( buttonTopLeft.m_x + ( dimensions.m_x / 2 ) - ( textDimensions.m_x / 2 ) + 1, buttonTopLeft.m_y + ( dimensions.m_y / 2 ) - ( textDimensions.m_y / 2 ) );
49 pDrawList->AddText( textPos, 0xFFFFFFFF, pLabel );
50 }
51 }
52
53 static void DrawTriggerButton( ImDrawList* pDrawList, Float2 const& position, Float2 const& dimensions, char const* const pLabel, ControllerDevice const& controller, bool isLeftTrigger )
54 {
55 EE_ASSERT( pDrawList != nullptr );
56

Callers 1

DrawControllerStateMethod · 0.85

Calls 4

AddRectMethod · 0.80
AddRectFilledMethod · 0.80
AddTextMethod · 0.80
Float2Function · 0.50

Tested by

no test coverage detected