haiku/headers/os
John Scipione d9385a9d38 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>
2020-09-07 22:10:36 +00:00
..
add-ons Tracker: Allow add-ons to dynamically extend popup menu. 2018-07-19 14:00:48 +00:00
app RosterPrivate: add IsShutDownInProgress() 2019-12-21 20:32:31 +00:00
arch arm64: Add more headers for code compilation 2019-09-01 03:02:49 +00:00
be_apps be_apps/ServicesDaemon: Remove. 2016-07-29 18:41:30 -04:00
bluetooth bluetooth: ioctls always pass size on Haiku. 2018-11-18 14:42:09 -05:00
device Revert r42812. As pointed by Michael, one can use 2011-10-24 21:02:14 +00:00
drivers block_cache: Change signature of *_etc() functions 2020-06-20 18:10:03 +00:00
game More build fixes. 2020-01-25 21:35:34 +01:00
interface IK: align BTextView text rect/fix alignment 2020-09-07 22:10:36 +00:00
kernel arm64: Add more headers for code compilation 2019-09-01 03:02:49 +00:00
locale locale kit: allow creating a catalog without entry_ref 2020-09-01 18:14:57 +00:00
mail Migrate the BMailComponent docs to the Haiku Book. 2017-12-25 19:43:51 -05:00
media PVS V522: null pointer dereferences 2019-07-16 20:44:32 +00:00
midi Fix clang warning "mismatched-tags" 2020-03-23 01:30:23 +00:00
midi2 style cleanup 2006-09-21 13:04:59 +00:00
net docs: Add documentation for BUrlProtocolListener 2020-06-20 18:13:33 +00:00
package Package Kit: reduce identifer/base-url confusion 2020-05-09 20:04:50 +00:00
storage Remove Spurious B_BEOS_DATA_DIRECTORY 2017-05-08 22:17:53 +02:00
support PVS V591: non void functions must return something 2019-07-17 01:57:50 +00:00
translation TranslationErrors.h: document as deprecated. 2019-04-15 20:45:19 +02:00
AppKit.h added these master include files for better R5 compatibility when compiling 2002-10-23 13:48:14 +00:00
Be.h Patch by Jorma Karvonen: Add LocaleKit.h header and also add it to Be.h. Thanks! 2010-05-16 16:07:55 +00:00
BeBuild.h Fix build of Haiku on gcc10 host 2020-05-21 01:35:10 +00:00
DeviceKit.h added these master include files for better R5 compatibility when compiling 2002-10-23 13:48:14 +00:00
GameKit.h added these master include files for better R5 compatibility when compiling 2002-10-23 13:48:14 +00:00
InterfaceKit.h added these master include files for better R5 compatibility when compiling 2002-10-23 13:48:14 +00:00
KernelKit.h added these master include files for better R5 compatibility when compiling 2002-10-23 13:48:14 +00:00
LocaleKit.h Remove even more Locale Kit cruft. 2017-07-30 14:46:41 -04:00
MailKit.h added these master include files for better R5 compatibility when compiling 2002-10-23 13:48:14 +00:00
MediaKit.h Make BMediaRecorder public 2017-01-10 21:34:20 +01:00
MidiKit.h added these master include files for better R5 compatibility when compiling 2002-10-23 13:48:14 +00:00
NetKit.h * Rewrote NetKit.h, and added the libnetapi headers. 2008-06-24 09:03:44 +00:00
NetworkKit.h Added the new headers to the NetworkKit.h all-in-one header. 2010-10-27 14:16:19 +00:00
StorageKit.h StorageKit.h still included the Alias.h header file I removed with the previous commit. 2007-07-06 12:52:01 +00:00
SupportKit.h added these master include files for better R5 compatibility when compiling 2002-10-23 13:48:14 +00:00
TranslationKit.h added these master include files for better R5 compatibility when compiling 2002-10-23 13:48:14 +00:00