MCPcopy Create free account
hub / github.com/crosspoint-reader/crosspoint-reader / drawKeyboardKey

Method drawKeyboardKey

src/components/themes/BaseTheme.cpp:911–1007  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

909}
910
911void BaseTheme::drawKeyboardKey(const GfxRenderer& renderer, Rect rect, const char* label, const bool isSelected,
912 const char* secondaryLabel, const KeyboardKeyType keyType,
913 const bool inactiveSelection) const {
914 const auto& metrics = UITheme::getInstance().getMetrics();
915 const int cr = metrics.keyboardKeyCornerRadius;
916 const bool isSpecialKey = keyType == KeyboardKeyType::Shift || keyType == KeyboardKeyType::Mode ||
917 keyType == KeyboardKeyType::Del || keyType == KeyboardKeyType::Space ||
918 keyType == KeyboardKeyType::Ok || keyType == KeyboardKeyType::Disabled;
919
920 if (isSelected) {
921 if (inactiveSelection) {
922 if (cr > 0) {
923 renderer.fillRoundedRect(rect.x, rect.y, rect.width, rect.height, cr, Color::LightGray);
924 } else {
925 renderer.drawRect(rect.x, rect.y, rect.width, rect.height, 2, true);
926 }
927 } else if (keyType == KeyboardKeyType::Disabled) {
928 if (cr > 0) {
929 renderer.fillRoundedRect(rect.x, rect.y, rect.width, rect.height, cr, Color::LightGray);
930 } else {
931 renderer.fillRectDither(rect.x, rect.y, rect.width, rect.height, Color::LightGray);
932 }
933 } else {
934 if (cr > 0) {
935 renderer.fillRoundedRect(rect.x, rect.y, rect.width, rect.height, cr, Color::Black);
936 } else {
937 renderer.fillRect(rect.x, rect.y, rect.width, rect.height, true);
938 }
939 }
940 } else {
941 if (metrics.keyboardFillUnselected) {
942 if (keyType == KeyboardKeyType::Disabled) {
943 if (cr > 0) {
944 renderer.fillRoundedRect(rect.x, rect.y, rect.width, rect.height, cr, Color::LightGray);
945 } else {
946 renderer.fillRectDither(rect.x, rect.y, rect.width, rect.height, Color::LightGray);
947 }
948 } else {
949 if (cr > 0) {
950 renderer.fillRoundedRect(rect.x, rect.y, rect.width, rect.height, cr, Color::White);
951 } else {
952 renderer.fillRect(rect.x, rect.y, rect.width, rect.height, false);
953 }
954 }
955 }
956
957 const bool shouldDrawOutline =
958 (metrics.keyboardDrawSpecialOutlineWhenUnselected && isSpecialKey) || metrics.keyboardOutlineAllUnselected;
959 if (shouldDrawOutline) {
960 if (cr > 0) {
961 renderer.drawRoundedRect(rect.x, rect.y, rect.width, rect.height, 1, cr, true);
962 } else {
963 renderer.drawRect(rect.x, rect.y, rect.width, rect.height);
964 }
965 }
966 }
967
968 const bool invert = isSelected && !inactiveSelection;

Callers 1

renderMethod · 0.45

Calls 9

fillRoundedRectMethod · 0.80
drawRectMethod · 0.80
fillRectDitherMethod · 0.80
fillRectMethod · 0.80
drawRoundedRectMethod · 0.80
drawLineMethod · 0.80
getTextWidthMethod · 0.80
getLineHeightMethod · 0.80
drawTextMethod · 0.80

Tested by

no test coverage detected