⛏️ index : haiku.git

author John Scipione <jscipione@gmail.com> 2024-09-05 1:51:12.0 -04:00:00
committer waddlesplash <waddlesplash@gmail.com> 2024-09-05 15:19:57.0 +00:00:00
commit
968df8c8d2dd4ff2434345dd7668d09e9401931d [patch]
tree
2fff7cae6964a884f7089470ebcf83c5142668f1
parent
754af207b9298ef76a65a0540a0e997f26a6794a
download
968df8c8d2dd4ff2434345dd7668d09e9401931d.tar.gz

Interface Kit: Adopt parent colors on checkboxes and radio buttons

We do not always use radio buttons and check boxes on panel color,
use the parent colors instead if you have them. The label is left-
center aligned.

Change-Id: Id5cbd98e8ae88d3a65fb0735d45b2ad19c4afdf9
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8233
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Haiku-Format: Haiku-format Bot <no-reply+haikuformatbot@haiku-os.org>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
(cherry picked from commit 5333610f85f043f71ca2c7d220990fefbe43f6fa)
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8204

Diff

 src/kits/interface/CheckBox.cpp    | 14 +++++++++++++-
 src/kits/interface/RadioButton.cpp | 17 +++++++++++++++--
 2 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/src/kits/interface/CheckBox.cpp b/src/kits/interface/CheckBox.cpp
index 8e20d6b..1144d90 100644
--- a/src/kits/interface/CheckBox.cpp
+++ b/src/kits/interface/CheckBox.cpp
@@ -103,7 +103,14 @@
void
BCheckBox::Draw(BRect updateRect)
{
	rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
	rgb_color base, textColor;
	if (Parent() != NULL) {
		base = Parent()->ViewColor();
		textColor = Parent()->HighColor();
	} else {
		base = ui_color(B_PANEL_BACKGROUND_COLOR);
		textColor = ui_color(B_PANEL_TEXT_COLOR);
	}

	uint32 flags = be_control_look->Flags(this);
	if (fOutlined)
@@ -123,9 +130,10 @@

	const BBitmap* icon = IconBitmap(
		B_INACTIVE_ICON_BITMAP | (IsEnabled() ? 0 : B_DISABLED_ICON_BITMAP));
	const BAlignment alignment = BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_CENTER);

	be_control_look->DrawLabel(this, Label(), icon, labelRect, updateRect,
		base, flags);
	be_control_look->DrawLabel(this, Label(), icon, labelRect, updateRect, base, flags, alignment,
		&textColor);
}


diff --git a/src/kits/interface/RadioButton.cpp b/src/kits/interface/RadioButton.cpp
index 0469833..4ff6608 100644
--- a/src/kits/interface/RadioButton.cpp
+++ b/src/kits/interface/RadioButton.cpp
@@ -89,7 +89,14 @@
	font_height fontHeight;
	GetFontHeight(&fontHeight);

	rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
	rgb_color base, textColor;
	if (Parent() != NULL) {
		base = Parent()->ViewColor();
		textColor = Parent()->HighColor();
	} else {
		base = ui_color(B_PANEL_BACKGROUND_COLOR);
		textColor = ui_color(B_PANEL_TEXT_COLOR);
	}

	uint32 flags = be_control_look->Flags(this);
	if (fOutlined)
@@ -104,14 +111,14 @@
	flags &= ~BControlLook::B_IS_CONTROL;

	BRect labelRect(Bounds());
	labelRect.left = knobRect.right + 1
		+ be_control_look->DefaultLabelSpacing();
	labelRect.left = knobRect.right + 1 + be_control_look->DefaultLabelSpacing();

	const BBitmap* icon = IconBitmap(
		B_INACTIVE_ICON_BITMAP | (IsEnabled() ? 0 : B_DISABLED_ICON_BITMAP));
	const BAlignment alignment = BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_CENTER);

	be_control_look->DrawLabel(this, Label(), icon, labelRect, updateRect,
		base, flags);
	be_control_look->DrawLabel(this, Label(), icon, labelRect, updateRect, base, flags, alignment,
		&textColor);
}