Skip to content

Commit

Permalink
Use theme color for textbox cursor and fix #4947
Browse files Browse the repository at this point in the history
- Change the colors of the background and borders of the textbox to ensure they always contrast with each other
- Make the color of the textbox cursor the same as the skin's text color - this ensure it always has good contrast
- Offset the display of text slightly in the textbox. This avoids the cursor 'blending in' with the textbox border
  • Loading branch information
Alayan-stk-2 committed Dec 14, 2023
1 parent f8db600 commit bba568d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
8 changes: 4 additions & 4 deletions data/skins/coal/stkskin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -338,12 +338,12 @@ to specify all types of ttf.
<color type="tips_background" state="neutral" a="120" r="0" g="0" b="0" />

<!-- Text field color -->
<color type="text_field" state="background" a="255" r="35" g="35" b="35" />
<color type="text_field" state="background" a="255" r="50" g="50" b="50" />
<color type="text_field" state="background_focused" a="255" r="15" g="15" b="15" />
<color type="text_field" state="background_deactivated" a="255" r="90" g="90" b="90" />
<color type="text_field" state="background_deactivated" a="255" r="120" g="120" b="120" />
<color type="text_field" state="background_marked" a="128" r="220" g="220" b="220" />
<color type="text_field" state="neutral" a="255" r="35" g="35" b="35" />
<color type="text_field" state="focused" a="255" r="15" g="15" b="15" />
<color type="text_field" state="neutral" a="255" r="20" g="20" b="20" />
<color type="text_field" state="focused" a="255" r="235" g="235" b="235" />
<color type="text_field" state="deactivated" a="255" r="90" g="90" b="90" />

<!-- Rating star image -->
Expand Down
10 changes: 9 additions & 1 deletion src/guiengine/skin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2918,7 +2918,15 @@ u32 Skin::getIcon (EGUI_DEFAULT_ICON icon) const

s32 Skin::getSize (EGUI_DEFAULT_SIZE texture_size) const
{
return m_fallback_skin->getSize(texture_size);
switch(texture_size)
{
// TODO : make this depend on the text-size parameter and/or skin
// and perhaps rename it
case EGDS_TEXT_DISTANCE_X:
return 10;
default:
return m_fallback_skin->getSize(texture_size);
}
}

// -----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/guiengine/widgets/CGUIEditBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,7 @@ void CGUIEditBox::draw()
core::rect< s32 > caret_rect = CurrentTextRect;
caret_rect.UpperLeftCorner.X += m_cursor_distance - 1;
caret_rect.LowerRightCorner.X = caret_rect.UpperLeftCorner.X + 2;
GL32_draw2DRectangle(video::SColor(255, 0, 0, 0), caret_rect);
GL32_draw2DRectangle(skin->getColor(EGDC_BUTTON_TEXT), caret_rect);
}

// Return the override color information to its previous settings.
Expand Down

0 comments on commit bba568d

Please sign in to comment.