BTextView: Fixup AdoptSystemColors() and HasSystemColors()
Replace private _UsesSystemColors() with public HasSystemColors() and make sure to consider the tints when checking if system colors are used or not. Document HasSytemColors() in the Haiku Book. Change-Id: I78de4904d5ddb24b98ad27eb93d4e5ccb330d76a Reviewed-on: https://review.haiku-os.org/c/haiku/+/8897 Haiku-Format: Haiku-format Bot <[email protected]> Tested-by: Commit checker robot <[email protected]> Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
74ef92bc55
commit
16c6cc4418
@@ -1363,11 +1363,32 @@
|
||||
- \c B_DOCUMENT_BACKGROUND_COLOR for LowUIColor()
|
||||
- \c B_DOCUMENT_TEXT_COLOR for HighUIColor()
|
||||
|
||||
This is reimplemented from BView which uses panel colors.
|
||||
|
||||
View and low colors tinted \c B_DARKEN_1_TINT (inverse on dark) if uneditable.
|
||||
|
||||
Does not alter text color.
|
||||
|
||||
\see BView::AdoptSystemColors(), MakeEditable()
|
||||
\see BView::AdoptSystemColors(), MakeEditable(), HasSystemColors()
|
||||
|
||||
\since Haiku R1
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\fn bool BTextView::HasSystemColors() const
|
||||
\brief Tests whether or not the text view is using system colors.
|
||||
|
||||
- \c B_DOCUMENT_BACKGROUND_COLOR for ViewUIColor() either untinted or \c B_DARKEN_1_TINT
|
||||
- \c B_DOCUMENT_BACKGROUND_COLOR for LowUIColor() either untinted or \c B_DARKEN_1_TINT
|
||||
- \c B_DOCUMENT_TEXT_COLOR for HighUIColor() untinted
|
||||
|
||||
Does not consider text color.
|
||||
|
||||
\returns \c true if using system colors either untinted or using uneditable tint
|
||||
\c false otherwise.
|
||||
|
||||
\see AdoptSystemColors(), MakeEditable()
|
||||
|
||||
\since Haiku R1
|
||||
*/
|
||||
|
||||
@@ -132,6 +132,7 @@ public:
|
||||
void GetSelection(int32* _start, int32* _end) const;
|
||||
|
||||
void AdoptSystemColors();
|
||||
bool HasSystemColors() const;
|
||||
|
||||
void SetFontAndColor(const BFont* font,
|
||||
uint32 mode = B_FONT_ALL,
|
||||
@@ -428,8 +429,7 @@ private:
|
||||
float _TextHeight();
|
||||
BRect _TextRect();
|
||||
|
||||
float _UneditableTint();
|
||||
bool _UsesSystemColors();
|
||||
float _UneditableTint() const;
|
||||
|
||||
private:
|
||||
BPrivate::TextGapBuffer* fText;
|
||||
|
||||
@@ -1601,6 +1601,20 @@ BTextView::AdoptSystemColors()
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
BTextView::HasSystemColors() const
|
||||
{
|
||||
float tint = B_NO_TINT;
|
||||
float uneditableTint = _UneditableTint();
|
||||
|
||||
return ViewUIColor(&tint) == B_DOCUMENT_BACKGROUND_COLOR
|
||||
&& (tint == B_NO_TINT || tint == uneditableTint)
|
||||
&& LowUIColor(&tint) == B_DOCUMENT_BACKGROUND_COLOR
|
||||
&& (tint == B_NO_TINT || tint == uneditableTint)
|
||||
&& HighUIColor(&tint) == B_DOCUMENT_TEXT_COLOR && tint == B_NO_TINT;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BTextView::SetFontAndColor(const BFont* font, uint32 mode, const rgb_color* color)
|
||||
{
|
||||
@@ -2385,7 +2399,7 @@ BTextView::MakeEditable(bool editable)
|
||||
fEditable = editable;
|
||||
|
||||
// apply uneditable colors or unapply them
|
||||
if (_UsesSystemColors())
|
||||
if (HasSystemColors())
|
||||
AdoptSystemColors();
|
||||
|
||||
// TextControls change the color of the text when
|
||||
@@ -6226,23 +6240,12 @@ BTextView::_TextRect()
|
||||
|
||||
|
||||
float
|
||||
BTextView::_UneditableTint()
|
||||
BTextView::_UneditableTint() const
|
||||
{
|
||||
return ui_color(B_DOCUMENT_BACKGROUND_COLOR).IsLight() ? B_DARKEN_1_TINT : 0.853;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
BTextView::_UsesSystemColors()
|
||||
{
|
||||
float tint = B_NO_TINT;
|
||||
|
||||
return ViewUIColor(&tint) == B_DOCUMENT_BACKGROUND_COLOR
|
||||
&& LowUIColor(&tint) == B_DOCUMENT_BACKGROUND_COLOR
|
||||
&& HighUIColor() == B_DOCUMENT_TEXT_COLOR;
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - BTextView::TextTrackState
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user