[haiku-commits] BRANCH axeld-github.mail-layout [3fe7551be01d] src/apps/mail src/kits/mail headers/os/mail src/kits/support

  • From: axeld-github.mail-layout <community@xxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 1 Sep 2015 22:46:57 +0200 (CEST)

added 7 changesets to branch 'refs/remotes/axeld-github/mail-layout'
old head: 01d2cd3359c0f1ee6c1aea4bfa4ee9f2334fd4ea
new head: 3fe7551be01df2106ae49b5942a764781efd4c2a
overview: https://github.com/axeld/haiku/compare/01d2cd3359c0...3fe7551be01d

----------------------------------------------------------------------------

27211170eadf: Mail: properly disable prev/next buttons without Tracker.

* The prev/next buttons will only work when invoked via an actual
mail file from Tracker.

e246e501b6a6: Mail: fAccount text control is no longer used.

46f2d8a614fd: BDate: added time_t constructor.

* This class is pretty much useless as it is.

a89addd317df: BMailComponent: made a few methods const.

ff2035d44cc8: BEmailMessage: added missing const, Date() returns time_t.

* Added missing const to some getter methods.
* Date() now tries to parse the date of the mail, and return it as
a time_t; you can still retrieve the actual string via
HeaderField("Date") if you have to.
* Mail now shows the time in the local time zone, and with the
current locale.

fb40755fbde5: Mail: change look of disabled text controls.

* Added HeaderTextControl that draws the text in black, and uses the
panel background without a frame when it's disabled. Only the label
is still drawn as disabled.
* Changed AddressTextControl to behave in the same way.
* The date view is now a HeaderTextControl, too.
* Unfortunately, the label is not vertically aligned with the contents.

3fe7551be01d: Mail: temporary workaround for the label placing issue.

* Does not work for all font sizes.

[ Axel Dörfler <axeld@xxxxxxxxxxxxxxxx> ]

----------------------------------------------------------------------------

11 files changed, 235 insertions(+), 81 deletions(-)
headers/os/mail/MailComponent.h | 6 +-
headers/os/mail/MailMessage.h | 14 +--
headers/os/support/DateTime.h | 2 +
src/apps/mail/AddressTextControl.cpp | 18 ++--
src/apps/mail/AddressTextControl.h | 2 +-
src/apps/mail/Header.cpp | 178 +++++++++++++++++++++++++++----
src/apps/mail/Header.h | 11 +-
src/apps/mail/MailWindow.cpp | 19 ++--
src/kits/mail/MailComponent.cpp | 11 +-
src/kits/mail/MailMessage.cpp | 22 ++--
src/kits/support/DateTime.cpp | 33 +++---

############################################################################

Commit: 27211170eadf2e417b22c6118e4988ad34b7a643
Author: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date: Mon Aug 31 06:10:39 2015 UTC

Mail: properly disable prev/next buttons without Tracker.

* The prev/next buttons will only work when invoked via an actual
mail file from Tracker.

----------------------------------------------------------------------------

diff --git a/src/apps/mail/MailWindow.cpp b/src/apps/mail/MailWindow.cpp
index b11711c..55d5431 100644
--- a/src/apps/mail/MailWindow.cpp
+++ b/src/apps/mail/MailWindow.cpp
@@ -686,9 +686,10 @@ TMailWindow::BuildToolBar()
B_TRANSLATE("Print"));
fToolBar->AddAction(M_DELETE_NEXT, this,
_RetrieveVectorIcon(4), NULL,
B_TRANSLATE("Trash"));
- if (fApp->ShowSpamGUI())
- fToolBar->AddAction(M_SPAM_BUTTON, this,
_RetrieveVectorIcon(10), NULL,
- B_TRANSLATE("Spam"));
+ if (fApp->ShowSpamGUI()) {
+ fToolBar->AddAction(M_SPAM_BUTTON, this,
_RetrieveVectorIcon(10),
+ NULL, B_TRANSLATE("Spam"));
+ }
fToolBar->AddSeparator();
fToolBar->AddAction(M_NEXTMSG, this, _RetrieveVectorIcon(6),
NULL,
B_TRANSLATE("Next"));
@@ -701,6 +702,11 @@ TMailWindow::BuildToolBar()
fToolBar->AddAction(M_PREVMSG, this, _RetrieveVectorIcon(7),
NULL,
B_TRANSLATE("Previous"));

+ if (!fTrackerMessenger.IsValid()) {
+ fToolBar->SetActionEnabled(M_NEXTMSG, false);
+ fToolBar->SetActionEnabled(M_PREVMSG, false);
+ }
+
if (!fAutoMarkRead)
_AddReadButton();
}
@@ -950,11 +956,6 @@ TMailWindow::MenusBeginning()
} else {
fCut->SetEnabled(false);
fPaste->SetEnabled(false);
-
- if (!fTrackerMessenger.IsValid()) {
- fNextMsg->SetEnabled(false);
- fPrevMsg->SetEnabled(false);
- }
}
}


############################################################################

Commit: e246e501b6a679ee9560d517dde1d402f4cddea7
Author: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date: Mon Aug 31 07:13:36 2015 UTC

Mail: fAccount text control is no longer used.

----------------------------------------------------------------------------

diff --git a/src/apps/mail/Header.cpp b/src/apps/mail/Header.cpp
index 4865612..a4360a3 100644
--- a/src/apps/mail/Header.cpp
+++ b/src/apps/mail/Header.cpp
@@ -149,7 +149,6 @@ THeaderView::THeaderView(bool incoming, bool resending,
int32 defaultAccount)
:
fAccountMenu(NULL),
fAccountID(defaultAccount),
- fAccount(NULL),
fFromControl(NULL),
fBccControl(NULL),
fDateView(NULL),
@@ -461,6 +460,9 @@ THeaderView::SetAccount(int32 id)
{
fAccountID = id;

+ if (fAccountMenu == NULL)
+ return;
+
for (int32 i = fAccountMenu->CountItems(); i-- > 0;) {
BMenuItem* item = fAccountMenu->ItemAt(i);
if (item == NULL)
@@ -478,6 +480,9 @@ THeaderView::SetAccount(int32 id)
void
THeaderView::SetAccount(const char* name)
{
+ if (fAccountMenu == NULL)
+ return;
+
BMenuItem* item = fAccountMenu->FindItem(name);
if (item != NULL) {
item->SetMarked(true);
@@ -496,7 +501,7 @@ THeaderView::SetFromMessage(BEmailMessage* mail)
SetCc(mail->CC());

BString accountName;
- if (fAccount != NULL && mail->GetAccountName(accountName) == B_OK)
+ if (mail->GetAccountName(accountName) == B_OK)
SetAccount(accountName);

// Set the date on this message
@@ -553,8 +558,6 @@ THeaderView::AttachedToWindow()
fCcControl->SetTarget(Looper());
if (fBccControl != NULL)
fBccControl->SetTarget(Looper());
- if (fAccount != NULL)
- fAccount->SetTarget(Looper());
if (fAccountMenu != NULL)
fAccountMenu->SetTargetForItems(this);

diff --git a/src/apps/mail/Header.h b/src/apps/mail/Header.h
index c9ff2a0..fd72a5d 100644
--- a/src/apps/mail/Header.h
+++ b/src/apps/mail/Header.h
@@ -94,7 +94,6 @@ public:
private:
BPopUpMenu* fAccountMenu;
int32 fAccountID;
- BTextControl* fAccount;
BTextControl* fFromControl;
LabelView* fToLabel;
AddressTextControl* fToControl;

############################################################################

Commit: 46f2d8a614fd35f0fcc0114dc654c3be88496721
Author: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date: Mon Aug 31 16:01:33 2015 UTC

BDate: added time_t constructor.

* This class is pretty much useless as it is.

----------------------------------------------------------------------------

diff --git a/headers/os/support/DateTime.h b/headers/os/support/DateTime.h
index 8ee9122..e6e3db2 100644
--- a/headers/os/support/DateTime.h
+++ b/headers/os/support/DateTime.h
@@ -91,6 +91,8 @@ public:
BDate();
BDate(const
BDate& other);
BDate(int32
year, int32 month, int32 day);
+ BDate(time_t
time,
+
time_type type = B_LOCAL_TIME);
BDate(const
BMessage* archive);
~BDate();

diff --git a/src/kits/support/DateTime.cpp b/src/kits/support/DateTime.cpp
index 1852d35..b7f4ab0 100644
--- a/src/kits/support/DateTime.cpp
+++ b/src/kits/support/DateTime.cpp
@@ -486,6 +486,23 @@ BDate::BDate(int32 year, int32 month, int32 day)
}


+BDate::BDate(time_t time, time_type type)
+{
+ struct tm result;
+ struct tm* timeinfo;
+
+ if (type == B_GMT_TIME)
+ timeinfo = gmtime_r(&time, &result);
+ else
+ timeinfo = localtime_r(&time, &result);
+
+ if (timeinfo != NULL) {
+ _SetDate(timeinfo->tm_year + 1900, timeinfo->tm_mon + 1,
+ timeinfo->tm_mday);
+ }
+}
+
+
/*!
Constructs a new BDate object from the provided archive.
*/
@@ -586,21 +603,7 @@ BDate::IsValid(int32 year, int32 month, int32 day)
BDate
BDate::CurrentDate(time_type type)
{
- time_t timer;
- struct tm result;
- struct tm* timeinfo;
-
- time(&timer);
-
- if (type == B_GMT_TIME)
- timeinfo = gmtime_r(&timer, &result);
- else
- timeinfo = localtime_r(&timer, &result);
-
- if (timeinfo == NULL)
- return BDate();
-
- return BDate(timeinfo->tm_year + 1900, timeinfo->tm_mon +1,
timeinfo->tm_mday);
+ return BDate(time(NULL), type);
}



############################################################################

Commit: a89addd317dfa6cbf115ed4f0af1941d198e99e0
Author: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date: Mon Aug 31 16:04:03 2015 UTC

BMailComponent: made a few methods const.

----------------------------------------------------------------------------

diff --git a/headers/os/mail/MailComponent.h b/headers/os/mail/MailComponent.h
index 6724cab..91b5b9a 100644
--- a/headers/os/mail/MailComponent.h
+++ b/headers/os/mail/MailComponent.h
@@ -56,9 +56,9 @@ class BMailComponent {
const char *key, BMessage *structured_header,
bool replace_existing = true);

- const char *HeaderAt(int32 index);
- const char *HeaderField(const char *key, int32 index = 0);
- status_t HeaderField(const char *key, BMessage
*structured_header, int32 index = 0);
+ const char *HeaderAt(int32 index) const;
+ const char *HeaderField(const char *key, int32 index = 0) const;
+ status_t HeaderField(const char *key, BMessage
*structured_header, int32 index = 0) const;

status_t RemoveHeader(const char *key);

diff --git a/src/kits/mail/MailComponent.cpp b/src/kits/mail/MailComponent.cpp
index 2cc0624..5c5dcbc 100644
--- a/src/kits/mail/MailComponent.cpp
+++ b/src/kits/mail/MailComponent.cpp
@@ -186,7 +186,7 @@ BMailComponent::SetHeaderField(const char* key, BMessage*
structure,


const char*
-BMailComponent::HeaderField(const char* key, int32 index)
+BMailComponent::HeaderField(const char* key, int32 index) const
{
const char* string = NULL;

@@ -196,7 +196,8 @@ BMailComponent::HeaderField(const char* key, int32 index)


status_t
-BMailComponent::HeaderField(const char* key, BMessage* structure, int32 index)
+BMailComponent::HeaderField(const char* key, BMessage* structure,
+ int32 index) const
{
BString string = HeaderField(key, index);
if (string == "")
@@ -265,7 +266,7 @@ BMailComponent::RemoveHeader(const char* key)


const char*
-BMailComponent::HeaderAt(int32 index)
+BMailComponent::HeaderAt(int32 index) const
{
#if defined(HAIKU_TARGET_PLATFORM_DANO)
const
@@ -503,7 +504,7 @@ status_t
BTextMailComponent::GetDecodedData(BPositionIO* data)
{
ParseRaw();
-
+
if (data == NULL)
return B_IO_ERROR;

@@ -657,7 +658,7 @@ BTextMailComponent::RenderToRFC822(BPositionIO* render_to)
status_t status = ParseRaw();
if (status < B_OK)
return status;
-
+
BMimeType type;
MIMEType(&type);
BString content_type;

############################################################################

Commit: ff2035d44cc8807322010354ee44511b1c514ae8
Author: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date: Mon Aug 31 16:14:17 2015 UTC

BEmailMessage: added missing const, Date() returns time_t.

* Added missing const to some getter methods.
* Date() now tries to parse the date of the mail, and return it as
a time_t; you can still retrieve the actual string via
HeaderField("Date") if you have to.
* Mail now shows the time in the local time zone, and with the
current locale.

----------------------------------------------------------------------------

diff --git a/headers/os/mail/MailMessage.h b/headers/os/mail/MailMessage.h
index 0c87e8b..63a8150 100644
--- a/headers/os/mail/MailMessage.h
+++ b/headers/os/mail/MailMessage.h
@@ -55,13 +55,13 @@ public:
// addresses the message appropriately, but
ForwardMessage()
// leaves it unaddressed.

- const char* To();
- const char* From();
- const char* ReplyTo();
- const char* CC();
- const char* Subject();
- const char* Date();
- int Priority();
+ const char* To() const;
+ const char* From() const;
+ const char* ReplyTo() const;
+ const char* CC() const;
+ const char* Subject() const;
+ time_t Date() const;
+ int Priority()
const;

void SetSubject(const char*
to,
uint32
charset = B_MAIL_NULL_CONVERSION,
diff --git a/src/apps/mail/Header.cpp b/src/apps/mail/Header.cpp
index a4360a3..69623fc 100644
--- a/src/apps/mail/Header.cpp
+++ b/src/apps/mail/Header.cpp
@@ -38,6 +38,7 @@ of their respective holders. All rights reserved.
#include <stdio.h>

#include <ControlLook.h>
+#include <DateTimeFormat.h>
#include <E-mail.h>
#include <LayoutBuilder.h>
#include <Locale.h>
@@ -430,6 +431,22 @@ THeaderView::Date() const


void
+THeaderView::SetDate(time_t date)
+{
+ fDate = date;
+
+ if (fDateView != NULL) {
+ BDateTimeFormat formatter;
+
+ BString string;
+ formatter.Format(string, date, B_FULL_DATE_FORMAT,
+ B_MEDIUM_TIME_FORMAT);
+ SetDate(string);
+ }
+}
+
+
+void
THeaderView::SetDate(const char* date)
{
if (fDateView != NULL)
@@ -505,8 +522,12 @@ THeaderView::SetFromMessage(BEmailMessage* mail)
SetAccount(accountName);

// Set the date on this message
- const char* dateField = mail->Date();
- SetDate(dateField != NULL ? dateField : B_TRANSLATE("Unknown"));
+ time_t date = mail->Date();
+ if (date <= 0) {
+ const char* dateField = mail->HeaderField("Date");
+ SetDate(dateField != NULL ? dateField : B_TRANSLATE("Unknown"));
+ } else
+ SetDate(date);

return B_OK;
}
diff --git a/src/apps/mail/Header.h b/src/apps/mail/Header.h
index fd72a5d..77f5c55 100644
--- a/src/apps/mail/Header.h
+++ b/src/apps/mail/Header.h
@@ -79,6 +79,7 @@ public:

bool IsDateEmpty() const;
const char* Date() const;
+ void SetDate(time_t date);
void SetDate(const char*
date);

int32 AccountID() const;
@@ -102,6 +103,7 @@ private:
AddressTextControl* fBccControl;
BTextControl* fSubjectControl;
BStringView* fDateView;
+ time_t fDate;
bool fIncoming;
bool fResending;
};
diff --git a/src/apps/mail/MailWindow.cpp b/src/apps/mail/MailWindow.cpp
index 55d5431..e02f89f 100644
--- a/src/apps/mail/MailWindow.cpp
+++ b/src/apps/mail/MailWindow.cpp
@@ -2177,7 +2177,7 @@ TMailWindow::Reply(entry_ref* ref, TMailWindow* window,
uint32 type)
if (address.Length() <= 0)
address = B_TRANSLATE("(Address unavailable)");

- BString date(mail->Date());
+ BString date(mail->HeaderField("Date"));
if (date.Length() <= 0)
date = B_TRANSLATE("(Date unavailable)");

diff --git a/src/kits/mail/MailMessage.cpp b/src/kits/mail/MailMessage.cpp
index 864182d..a70386d 100644
--- a/src/kits/mail/MailMessage.cpp
+++ b/src/kits/mail/MailMessage.cpp
@@ -226,28 +226,28 @@ BEmailMessage::ForwardMessage(bool accountFromMail, bool
includeAttachments)


const char*
-BEmailMessage::To()
+BEmailMessage::To() const
{
return HeaderField("To");
}


const char*
-BEmailMessage::From()
+BEmailMessage::From() const
{
return HeaderField("From");
}


const char*
-BEmailMessage::ReplyTo()
+BEmailMessage::ReplyTo() const
{
return HeaderField("Reply-To");
}


const char*
-BEmailMessage::CC()
+BEmailMessage::CC() const
{
return HeaderField("Cc");
// Note case of CC is "Cc" in our internal headers.
@@ -255,21 +255,25 @@ BEmailMessage::CC()


const char*
-BEmailMessage::Subject()
+BEmailMessage::Subject() const
{
return HeaderField("Subject");
}


-const char*
-BEmailMessage::Date()
+time_t
+BEmailMessage::Date() const
{
- return HeaderField("Date");
+ const char* dateField = HeaderField("Date");
+ if (dateField == NULL)
+ return -1;
+
+ return ParseDateWithTimeZone(dateField);
}


int
-BEmailMessage::Priority()
+BEmailMessage::Priority() const
{
int priorityNumber;
const char* priorityString;

############################################################################

Commit: fb40755fbde579cc2da999cbe27aef02342515dd
Author: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date: Mon Aug 31 17:03:20 2015 UTC

Mail: change look of disabled text controls.

* Added HeaderTextControl that draws the text in black, and uses the
panel background without a frame when it's disabled. Only the label
is still drawn as disabled.
* Changed AddressTextControl to behave in the same way.
* The date view is now a HeaderTextControl, too.
* Unfortunately, the label is not vertically aligned with the contents.

----------------------------------------------------------------------------

diff --git a/src/apps/mail/AddressTextControl.cpp
b/src/apps/mail/AddressTextControl.cpp
index 8fec665..dd60999 100644
--- a/src/apps/mail/AddressTextControl.cpp
+++ b/src/apps/mail/AddressTextControl.cpp
@@ -36,7 +36,6 @@


static const uint32 kMsgAddAddress = 'adad';
-static const float kHorizontalTextRectInset = 4.0;
static const float kVerticalTextRectInset = 2.0;


@@ -393,9 +392,9 @@ AddressTextControl::TextView::_AlignTextRect()
textRect.left = 0.0;
float vInset = max_c(1,
floorf((textRect.Height() - LineHeight(0)) / 2.0 + 0.5));
- float hInset = kHorizontalTextRectInset;

- if (be_control_look)
+ float hInset = 0;
+ if (be_control_look != NULL)
hInset = be_control_look->DefaultLabelSpacing();

textRect.InsetBy(hInset, vInset);
@@ -692,6 +691,9 @@ AddressTextControl::WindowActivated(bool active)
void
AddressTextControl::Draw(BRect updateRect)
{
+ if (!IsEditable())
+ return;
+
BRect bounds(Bounds());
rgb_color base(LowColor());
uint32 flags = 0;
@@ -724,7 +726,7 @@ AddressTextControl::SetEnabled(bool enabled)

fPopUpButton->SetEnabled(enabled);

- _UpdateTextViewColors(enabled);
+ _UpdateTextViewColors();
}


@@ -959,13 +961,13 @@ AddressTextControl::_AddAddress(const char* text)


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

rgb_color textColor;
- if (enabled)
+ if (!IsEditable() || IsEnabled())
textColor = ui_color(B_DOCUMENT_TEXT_COLOR);
else {
textColor = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
@@ -975,7 +977,9 @@ AddressTextControl::_UpdateTextViewColors(bool enabled)
fTextView->SetFontAndColor(&font, B_FONT_ALL, &textColor);

rgb_color color;
- if (enabled)
+ if (!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),
diff --git a/src/apps/mail/AddressTextControl.h
b/src/apps/mail/AddressTextControl.h
index 0ba6074..51c38bc 100644
--- a/src/apps/mail/AddressTextControl.h
+++ b/src/apps/mail/AddressTextControl.h
@@ -44,7 +44,7 @@ public:

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

private:
class TextView;
diff --git a/src/apps/mail/Header.cpp b/src/apps/mail/Header.cpp
index 69623fc..d52b939 100644
--- a/src/apps/mail/Header.cpp
+++ b/src/apps/mail/Header.cpp
@@ -104,6 +104,20 @@ private:
};


+class HeaderTextControl : public BTextControl {
+public:
+
HeaderTextControl(const char* label,
+ const
char* name, BMessage* message);
+
+ virtual void AttachedToWindow();
+ virtual void SetEnabled(bool enabled);
+ virtual void Draw(BRect updateRect);
+
+private:
+ void _UpdateTextViewColors();
+};
+
+
// #pragma mark - LabelView


@@ -143,6 +157,101 @@ LabelView::Draw(BRect updateRect)
}


+// #pragma mark - HeaderTextControl
+
+
+HeaderTextControl::HeaderTextControl(const char* label, const char* name,
+ BMessage* message)
+ :
+ BTextControl(label, name, message)
+{
+}
+
+
+void
+HeaderTextControl::AttachedToWindow()
+{
+ BTextControl::AttachedToWindow();
+ _UpdateTextViewColors();
+}
+
+
+void
+HeaderTextControl::SetEnabled(bool enabled)
+{
+ BTextControl::SetEnabled(enabled);
+ _UpdateTextViewColors();
+}
+
+
+void
+HeaderTextControl::Draw(BRect updateRect)
+{
+ bool enabled = IsEnabled();
+ bool active = TextView()->IsFocus() && Window()->IsActive();
+
+ BRect rect = TextView()->Frame();
+ rect.InsetBy(-2, -2);
+
+ rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
+ uint32 flags = 0;
+ if (!enabled)
+ flags = BControlLook::B_DISABLED;
+
+ if (enabled) {
+ if (active)
+ flags |= BControlLook::B_FOCUSED;
+
+ be_control_look->DrawTextControlBorder(this, rect, updateRect,
base,
+ flags);
+ }
+
+ if (Label() != NULL) {
+ rect =
CreateLabelLayoutItem()->Frame().OffsetByCopy(-Frame().left,
+ -Frame().top);
+
+ alignment labelAlignment;
+ GetAlignment(&labelAlignment, NULL);
+
+ be_control_look->DrawLabel(this, Label(), rect, updateRect,
+ base, flags, BAlignment(labelAlignment,
B_ALIGN_MIDDLE));
+ }
+}
+
+
+void
+HeaderTextControl::_UpdateTextViewColors()
+{
+ 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);
+}
+
+
// #pragma mark - THeaderView


@@ -152,13 +261,13 @@ THeaderView::THeaderView(bool incoming, bool resending,
int32 defaultAccount)
fAccountID(defaultAccount),
fFromControl(NULL),
fBccControl(NULL),
- fDateView(NULL),
+ fDateControl(NULL),
fIncoming(incoming),
fResending(resending)
{
// From
if (fIncoming) {
- fFromControl = new BTextControl(B_TRANSLATE("From:"), NULL,
NULL);
+ fFromControl = new HeaderTextControl(B_TRANSLATE("From:"),
NULL, NULL);
fFromControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
fFromControl->SetEnabled(false);
}
@@ -251,7 +360,7 @@ THeaderView::THeaderView(bool incoming, bool resending,
int32 defaultAccount)
}

// Subject
- fSubjectControl = new BTextControl(B_TRANSLATE("Subject:"), NULL,
+ fSubjectControl = new HeaderTextControl(B_TRANSLATE("Subject:"), NULL,
new BMessage(SUBJECT_FIELD));
msg = new BMessage(FIELD_CHANGED);
msg->AddInt32("bitmask", FIELD_SUBJECT);
@@ -261,17 +370,17 @@ THeaderView::THeaderView(bool incoming, bool resending,
int32 defaultAccount)
fSubjectControl->SetEnabled(false);

// Date
- LabelView* dateLabel = NULL;
if (fIncoming) {
- dateLabel = new LabelView(B_TRANSLATE("Date:"));
- dateLabel->SetEnabled(false);
- fDateView = new BStringView("", "");
- fDateView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED,
B_SIZE_UNSET));
+ fDateControl = new HeaderTextControl(B_TRANSLATE("Date:"),
NULL, NULL);
+ fDateControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
+ fDateControl->SetEnabled(false);
}

BGridLayout* layout = GridLayout();

layout->SetInsets(B_USE_DEFAULT_SPACING);
+ if (fIncoming)
+ layout->SetHorizontalSpacing(0);
layout->SetVerticalSpacing(B_USE_HALF_ITEM_SPACING);

int32 row = 0;
@@ -297,9 +406,10 @@ THeaderView::THeaderView(bool incoming, bool resending,
int32 defaultAccount)
layout->AddItem(fSubjectControl->CreateTextViewLayoutItem(), 1, row++,
3, 1);

- if (fDateView != NULL) {
- layout->AddView(dateLabel, 0, row);
- layout->AddView(fDateView, 1, row++, 3, 1);
+ if (fDateControl != NULL) {
+ layout->AddItem(fDateControl->CreateLabelLayoutItem(), 0, row);
+ layout->AddItem(fDateControl->CreateTextViewLayoutItem(), 1,
row++,
+ 3, 1);
}
}

@@ -426,7 +536,7 @@ THeaderView::IsDateEmpty() const
const char*
THeaderView::Date() const
{
- return fDateView != NULL ? fDateView->Text() : NULL;
+ return fDateControl != NULL ? fDateControl->Text() : NULL;
}


@@ -435,7 +545,7 @@ THeaderView::SetDate(time_t date)
{
fDate = date;

- if (fDateView != NULL) {
+ if (fDateControl != NULL) {
BDateTimeFormat formatter;

BString string;
@@ -449,8 +559,8 @@ THeaderView::SetDate(time_t date)
void
THeaderView::SetDate(const char* date)
{
- if (fDateView != NULL)
- fDateView->SetText(date);
+ if (fDateControl != NULL)
+ fDateControl->SetText(date);
}


diff --git a/src/apps/mail/Header.h b/src/apps/mail/Header.h
index 77f5c55..597a565 100644
--- a/src/apps/mail/Header.h
+++ b/src/apps/mail/Header.h
@@ -37,7 +37,6 @@ All rights reserved.

#include <GridView.h>
#include <NodeInfo.h>
-#include <TextControl.h>

#include "AddressTextControl.h"

@@ -48,6 +47,7 @@ class BMenuField;
class BMenuItem;
class BPopUpMenu;
class BStringView;
+class HeaderTextControl;
class LabelView;


@@ -95,14 +95,14 @@ public:
private:
BPopUpMenu* fAccountMenu;
int32 fAccountID;
- BTextControl* fFromControl;
+ HeaderTextControl* fFromControl;
LabelView* fToLabel;
AddressTextControl* fToControl;
LabelView* fCcLabel;
AddressTextControl* fCcControl;
AddressTextControl* fBccControl;
- BTextControl* fSubjectControl;
- BStringView* fDateView;
+ HeaderTextControl* fSubjectControl;
+ HeaderTextControl* fDateControl;
time_t fDate;
bool fIncoming;
bool fResending;

############################################################################

Commit: 3fe7551be01df2106ae49b5942a764781efd4c2a
Author: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date: Mon Aug 31 17:30:32 2015 UTC

Mail: temporary workaround for the label placing issue.

* Does not work for all font sizes.

----------------------------------------------------------------------------

diff --git a/src/apps/mail/Header.cpp b/src/apps/mail/Header.cpp
index d52b939..3165d1f 100644
--- a/src/apps/mail/Header.cpp
+++ b/src/apps/mail/Header.cpp
@@ -145,6 +145,8 @@ LabelView::Draw(BRect updateRect)
{
if (Text() != NULL) {
BRect rect = Bounds();
+ // TODO: solve this better (alignment of label and text)
+ rect.top++;

rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
uint32 flags = 0;
@@ -209,6 +211,8 @@ HeaderTextControl::Draw(BRect updateRect)
if (Label() != NULL) {
rect =
CreateLabelLayoutItem()->Frame().OffsetByCopy(-Frame().left,
-Frame().top);
+ // TODO: solve this better (alignment of label and text)
+ rect.top++;

alignment labelAlignment;
GetAlignment(&labelAlignment, NULL);


Other related posts:

  • » [haiku-commits] BRANCH axeld-github.mail-layout [3fe7551be01d] src/apps/mail src/kits/mail headers/os/mail src/kits/support - axeld-github . mail-layout