* Coding style cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26759 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
39eb52d83b
commit
207e176915
@ -32,18 +32,20 @@ names are registered trademarks or trademarks of their respective holders.
|
|||||||
All rights reserved.
|
All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Debug.h>
|
#include "WindowMenuItem.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
|
#include <Debug.h>
|
||||||
|
|
||||||
#include "BarApp.h"
|
#include "BarApp.h"
|
||||||
#include "BarMenuBar.h"
|
#include "BarMenuBar.h"
|
||||||
#include "ExpandoMenuBar.h"
|
#include "ExpandoMenuBar.h"
|
||||||
|
#include "icons.h"
|
||||||
#include "ResourceSet.h"
|
#include "ResourceSet.h"
|
||||||
#include "TeamMenu.h"
|
#include "TeamMenu.h"
|
||||||
#include "WindowMenu.h"
|
#include "WindowMenu.h"
|
||||||
#include "WindowMenuItem.h"
|
|
||||||
#include "icons.h"
|
|
||||||
|
|
||||||
|
|
||||||
const float kHPad = 10.0f;
|
const float kHPad = 10.0f;
|
||||||
@ -52,9 +54,9 @@ const float kLabelOffset = 8.0f;
|
|||||||
const BRect kIconRect(1.0f, 1.0f, 13.0f, 14.0f);
|
const BRect kIconRect(1.0f, 1.0f, 13.0f, 14.0f);
|
||||||
|
|
||||||
|
|
||||||
TWindowMenuItem::TWindowMenuItem(const char *title, int32 id,
|
TWindowMenuItem::TWindowMenuItem(const char *title, int32 id, bool mini,
|
||||||
bool mini, bool currentWorkspace, bool dragging)
|
bool currentWorkspace, bool dragging)
|
||||||
: BMenuItem(title, NULL),
|
: BMenuItem(title, NULL),
|
||||||
fID(id),
|
fID(id),
|
||||||
fMini(mini),
|
fMini(mini),
|
||||||
fCurrentWorkSpace(currentWorkspace),
|
fCurrentWorkSpace(currentWorkspace),
|
||||||
@ -71,14 +73,15 @@ TWindowMenuItem::TWindowMenuItem(const char *title, int32 id,
|
|||||||
void
|
void
|
||||||
TWindowMenuItem::Initialize(const char *title)
|
TWindowMenuItem::Initialize(const char *title)
|
||||||
{
|
{
|
||||||
if (fMini)
|
if (fMini) {
|
||||||
fBitmap = fCurrentWorkSpace
|
fBitmap = fCurrentWorkSpace
|
||||||
? AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_WindowHiddenIcon)
|
? AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_WindowHiddenIcon)
|
||||||
: AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_WindowHiddenSwitchIcon);
|
: AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_WindowHiddenSwitchIcon);
|
||||||
else
|
} else {
|
||||||
fBitmap = fCurrentWorkSpace
|
fBitmap = fCurrentWorkSpace
|
||||||
? AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_WindowShownIcon)
|
? AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_WindowShownIcon)
|
||||||
: AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_WindowShownSwitchIcon);
|
: AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_WindowShownSwitchIcon);
|
||||||
|
}
|
||||||
|
|
||||||
BFont font(be_plain_font);
|
BFont font(be_plain_font);
|
||||||
fTitleWidth = ceilf(font.StringWidth(title));
|
fTitleWidth = ceilf(font.StringWidth(title));
|
||||||
@ -90,8 +93,8 @@ TWindowMenuItem::Initialize(const char *title)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TWindowMenuItem::SetTo(const char *title, int32 id,
|
TWindowMenuItem::SetTo(const char *title, int32 id, bool mini,
|
||||||
bool mini, bool currentWorkspace, bool dragging)
|
bool currentWorkspace, bool dragging)
|
||||||
{
|
{
|
||||||
fModified = fCurrentWorkSpace != currentWorkspace || fMini != mini;
|
fModified = fCurrentWorkSpace != currentWorkspace || fMini != mini;
|
||||||
|
|
||||||
@ -123,7 +126,7 @@ TWindowMenuItem::SetLabel(const char* string)
|
|||||||
contLoc.x += kIconRect.Width() + kLabelOffset;
|
contLoc.x += kIconRect.Width() + kLabelOffset;
|
||||||
|
|
||||||
be_plain_font->TruncateString(&truncatedTitle, B_TRUNCATE_MIDDLE,
|
be_plain_font->TruncateString(&truncatedTitle, B_TRUNCATE_MIDDLE,
|
||||||
Frame().Width() - contLoc.x - 3.0f);
|
Frame().Width() - contLoc.x - 3.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(Label(), truncatedTitle.String()) != 0)
|
if (strcmp(Label(), truncatedTitle.String()) != 0)
|
||||||
@ -141,22 +144,26 @@ TWindowMenuItem::ID()
|
|||||||
void
|
void
|
||||||
TWindowMenuItem::GetContentSize(float *width, float *height)
|
TWindowMenuItem::GetContentSize(float *width, float *height)
|
||||||
{
|
{
|
||||||
if (!fExpanded) {
|
if (width != NULL) {
|
||||||
*width = kHPad + fTitleWidth + kHPad;
|
if (!fExpanded) {
|
||||||
if (fID >= 0)
|
*width = kHPad + fTitleWidth + kHPad;
|
||||||
*width += fBitmap->Bounds().Width() + kLabelOffset;
|
if (fID >= 0)
|
||||||
} else
|
*width += fBitmap->Bounds().Width() + kLabelOffset;
|
||||||
*width = Frame().Width()/* - kHPad*/;
|
} else
|
||||||
|
*width = Frame().Width()/* - kHPad*/;
|
||||||
|
}
|
||||||
|
|
||||||
// Note: when the item is in "expanded mode", ie embedded into
|
// Note: when the item is in "expanded mode", ie embedded into
|
||||||
// the Deskbar itself, then a truncated label is used in SetLabel()
|
// the Deskbar itself, then a truncated label is used in SetLabel()
|
||||||
// The code here is ignorant of this fact, but it doesn't seem to
|
// The code here is ignorant of this fact, but it doesn't seem to
|
||||||
// hurt anything.
|
// hurt anything.
|
||||||
|
|
||||||
*height = (fID >= 0) ? fBitmap->Bounds().Height() : 0.0f;
|
if (height != NULL) {
|
||||||
float labelHeight = fTitleAscent + fTitleDescent;
|
*height = (fID >= 0) ? fBitmap->Bounds().Height() : 0.0f;
|
||||||
*height = (labelHeight > *height) ? labelHeight : *height;
|
float labelHeight = fTitleAscent + fTitleDescent;
|
||||||
*height += kVPad * 2;
|
*height = (labelHeight > *height) ? labelHeight : *height;
|
||||||
|
*height += kVPad * 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -172,12 +179,14 @@ TWindowMenuItem::Draw()
|
|||||||
|
|
||||||
// if not selected or being tracked on, fill with gray
|
// if not selected or being tracked on, fill with gray
|
||||||
TBarView *barview = (static_cast<TBarApp *>(be_app))->BarView();
|
TBarView *barview = (static_cast<TBarApp *>(be_app))->BarView();
|
||||||
if (!IsSelected() && !menu->IsRedrawAfterSticky() || barview->Dragging() || !IsEnabled()) {
|
if (!IsSelected() && !menu->IsRedrawAfterSticky()
|
||||||
|
|| barview->Dragging() || !IsEnabled()) {
|
||||||
menu->SetHighColor(menuColor);
|
menu->SetHighColor(menuColor);
|
||||||
menu->FillRect(frame);
|
menu->FillRect(frame);
|
||||||
|
|
||||||
if (fExpanded) {
|
if (fExpanded) {
|
||||||
rgb_color shadow = tint_color(menuColor, (B_NO_TINT + B_DARKEN_1_TINT) / 2.0f);
|
rgb_color shadow = tint_color(menuColor,
|
||||||
|
(B_NO_TINT + B_DARKEN_1_TINT) / 2.0f);
|
||||||
menu->SetHighColor(shadow);
|
menu->SetHighColor(shadow);
|
||||||
frame.right = frame.left + kHPad / 2;
|
frame.right = frame.left + kHPad / 2;
|
||||||
menu->FillRect(frame);
|
menu->FillRect(frame);
|
||||||
@ -186,7 +195,8 @@ TWindowMenuItem::Draw()
|
|||||||
|
|
||||||
if (IsEnabled() && IsSelected() && !menu->IsRedrawAfterSticky()) {
|
if (IsEnabled() && IsSelected() && !menu->IsRedrawAfterSticky()) {
|
||||||
// fill
|
// fill
|
||||||
menu->SetHighColor(tint_color(menuColor, B_HIGHLIGHT_BACKGROUND_TINT));
|
menu->SetHighColor(tint_color(menuColor,
|
||||||
|
B_HIGHLIGHT_BACKGROUND_TINT));
|
||||||
menu->FillRect(frame);
|
menu->FillRect(frame);
|
||||||
} else
|
} else
|
||||||
menu->SetLowColor(menuColor);
|
menu->SetLowColor(menuColor);
|
||||||
@ -228,7 +238,8 @@ TWindowMenuItem::DrawContent()
|
|||||||
|
|
||||||
menu->SetDrawingMode(B_OP_COPY);
|
menu->SetDrawingMode(B_OP_COPY);
|
||||||
}
|
}
|
||||||
contLoc.y = frame.top + ((frame.Height() - fTitleAscent - fTitleDescent) / 2) + 1.0f;
|
contLoc.y = frame.top
|
||||||
|
+ ((frame.Height() - fTitleAscent - fTitleDescent) / 2) + 1.0f;
|
||||||
menu->PopState();
|
menu->PopState();
|
||||||
|
|
||||||
menu->MovePenTo(contLoc);
|
menu->MovePenTo(contLoc);
|
||||||
@ -240,12 +251,12 @@ TWindowMenuItem::DrawContent()
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
TWindowMenuItem::Invoke(BMessage *)
|
TWindowMenuItem::Invoke(BMessage* /*message*/)
|
||||||
{
|
{
|
||||||
if (!fDragging) {
|
if (!fDragging) {
|
||||||
if (fID >= 0) {
|
if (fID >= 0) {
|
||||||
int32 action = (modifiers() & B_CONTROL_KEY)
|
int32 action = (modifiers() & B_CONTROL_KEY) != 0
|
||||||
? B_MINIMIZE_WINDOW :B_BRING_TO_FRONT;
|
? B_MINIMIZE_WINDOW : B_BRING_TO_FRONT;
|
||||||
|
|
||||||
bool doZoom = false;
|
bool doZoom = false;
|
||||||
BRect zoomRect(0.0f, 0.0f, 0.0f, 0.0f);
|
BRect zoomRect(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
@ -257,8 +268,8 @@ TWindowMenuItem::Invoke(BMessage *)
|
|||||||
|
|
||||||
if (item->Menu()->Window() != NULL) {
|
if (item->Menu()->Window() != NULL) {
|
||||||
zoomRect = item->Menu()->ConvertToScreen(item->Frame());
|
zoomRect = item->Menu()->ConvertToScreen(item->Frame());
|
||||||
doZoom = fMini && (action == B_BRING_TO_FRONT) ||
|
doZoom = fMini && action == B_BRING_TO_FRONT
|
||||||
!fMini && (action == B_MINIMIZE_WINDOW);
|
|| !fMini && action == B_MINIMIZE_WINDOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
do_window_action(fID, action, zoomRect, doZoom);
|
do_window_action(fID, action, zoomRect, doZoom);
|
||||||
|
Loading…
Reference in New Issue
Block a user