mirror of
https://review.haiku-os.org/haiku
synced 2024-11-23 07:18:40 +01:00
TextControl: Make background of invalid control red
Co-Authored-By: Niklas Poslovski <ni.pos@yandex.com> Change-Id: Idd6aa8984aab5d8a8aee81bade23946b88f2497e Reviewed-on: https://review.haiku-os.org/c/haiku/+/8428 Reviewed-by: nephele nephele <nep-git@packageloss.eu> Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org> Haiku-Format: Haiku-format Bot <no-reply+haikuformatbot@haiku-os.org> Reviewed-by: John Scipione <jscipione@gmail.com>
This commit is contained in:
parent
6ab7170720
commit
ca9854451d
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include <AbstractLayoutItem.h>
|
#include <AbstractLayoutItem.h>
|
||||||
#include <ControlLook.h>
|
#include <ControlLook.h>
|
||||||
|
#include <HSL.h>
|
||||||
#include <LayoutUtils.h>
|
#include <LayoutUtils.h>
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
#include <PropertyInfo.h>
|
#include <PropertyInfo.h>
|
||||||
@ -470,7 +471,8 @@ BTextControl::MessageReceived(BMessage* message)
|
|||||||
if (message->HasColor(ui_color_name(B_PANEL_BACKGROUND_COLOR))
|
if (message->HasColor(ui_color_name(B_PANEL_BACKGROUND_COLOR))
|
||||||
|| message->HasColor(ui_color_name(B_PANEL_TEXT_COLOR))
|
|| message->HasColor(ui_color_name(B_PANEL_TEXT_COLOR))
|
||||||
|| message->HasColor(ui_color_name(B_DOCUMENT_BACKGROUND_COLOR))
|
|| message->HasColor(ui_color_name(B_DOCUMENT_BACKGROUND_COLOR))
|
||||||
|| message->HasColor(ui_color_name(B_DOCUMENT_TEXT_COLOR))) {
|
|| message->HasColor(ui_color_name(B_DOCUMENT_TEXT_COLOR))
|
||||||
|
|| message->HasColor(ui_color_name(B_FAILURE_COLOR))) {
|
||||||
_UpdateTextViewColors(IsEnabled());
|
_UpdateTextViewColors(IsEnabled());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -595,8 +597,10 @@ BTextControl::MarkAsInvalid(bool invalid)
|
|||||||
else
|
else
|
||||||
fLook &= ~BControlLook::B_INVALID;
|
fLook &= ~BControlLook::B_INVALID;
|
||||||
|
|
||||||
if (look != fLook)
|
if (look != fLook) {
|
||||||
|
_UpdateTextViewColors(IsEnabled());
|
||||||
Invalidate();
|
Invalidate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1045,6 +1049,18 @@ BTextControl::_UpdateTextViewColors(bool enable)
|
|||||||
if (!enable) {
|
if (!enable) {
|
||||||
textColor = disable_color(textColor, ViewColor());
|
textColor = disable_color(textColor, ViewColor());
|
||||||
viewColor = disable_color(ViewColor(), viewColor);
|
viewColor = disable_color(ViewColor(), viewColor);
|
||||||
|
} else if (fLook & BControlLook::B_INVALID) {
|
||||||
|
hsl_color normalViewColor = hsl_color::from_rgb(viewColor);
|
||||||
|
rgb_color failureColor = ui_color(B_FAILURE_COLOR);
|
||||||
|
hsl_color newViewColor = hsl_color::from_rgb(failureColor);
|
||||||
|
if (normalViewColor.lightness < 0.15)
|
||||||
|
newViewColor.lightness = 0.15;
|
||||||
|
else if (normalViewColor.lightness > 0.95)
|
||||||
|
newViewColor.lightness = 0.95;
|
||||||
|
else
|
||||||
|
newViewColor.lightness = normalViewColor.lightness;
|
||||||
|
|
||||||
|
viewColor = newViewColor.to_rgb();
|
||||||
}
|
}
|
||||||
|
|
||||||
fText->SetFontAndColor(&font, B_FONT_ALL, &textColor);
|
fText->SetFontAndColor(&font, B_FONT_ALL, &textColor);
|
||||||
|
Loading…
Reference in New Issue
Block a user