History log of /haiku/src/kits/interface/TextInput.h
Revision Date Author Comments
# d9385a9d 20-Jul-2020 John Scipione <jscipione@gmail.com>

IK: align BTextView text rect/fix alignment

Recalculate line breaks in FrameResized() if word-wrap is on, otherwise
only move the text rect into position. StyledEdit was recalculating line
breaks before on resize (we have to in this mode) and the frame offset
updates for non-wrapping text views are inexpensive. This makes resizing
text view's work like StyledEdit everywhere.

Scroll to cursor when word-wrap setting changes if text view is editable.
If you are viewing a long document changing word-wrap can move the cursor
quite far, so scroll back to it.

Fix _ActualTabWidth() pen location for right and center-aligned text views
so that tabs widths are calculated correctly.

Reset fTextRect horizontal limits to bounds minus insets in
_RecalculateLineBreaks(), then grow fTextRect based on alignment when
wrap is off.

Fixing insets also fixes right and center-aligned BTextViews.
Left-aligned text view's grow right, right-aligned ones grow left,
and center-aligned ones grow out.

Make extra scrolling space for all aligned text views go the other way
from how it did in hrev24130 (and on left-aligned text view's too) so
that half the text is visible when you edit past the end or before the
beginnning of a text view instead of none of it.

Fixes #1651 #12608 #13796 #15189

Do not _RecalculateLineBreaks() if text view bounds are invalid.
In SetText() detect invalid text view bounds and resize the view to the
width and height of the first line. Then recalculate line breaks.
This fixes BAlert text view size issues.

Fixes #16481 (regression from hrev54496.)

Remove useless and heavy computation. There is no point in computing line
breaks for a 10px wide text view and it takes a long time because it needs
a lot of linebreaks. The view eventually gets laid out properly.

Fixes #5582 (which was not locale-related, after all.)

Only apply default insets if text rect is set to bounds. This ensures
that apps that manipulate the text rect can continue to do so without
the default insets interfering while apps that don't can benefit
from the defaults. If you want to set the text rect to bounds and
not use the default insets you must override the default by calling
SetInsets(). This prevent the default insets from being applied once
apps have changed the text rect fixing a bug in Icon-O-Matic where the
text rect insets were being applied incorrectly.

Fixes #16488 (regression from hrev54496.)

Reduce left and right insets inside text views from full label spacing
to half label spacing. Unify padding between BTextControl and BTextView.

Move fLayoutData->UpdateInsets() to private BTextView::_UpdateInsets()
because we need access to BTextView member variables when deciding
whether or not to add the default padding or not.

_UpdateInsets() changes:
* Don't update insets if BTextView::SetInsets() was called.
* Don't add default insets unless fTextRect is set to view Bounds().
* Do not set the right and bottom insets to left and top if negative,
set them to 0 like we do to left and top -- DeskCalc bug otherwise.

Fixes #15688

Other BTextView fixes:
* Replace max_c and min_c with std::max and std::min respectively.
* Remove scrolling from one instance of BTextView::SetText() as it
produced undesired results while editing a scrolled text view.
* Add default insets in _UpdateInsets()
* Fix scrolling when entering and deleting text so that some part of
the text is always visible. Make visible scroll width depend on font
size.
* Allow scrolling to a negative offset in x but not y. This allows you
to scroll the entire contents of right and centered-aligned text views
whose content does not fit in the box.
* Change _Refresh() to take an offset instead of a bool so that you can
scroll to any offset.
* Replace TextLength() with fText->Length() in a couple of places.

TextControl changes:
* Set text rect in BTextControl::DoLayout().
* Remove AlignTextRect() from TextInput.

Fix the following problems in apps:

ScreenSaver: Set text rect in PreviewView::AddPreview().
Tracker: Set "Edit name" text view insets to 2. Tweek text rect position
to be on top of label in icon, mini-icon, and list mode. Add a TODO that
the text rect is a pixel off from the name on some files.
Mail: Remove _AlignTextRect() and FrameResized() from AddressTextControl.
Use default insets on the text view, defaults are fine here.
DeskCalc: Set insets based on font size in ExpressionTextView
SetTextRect() instead of manipulating the text rect.
Remove _CheckTextRect() and related methods from InputTextView.
Icon-O-Matic: Remove _CheckTextRect() and related methods from InputTextView.
WebPositive: Remove _AlignTextRect() and FrameResized() from URLTextView
and call SetInsets().
StyledEdit: Word-wrap and FrameResized() changes ported to BTextView.

Fixes #16476 #16480 #16488 (regressions from hrev54496.)

Change-Id: Ifeca6077f8815ccd86d5a3880f99556298aaf0fe
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3152
Reviewed-by: John Scipione <jscipione@gmail.com>


# 22758f16 17-Aug-2020 John Scipione <jscipione@gmail.com>

Revert "IK: align BTextView text rect/fix alignment"

This reverts commit a9b301871d06c0ebe42d22b31c685abed5107acd.

hrev54496

Change-Id: Ife3c834ad98d330f04976d9adf3b1553e7aca034
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3153
Reviewed-by: Axel Dörfler <axeld@pinc-software.de>


# a9b30187 20-Jul-2020 John Scipione <jscipione@gmail.com>

IK: align BTextView text rect/fix alignment

Preserve passed in text rect in fTextRext (unless in layout)
and create an internal version fAlignedTextRect which is used
in place of fTextRect. fAlignedTextRext is aligned to fit the
text rect bounds and grows to fit. fAlignedTextRect always grows
vertically but only grows horizontally if wrap is off.

Left-aligned text view's grow right, right-aligned ones grow left,
and center center aligned ones grow out.

Set fTextRect to bounds in _DoLayout().

Reduce left and right padding inside text views from full label
spacing to half label spacing. Unify padding between BTextControl
and BTextView.

Fixing padding also fixes right and center-aligned BTextViews.

Undo extra scrolling for non-left text views from hrev24130 fixing
a scrolling left and right with mouse bug when it shouldn't.

Replace max_c and min_c with std::max and std::min respectively.

Remove scrolling from one instance of BTextView::SetText as it
produced undesired results while editing a scrolled text view.

Set text rect in BTextControl::DoLayout() and ScreenSaver
PreviewView::AddPreview().

Don't add padding if BTextView::SetInsets() is called. Set insets
to 0 in Tracker "Edit name" setting which prevents default padding
from being added. This is so that when you rename a file in Tracker
the TextView appears on top of the file name text with no padding.

80 char limit fixes.

Fixes #1651 #12608 #13796 #15189 #15688

Change-Id: I8c6106effc612f49aff374f29742471628b5df86
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3054
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>


# 1c9c7729 12-Jan-2020 X512 <danger_mail@list.ru>

Interface Kit: make BTextControl behave like BeOS

Contents of BTextControl should be not selected if text is directly clicked.
Selection should be removed if BTextView lose focus.

Change-Id: Ifba914c2ada4fc1aac88205f69a64a4356009469
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2109
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 349c911e 16-Sep-2008 Stephan Aßmus <superstippi@gmx.de>

* Implemented a lot of layout related methods and resolved a few TODOs by
doing a lot of these things the same way as BMenuField are already doing.
Perhaps a private helper class could be refactored from these two controls
to avoid duplicating a lot of this code, although there are a few subtle
differences here and there.

These changes make a BTextControl behave properly in the layout management
frame work, in case CreateLabelLayoutItem() and CreateTextViewLayoutItem()
are _not_ used to layout the BTextControl.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27584 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 46ea5b1e 25-Feb-2008 Stephan Aßmus <superstippi@gmx.de>

Further improvements to auto scrolling and text rect + container view resizing:
* Renaming things in Tracker list mode no longer magically grows the text view.
* ScrollToOffset() is not supposed to depend on the existence of any scroll
bars, in R5 text views simply scroll to where they need to. This fixes
renaming things in Tracker when hitting the window bounds (text widget stops
growing and starts to autoscroll) and also the Text tool in WonderBrush.
* _ScrollToOffset() is therefor no longer needed.
* The insets of the text rect are not so interesting as the original width.
In auto resizing mode, the original width is important when there is no
container view. In this setup, the text rect auto resizing is mainly needed
for auto scrolling, but it should never shrink below the original size.
* Further improved auto scrolling for right aligned and center aligned text
views, it works like R5 now. Also take the line height into account when
checking for the bounds bottom. Removed extra spacing for vertical
scrolling.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24130 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b8872c02 24-Feb-2008 Stephan Aßmus <superstippi@gmx.de>

BTextControl:
* Placed _BTextInput_ into BPrivate namespace.
* Made _BTextInput_::AlignTextRect() smarter, it centers the line vertically,
for the case that the BTextControl has a larger label font. Improved insets
for asthetics.
* Used _BTextInput_::AlignTextRect() consistently in BTextControl, no more
custom calls to SetTextRect(). Account for minimum vertical inset of 2
pixels in GetPreferredSize().
* Consistendly select all text when gaining focus in _BTextInput_.
* Override MouseDown() in case the control did not have focus before, or else
BTextView::MouseDown() will deselct the text again and place the cursor.
(in line with BeOS behavior)
* Removed unused fBool member from _BTextInput_ and other cleanup.

BTextView:
* Reimplemented BTextView::_AutoResize() so that it works well with
BTextControl and autoscrolling when the alignment is not B_ALIGN_LEFT.
I needed two new members for this, fLeftInset and fRightInset which are
the original insets from the fTextRects. It might currently be broken
for renaming things in Tracker, I will have to check. _AutoResize() no
longer messes up the fTextRect insets.
* Fixed stray carrets sometimes being left over, mostly when auto scrolling,
but I observed them in other cases as well.
* Prevent negative scrolling offsets when autoscrolling. Fixes weird scrolling
offsets when navigating to the left.
* Reset scrolling to B_ORIGIN when SetText() is called. Fixes for example
starting to type in the middle of the control in Vision when entering new
text and autoscrolling was triggered before.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24101 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f2476bcc 04-Oct-2007 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Patch by Rene Gollent: TextViews now can scroll even if they aren't
attached to a BScrollView.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22432 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fab61b62 18-Jun-2007 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Moved TextInput.h to src/kits/interface as it's only used there.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21455 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 349c911ee9194e4f25c31267a6464f5399c71e59 16-Sep-2008 Stephan Aßmus <superstippi@gmx.de>

* Implemented a lot of layout related methods and resolved a few TODOs by
doing a lot of these things the same way as BMenuField are already doing.
Perhaps a private helper class could be refactored from these two controls
to avoid duplicating a lot of this code, although there are a few subtle
differences here and there.

These changes make a BTextControl behave properly in the layout management
frame work, in case CreateLabelLayoutItem() and CreateTextViewLayoutItem()
are _not_ used to layout the BTextControl.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27584 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 46ea5b1e49005fa48c79898fb3ad9f8f28476b52 25-Feb-2008 Stephan Aßmus <superstippi@gmx.de>

Further improvements to auto scrolling and text rect + container view resizing:
* Renaming things in Tracker list mode no longer magically grows the text view.
* ScrollToOffset() is not supposed to depend on the existence of any scroll
bars, in R5 text views simply scroll to where they need to. This fixes
renaming things in Tracker when hitting the window bounds (text widget stops
growing and starts to autoscroll) and also the Text tool in WonderBrush.
* _ScrollToOffset() is therefor no longer needed.
* The insets of the text rect are not so interesting as the original width.
In auto resizing mode, the original width is important when there is no
container view. In this setup, the text rect auto resizing is mainly needed
for auto scrolling, but it should never shrink below the original size.
* Further improved auto scrolling for right aligned and center aligned text
views, it works like R5 now. Also take the line height into account when
checking for the bounds bottom. Removed extra spacing for vertical
scrolling.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24130 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b8872c02c1d02d892037bcdb6cbbb3dfe482b98b 24-Feb-2008 Stephan Aßmus <superstippi@gmx.de>

BTextControl:
* Placed _BTextInput_ into BPrivate namespace.
* Made _BTextInput_::AlignTextRect() smarter, it centers the line vertically,
for the case that the BTextControl has a larger label font. Improved insets
for asthetics.
* Used _BTextInput_::AlignTextRect() consistently in BTextControl, no more
custom calls to SetTextRect(). Account for minimum vertical inset of 2
pixels in GetPreferredSize().
* Consistendly select all text when gaining focus in _BTextInput_.
* Override MouseDown() in case the control did not have focus before, or else
BTextView::MouseDown() will deselct the text again and place the cursor.
(in line with BeOS behavior)
* Removed unused fBool member from _BTextInput_ and other cleanup.

BTextView:
* Reimplemented BTextView::_AutoResize() so that it works well with
BTextControl and autoscrolling when the alignment is not B_ALIGN_LEFT.
I needed two new members for this, fLeftInset and fRightInset which are
the original insets from the fTextRects. It might currently be broken
for renaming things in Tracker, I will have to check. _AutoResize() no
longer messes up the fTextRect insets.
* Fixed stray carrets sometimes being left over, mostly when auto scrolling,
but I observed them in other cases as well.
* Prevent negative scrolling offsets when autoscrolling. Fixes weird scrolling
offsets when navigating to the left.
* Reset scrolling to B_ORIGIN when SetText() is called. Fixes for example
starting to type in the middle of the control in Vision when entering new
text and autoscrolling was triggered before.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24101 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f2476bcc9c193632711781727a96a3222ee1df05 04-Oct-2007 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Patch by Rene Gollent: TextViews now can scroll even if they aren't
attached to a BScrollView.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22432 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fab61b623760b244cdc3f2cfade7f214ad8e2f71 18-Jun-2007 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Moved TextInput.h to src/kits/interface as it's only used there.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21455 a95241bf-73f2-0310-859d-f6bbb57e9c96