Skip to content

Commit

Permalink
Apply Guichan's changes from c9c8714df7b3a19721d3141c56978d0aaf85de29…
Browse files Browse the repository at this point in the history
… (Sept 15th 2008)

The way a text field draws itself has slightly changed. It now draws a border around its content when focused.
  • Loading branch information
Jarod42 committed Sep 4, 2024
1 parent abe55ac commit 00d8d54
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion TODO
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
* Continue rebasing from 840e2ea3b13eb24057b8505eaa615d4e6bd363c6
* Continue rebasing from ac25684370f72e5e204bd994fd736e630fb8425a
* Add a focus listener interface.
* Make focus apply synchronously.
* Graphics and input objects for DirectX.
Expand Down
9 changes: 8 additions & 1 deletion src/widgets/textfield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ namespace gcn
graphics->setColor(getBackgroundColor());
graphics->fillRectangle(Rectangle(0, 0, getWidth(), getHeight()));

if (isFocused())
{
graphics->setColor(getSelectionColor());
graphics->drawRectangle(Rectangle(0, 0, getWidth() - 2, getHeight() - 2));
graphics->drawRectangle(Rectangle(1, 1, getWidth() - 4, getHeight() - 4));
}

if (isFocused() && isEditable())
{
drawCaret(graphics, getFont()->getWidth(mText.substr(0, mCaretPosition)) - mXScroll);
Expand Down Expand Up @@ -233,7 +240,7 @@ namespace gcn

void TextField::adjustSize()
{
setWidth(getFont()->getWidth(mText) + 4);
setWidth(getFont()->getWidth(mText) + 7);
adjustHeight();

fixScroll();
Expand Down

0 comments on commit 00d8d54

Please sign in to comment.