Locale: Small cleanup of outline list view.
* preserve high and low colors of view between draws * Use DefaultLabelSpacing() instead of using hard 4 pixel spacing
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
|
#include <ControlLook.h>
|
||||||
#include <FormattingConventions.h>
|
#include <FormattingConventions.h>
|
||||||
#include <GradientLinear.h>
|
#include <GradientLinear.h>
|
||||||
#include <LocaleRoster.h>
|
#include <LocaleRoster.h>
|
||||||
@@ -32,8 +33,6 @@
|
|||||||
#define B_TRANSLATION_CONTEXT "LanguageListView"
|
#define B_TRANSLATION_CONTEXT "LanguageListView"
|
||||||
|
|
||||||
|
|
||||||
static const float kLeftInset = 4;
|
|
||||||
|
|
||||||
LanguageListItem::LanguageListItem(const char* text, const char* id,
|
LanguageListItem::LanguageListItem(const char* text, const char* id,
|
||||||
const char* languageCode)
|
const char* languageCode)
|
||||||
:
|
:
|
||||||
@@ -64,6 +63,9 @@ void
|
|||||||
LanguageListItem::DrawItemWithTextOffset(BView* owner, BRect frame,
|
LanguageListItem::DrawItemWithTextOffset(BView* owner, BRect frame,
|
||||||
bool complete, float textOffset)
|
bool complete, float textOffset)
|
||||||
{
|
{
|
||||||
|
rgb_color highColor = owner->HighColor();
|
||||||
|
rgb_color lowColor = owner->LowColor();
|
||||||
|
|
||||||
if (IsSelected() || complete) {
|
if (IsSelected() || complete) {
|
||||||
rgb_color color;
|
rgb_color color;
|
||||||
if (IsSelected())
|
if (IsSelected())
|
||||||
@@ -93,9 +95,13 @@ LanguageListItem::DrawItemWithTextOffset(BView* owner, BRect frame,
|
|||||||
owner->SetHighColor(ui_color(B_LIST_ITEM_TEXT_COLOR));
|
owner->SetHighColor(ui_color(B_LIST_ITEM_TEXT_COLOR));
|
||||||
}
|
}
|
||||||
|
|
||||||
owner->MovePenTo(frame.left + kLeftInset + textOffset,
|
owner->MovePenTo(
|
||||||
|
frame.left + be_control_look->DefaultLabelSpacing() + textOffset,
|
||||||
frame.top + BaselineOffset());
|
frame.top + BaselineOffset());
|
||||||
owner->DrawString(text.String());
|
owner->DrawString(text.String());
|
||||||
|
|
||||||
|
owner->SetHighColor(highColor);
|
||||||
|
owner->SetLowColor(lowColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -134,7 +140,7 @@ LanguageListItemWithFlag::Update(BView* owner, const BFont* font)
|
|||||||
LanguageListItem::Update(owner, font);
|
LanguageListItem::Update(owner, font);
|
||||||
|
|
||||||
float iconSize = Height();
|
float iconSize = Height();
|
||||||
SetWidth(Width() + iconSize + 4);
|
SetWidth(Width() + iconSize + be_control_look->DefaultLabelSpacing());
|
||||||
|
|
||||||
if (fCountryCode.IsEmpty())
|
if (fCountryCode.IsEmpty())
|
||||||
return;
|
return;
|
||||||
@@ -158,10 +164,13 @@ LanguageListItemWithFlag::DrawItem(BView* owner, BRect frame, bool complete)
|
|||||||
}
|
}
|
||||||
|
|
||||||
float iconSize = fIcon->Bounds().Width();
|
float iconSize = fIcon->Bounds().Width();
|
||||||
DrawItemWithTextOffset(owner, frame, complete, iconSize + 4);
|
DrawItemWithTextOffset(owner, frame, complete,
|
||||||
|
iconSize + be_control_look->DefaultLabelSpacing());
|
||||||
|
|
||||||
BRect iconFrame(frame.left + kLeftInset, frame.top,
|
BRect iconFrame(frame.left + be_control_look->DefaultLabelSpacing(),
|
||||||
frame.left + kLeftInset + iconSize - 1, frame.top + iconSize - 1);
|
frame.top,
|
||||||
|
frame.left + iconSize - 1 + be_control_look->DefaultLabelSpacing(),
|
||||||
|
frame.top + iconSize - 1);
|
||||||
owner->SetDrawingMode(B_OP_OVER);
|
owner->SetDrawingMode(B_OP_OVER);
|
||||||
owner->DrawBitmap(fIcon, iconFrame);
|
owner->DrawBitmap(fIcon, iconFrame);
|
||||||
owner->SetDrawingMode(B_OP_COPY);
|
owner->SetDrawingMode(B_OP_COPY);
|
||||||
|
|||||||
Reference in New Issue
Block a user