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

Input Box Carrot Rendering Issues #15

Open
TBye101 opened this issue May 8, 2018 · 3 comments
Open

Input Box Carrot Rendering Issues #15

TBye101 opened this issue May 8, 2018 · 3 comments

Comments

@TBye101
Copy link
Owner

TBye101 commented May 8, 2018

The carrot of input boxes displays incorrectly until it is clicked on for the first time. It bugs me, and I don't even have OCD. The carrot should be centered, like after the input box is clicked on.

@TBye101 TBye101 added the bug label May 8, 2018
@TBye101 TBye101 self-assigned this May 8, 2018
@TBye101
Copy link
Owner Author

TBye101 commented Jul 12, 2018

Here's where the location to display the carrot is calculated at:

https://github.com/SneakyTactician/MagicalLife/blob/master/MagicalLifeGUIWindows/Rendering/GUI/GUIRenderer.cs
CalculateCarrotBounds(MonoInputBox textbox, GUIContainer container)

@TBye101 TBye101 removed their assignment Jul 12, 2018
@danielbizon1988
Copy link

{X:0 Y:0}
{X:5.5 Y:9}

first is where the carrot starts off, 2nd is after typing. Changing the following values did not change anything with how the carrot works:

Vector2 pos = new Vector2(textbox.DrawingBounds.Center.X, textbox.DrawingBounds.Center.Y);
#pragma warning disable RCS1096 // Use bitwise operation instead of calling 'HasFlag'.
if (textbox.TextAlignment.HasFlag(Alignment.Left))
{
origin.X += (textbox.DrawingBounds.Width * 2) - (size.X / 2);
}
if (textbox.TextAlignment.HasFlag(Alignment.Right))
{
origin.X -= (textbox.DrawingBounds.Width / 2) - (size.X / 2);
}
if (textbox.TextAlignment.HasFlag(Alignment.Top))
{
origin.Y += (textbox.DrawingBounds.Height / 2) - (size.Y / 2);
}
if (textbox.TextAlignment.HasFlag(Alignment.Bottom))
{
origin.Y -= (textbox.DrawingBounds.Height / 2) - (size.Y / 2);
}

The only location I could get the carrot to move initially was:
int XPos = (int)Math.Round(origin.X + textbox.DrawingBounds.X + textbox.Font.MeasureString(TextBeforeCarrot).X) + container.DrawingBounds.X;
int YPos = (int)Math.Round(origin.Y + textbox.DrawingBounds.Y) + container.DrawingBounds.Y;

but it would stay that way even after typing (so changing the X would keep it X distance away the entire time typing). Continuing to work on this.

@TBye101
Copy link
Owner Author

TBye101 commented Jul 13, 2018

Yeah, it's a tough one. I tried to fix it a month ago, and got nowhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants