⛏️ index : haiku.git

author John Scipione <jscipione@gmail.com> 2025-11-22 11:13:13.0 -05:00:00
committer waddlesplash <waddlesplash@gmail.com> 2025-12-31 19:24:27.0 +00:00:00
commit
08ce5659a4fbb2924ca69544be11f3b021a412f1 [patch]
tree
a7b1e90d9a2d5ce59ffdcaf789417a3e2f5dc9f2
parent
eb506aedcde1aa08de0ef7954a24327ce6088c8c
download
08ce5659a4fbb2924ca69544be11f3b021a412f1.tar.gz

Mail: Update text control colors automatically.

Remove SetStylable() call making it false.

Update low and high colors in _UpdateTextViewColors().

Update colors when B_COLORS_UPDATED message is received.

Change-Id: Iad3e3d9f46b922c7cf68e20cd7788d0d0efcb0b5
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10010
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: John Scipione <jscipione@gmail.com>

Diff

 src/apps/mail/AddressTextControl.cpp | 42 +++++++++++++++++++++++++-----------------
 src/apps/mail/AddressTextControl.h   |  2 +-
 src/apps/mail/Header.cpp             | 58 +++++++++++++++++++++++++++++++++++++++++-----------------
 3 files changed, 47 insertions(+), 55 deletions(-)

diff --git a/src/apps/mail/AddressTextControl.cpp b/src/apps/mail/AddressTextControl.cpp
index 0f178d7..9af7192 100644
--- a/src/apps/mail/AddressTextControl.cpp
+++ b/src/apps/mail/AddressTextControl.cpp
@@ -191,7 +191,6 @@
	fUpdateAutoCompleterChoices(true)
{
	MakeResizable(true);
	SetStylable(true);
	fAutoCompleter->SetModificationsReported(true);
}

@@ -643,7 +642,7 @@
	BControl::AttachedToWindow();

	fTextView->MakeSelectable(true);
	_UpdateTextViewColors();
	_UpdateTextViewColors(IsEnabled());
}


@@ -679,7 +678,7 @@
		return;

	fTextView->MakeEditable(enabled);
	_UpdateTextViewColors();
	_UpdateTextViewColors(enabled);

	if (enabled && fPopUpButton->IsHidden(this))
		fPopUpButton->Show();
@@ -699,6 +698,16 @@
AddressTextControl::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case B_COLORS_UPDATED:
			if ((IsEnabled()
				&& (message->HasColor(ui_color_name(B_DOCUMENT_BACKGROUND_COLOR))
					|| message->HasColor(ui_color_name(B_DOCUMENT_TEXT_COLOR))))
				|| message->HasColor(ui_color_name(B_PANEL_BACKGROUND_COLOR))
				|| message->HasColor(ui_color_name(B_PANEL_TEXT_COLOR))) {
				_UpdateTextViewColors(IsEnabled());
			}
			break;

		case B_SIMPLE_DATA:
		{
			int32 buttons = -1;
@@ -906,31 +915,16 @@


void
AddressTextControl::_UpdateTextViewColors()
AddressTextControl::_UpdateTextViewColors(bool enabled)
{
	BFont font;
	fTextView->GetFontAndColor(0, &font);

	rgb_color textColor;
	if (!fTextView->IsEditable() || IsEnabled())
		textColor = ui_color(B_DOCUMENT_TEXT_COLOR);
	else {
		textColor = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
			B_DISABLED_LABEL_TINT);
	}

	// set text color only, do not set high color
	rgb_color textColor = ui_color(enabled ? B_DOCUMENT_TEXT_COLOR : B_PANEL_TEXT_COLOR);
	fTextView->SetFontAndColor(&font, B_FONT_ALL, &textColor);

	rgb_color color;
	if (!fTextView->IsEditable())
		color = ui_color(B_PANEL_BACKGROUND_COLOR);
	else if (IsEnabled())
		color = ui_color(B_DOCUMENT_BACKGROUND_COLOR);
	else {
		color = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
			B_LIGHTEN_2_TINT);
	}

	fTextView->SetViewColor(color);
	fTextView->SetLowColor(color);
	// set low color and set view color to low
	fTextView->SetLowUIColor(enabled ? B_DOCUMENT_BACKGROUND_COLOR : B_PANEL_BACKGROUND_COLOR);
	fTextView->SetViewUIColor(fTextView->LowUIColor());
}
diff --git a/src/apps/mail/AddressTextControl.h b/src/apps/mail/AddressTextControl.h
index 1fa762e..dda117f 100644
--- a/src/apps/mail/AddressTextControl.h
+++ b/src/apps/mail/AddressTextControl.h
@@ -40,7 +40,7 @@

private:
			void				_AddAddress(const char* text);
			void				_UpdateTextViewColors();
			void				_UpdateTextViewColors(bool enabled);

private:
			class TextView;
diff --git a/src/apps/mail/Header.cpp b/src/apps/mail/Header.cpp
index b268d2f..c2975bd 100644
--- a/src/apps/mail/Header.cpp
+++ b/src/apps/mail/Header.cpp
@@ -115,7 +115,7 @@
	virtual	void				MessageReceived(BMessage* message);

private:
			void				_UpdateTextViewColors();
			void				_UpdateTextViewColors(bool enabled);
};


@@ -180,16 +180,21 @@
{
	BTextControl::AttachedToWindow();

	_UpdateTextViewColors();
	TextView()->MakeSelectable(true);
	_UpdateTextViewColors(IsEnabled());
}


void
HeaderTextControl::SetEnabled(bool enabled)
{
	if (enabled == IsEnabled())
		return;

	TextView()->MakeEditable(enabled);
	_UpdateTextViewColors(enabled);

	BTextControl::SetEnabled(enabled);
	_UpdateTextViewColors();
}


@@ -232,6 +237,16 @@
HeaderTextControl::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case B_COLORS_UPDATED:
			if ((IsEnabled()
				&& (message->HasColor(ui_color_name(B_DOCUMENT_BACKGROUND_COLOR))
					|| message->HasColor(ui_color_name(B_DOCUMENT_TEXT_COLOR))))
				|| message->HasColor(ui_color_name(B_PANEL_BACKGROUND_COLOR))
				|| message->HasColor(ui_color_name(B_PANEL_TEXT_COLOR))) {
				_UpdateTextViewColors(IsEnabled());
			}
			break;

		case M_SELECT:
		{
			BTextView* textView = TextView();
@@ -248,35 +263,18 @@


void
HeaderTextControl::_UpdateTextViewColors()
HeaderTextControl::_UpdateTextViewColors(bool enabled)
{
	BTextView* textView = TextView();

	BFont font;
	textView->GetFontAndColor(0, &font);

	rgb_color textColor;
	if (!textView->IsEditable() || IsEnabled())
		textColor = ui_color(B_DOCUMENT_TEXT_COLOR);
	else {
		textColor = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
			B_DISABLED_LABEL_TINT);
	}

	textView->SetFontAndColor(&font, B_FONT_ALL, &textColor);

	rgb_color color;
	if (!textView->IsEditable())
		color = ui_color(B_PANEL_BACKGROUND_COLOR);
	else if (IsEnabled())
		color = ui_color(B_DOCUMENT_BACKGROUND_COLOR);
	else {
		color = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
			B_LIGHTEN_2_TINT);
	}

	textView->SetViewColor(color);
	textView->SetLowColor(color);
	TextView()->GetFontAndColor(0, &font);

	// set text color only, do not set high color
	rgb_color textColor = ui_color(enabled ? B_DOCUMENT_TEXT_COLOR : B_PANEL_TEXT_COLOR);
	TextView()->SetFontAndColor(&font, B_FONT_ALL, &textColor);

	// set low color and set view color to low
	TextView()->SetLowUIColor(enabled ? B_DOCUMENT_BACKGROUND_COLOR : B_PANEL_BACKGROUND_COLOR);
	TextView()->SetViewUIColor(TextView()->LowUIColor());
}