Skip to content

Commit

Permalink
Correct spelling of caret.
Browse files Browse the repository at this point in the history
  • Loading branch information
billyquith committed Aug 13, 2016
1 parent 8fe3559 commit 5d6393d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions source/gwork/include/Gwork/Controls/TextBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ namespace Gwk
OnSelectAll(this);
}

virtual void MakeCaratVisible();
virtual void MakeCaretVisible();

virtual void OnEnter();

Expand Down Expand Up @@ -133,7 +133,7 @@ namespace Gwk

virtual bool OnKeyReturn(bool bDown) override;
virtual void Render(Skin::Base* skin) override;
virtual void MakeCaratVisible() override;
virtual void MakeCaretVisible() override;

virtual bool OnKeyHome(bool bDown) override;
virtual bool OnKeyEnd(bool bDown) override;
Expand Down
34 changes: 17 additions & 17 deletions source/gwork/source/Controls/TextBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ void TextBox::RefreshCursorBounds()
{
m_fNextCaretColorChange = Gwk::Platform::GetTimeInSeconds()+1.5f;
m_caretColor = Gwk::Color(30, 30, 30, 255);
MakeCaratVisible();
MakeCaretVisible();
Gwk::Rect pA = GetCharacterPosition(m_cursorPos);
Gwk::Rect pB = GetCharacterPosition(m_cursorEnd);
m_rectSelectionBounds.x = std::min(pA.x, pB.x);
Expand Down Expand Up @@ -393,29 +393,29 @@ void TextBox::OnMouseMoved(int x, int y, int /*deltaX*/, int /*deltaY*/)
SetCursorPos(iChar);
}

void TextBox::MakeCaratVisible()
void TextBox::MakeCaretVisible()
{
if (m_text->Width() < Width())
{
m_text->SetPosition(m_align);
}
else
{
int iCaratPos = m_text->GetCharacterPosition(m_cursorPos).x;
int iRealCaratPos = iCaratPos+m_text->X();
int iCaretPos = m_text->GetCharacterPosition(m_cursorPos).x;
int iRealCaretPos = iCaretPos+m_text->X();
int iSlidingZone = m_text->GetFont()->size+1; // Width()*0.1f

// If the carat is already in a semi-good position, leave it.
if (iRealCaratPos >= iSlidingZone && iRealCaratPos <= Width()-iSlidingZone)
if (iRealCaretPos >= iSlidingZone && iRealCaretPos <= Width()-iSlidingZone)
return;

int x = 0;

if (iRealCaratPos > Width()-iSlidingZone)
x = Width()-iCaratPos-iSlidingZone;
if (iRealCaretPos > Width()-iSlidingZone)
x = Width()-iCaretPos-iSlidingZone;

if (iRealCaratPos < iSlidingZone)
x = -iCaratPos+iSlidingZone;
if (iRealCaretPos < iSlidingZone)
x = -iCaretPos+iSlidingZone;

// Don't show too much whitespace to the right
if (x+m_text->Width() < Width()-GetPadding().right)
Expand Down Expand Up @@ -567,7 +567,7 @@ void TextBoxMultiline::Render(Skin::Base* skin)
skin->GetRender()->DrawFilledRect(m_rectCaretBounds);
}

void TextBoxMultiline::MakeCaratVisible()
void TextBoxMultiline::MakeCaretVisible()
{
if (m_text->Height() < Height())
{
Expand All @@ -582,29 +582,29 @@ void TextBoxMultiline::MakeCaratVisible()
//if ( pos & Position::CenterV ) y = bounds.y + ( bounds.h - Height() ) * 0.5;

Rect pos = m_text->GetCharacterPosition(m_cursorPos);
int iCaratPos = pos.y; // + pos.h;
int iRealCaratPos = iCaratPos+m_text->Y();
int iCaretPos = pos.y; // + pos.h;
int iRealCaretPos = iCaretPos+m_text->Y();
//int iSlidingZone = m_text->GetFont()->size; //Width()*0.1f

// If the carat is already in a semi-good position, leave it.
// int mi = GetPadding().top;
// int ma = Height()-pos.h-GetPadding().bottom;
if (iRealCaratPos >= GetPadding().top && iRealCaratPos <= Height()-pos.h-
if (iRealCaretPos >= GetPadding().top && iRealCaretPos <= Height()-pos.h-
GetPadding().bottom)
return;

int y = 0;

// bottom of carat too low
if (iRealCaratPos > Height()-pos.h-GetPadding().bottom)
if (iRealCaretPos > Height()-pos.h-GetPadding().bottom)
{
//align bottom
y = Height()-iCaratPos-pos.h-GetPadding().bottom;
y = Height()-iCaretPos-pos.h-GetPadding().bottom;
}

// top of carat too low
if (iRealCaratPos < GetPadding().top)
y = -iCaratPos+GetPadding().top;
if (iRealCaretPos < GetPadding().top)
y = -iCaretPos+GetPadding().top;

// Don't show too much whitespace to the bottom
if (y+m_text->Height() < Height()-GetPadding().bottom)
Expand Down

0 comments on commit 5d6393d

Please sign in to comment.