Use theme color for textbox cursor and fix #4947

- 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
This commit is contained in:
Alayan 2023-12-14 18:22:18 +01:00
parent f8db600d09
commit bba568d9b8
No known key found for this signature in database
3 changed files with 14 additions and 6 deletions

View File

@ -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 -->

View File

@ -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);
}
}
// -----------------------------------------------------------------------------

View File

@ -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.