Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX/InputText messes up the cursor with freetype font &parent scaled #146

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions oxygine/src/oxygine/InputText.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ namespace oxygine
void InputText::updateText()
{
_textActor->setText(_txt);
float x = static_cast<float>(_textActor->getTextRect().getRight());
_cursor->setX(x);
float x = static_cast<float>(_textActor->getTextRect(_textActor->globalScaleX()).getRight());
_cursor->setX(x+1);


Event evnt(EVENT_TEXT_CHANGED);
Expand Down
19 changes: 18 additions & 1 deletion oxygine/src/oxygine/actor/Actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,24 @@ namespace oxygine
return stream.str();
}

float Actor::globalScaleX() const {
float scale = getScaleX();
const Actor* a = this;
while (a->getParent()) {
a = a->getParent();
scale*=a->getScaleX();
}
return scale;
}
float Actor::globalScaleY() const {
float scale = getScaleY();
const Actor* a = this;
while (a->getParent()) {
a = a->getParent();
scale*=a->getScaleY();
}
return scale;
}
pointer_index Actor::getPressed(MouseButton b) const
{
return _pressedButton[b];
Expand Down Expand Up @@ -1487,7 +1505,6 @@ namespace oxygine
}



spTween setTimeout(timeMS dur, const EventCallback& cb, Actor* root)
{
if (!root)
Expand Down
2 changes: 2 additions & 0 deletions oxygine/src/oxygine/actor/Actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ namespace oxygine
//converts global position (position in Stage space) to local space
Vector2 stage2local(const Vector2& pos = Vector2(0, 0), Actor* stage = 0) const;
Vector2 stage2local(float x, float y, Actor* stage = 0) const;
float globalScaleX() const;
float globalScaleY() const;

typedef Property2Args<float, Vector2, const Vector2&, Actor, &Actor::getPosition, &Actor::setPosition> TweenPosition;
typedef Property<float, float, Actor, &Actor::getX, &Actor::setX> TweenX;
Expand Down