TextBox text is now vertically centered
This commit is contained in:
parent
d38bd1cbf5
commit
7e0d64e8bd
@ -92,11 +92,18 @@ func (element *TextBox) HandleMouseMove (x, y int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (element *TextBox) atPosition (position image.Point) int {
|
func (element *TextBox) textOffset () image.Point {
|
||||||
padding := element.theme.Padding(theme.PatternInput)
|
padding := element.theme.Padding(theme.PatternInput)
|
||||||
offset := element.Bounds().Min.Add (image.Pt (
|
bounds := element.Bounds()
|
||||||
|
innerBounds := padding.Apply(bounds)
|
||||||
|
textHeight := element.valueDrawer.LineHeight().Round()
|
||||||
|
return bounds.Min.Add (image.Pt (
|
||||||
padding[artist.SideLeft] - element.scroll,
|
padding[artist.SideLeft] - element.scroll,
|
||||||
padding[artist.SideTop]))
|
padding[artist.SideTop] + (innerBounds.Dy() - textHeight) / 2))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (element *TextBox) atPosition (position image.Point) int {
|
||||||
|
offset := element.textOffset()
|
||||||
textBoundsMin := element.valueDrawer.LayoutBounds().Min
|
textBoundsMin := element.valueDrawer.LayoutBounds().Min
|
||||||
return element.valueDrawer.AtPosition (
|
return element.valueDrawer.AtPosition (
|
||||||
fixedutil.Pt(position.Sub(offset).Add(textBoundsMin)))
|
fixedutil.Pt(position.Sub(offset).Add(textBoundsMin)))
|
||||||
@ -115,8 +122,6 @@ func (element *TextBox) HandleKeyDown(key input.Key, modifiers input.Modifiers)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: text selection with shift
|
|
||||||
|
|
||||||
scrollMemory := element.scroll
|
scrollMemory := element.scroll
|
||||||
altered := true
|
altered := true
|
||||||
textChanged := false
|
textChanged := false
|
||||||
@ -358,11 +363,7 @@ func (element *TextBox) draw () {
|
|||||||
padding := element.theme.Padding(theme.PatternInput)
|
padding := element.theme.Padding(theme.PatternInput)
|
||||||
innerCanvas := canvas.Cut(element.core, padding.Apply(bounds))
|
innerCanvas := canvas.Cut(element.core, padding.Apply(bounds))
|
||||||
pattern.Draw(element.core, bounds)
|
pattern.Draw(element.core, bounds)
|
||||||
|
offset := element.textOffset()
|
||||||
offset := bounds.Min.Add (image.Point {
|
|
||||||
X: padding[artist.SideLeft] - element.scroll,
|
|
||||||
Y: padding[artist.SideTop],
|
|
||||||
})
|
|
||||||
|
|
||||||
if element.Focused() && !element.dot.Empty() {
|
if element.Focused() && !element.dot.Empty() {
|
||||||
// draw selection bounds
|
// draw selection bounds
|
||||||
|
Reference in New Issue
Block a user