Deskbar: Resizable tray

* Adds max width and height arguments to
  instantiate_deskbar_(item|entry).
* Old applications just stay with a 16x16 scaled icon, though.
* All used apps within the repository are converted to the new call
  besides the input_server input method icon (that will need further
  API changes in the input_server).

Change-Id: I29cc439396917be2c24135888459d31364997dff
Reviewed-on: https://review.haiku-os.org/656
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
Axel Dörfler
2018-11-04 19:00:49 +00:00
committed by waddlesplash
parent 1ad1c1c87b
commit efafab643c
20 changed files with 196 additions and 90 deletions
@@ -47,13 +47,13 @@ through a pointer to an int32.</P></LI>
<LI><P><B>Add Item 2:</B> The AddItem() member function can be used to add an item to the deskbar <LI><P><B>Add Item 2:</B> The AddItem() member function can be used to add an item to the deskbar
shelf by passing a pointer to an entry_ref. The file pointed to by this entry_ref should be shelf by passing a pointer to an entry_ref. The file pointed to by this entry_ref should be
an addon that exports the symbol "BView *instantiate_deskbar_item()". This entry point is used to an addon that exports the symbol "BView *instantiate_deskbar_item(float, float)". This entry point is used to
get a BView which it can display in the shelf. More information on this mechanism can be found in get a BView which it can display in the shelf. More information on this mechanism can be found in
the <A HREF="file:///boot/beos/documentation/Be%20Book/Release%20Notes/Deskbar.html">Deskbar Release Notes</A> the <A HREF="file:///boot/beos/documentation/Be%20Book/Release%20Notes/Deskbar.html">Deskbar Release Notes</A>
but not in the Be Book proper. The item id of the added item is passed back in an int32 pointer but not in the Be Book proper. The item id of the added item is passed back in an int32 pointer
provided by the caller. NOTE: The source code for the deskbar found in provided by the caller. NOTE: The source code for the deskbar found in
<A HREF="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/opentracker/opentracker/deskbar/StatusView.cpp?rev=1.5&content-type=text/vnd.viewcvs-markup">TReplicantTray::LoadAddon()</A> <A HREF="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/opentracker/opentracker/deskbar/StatusView.cpp?rev=1.5&content-type=text/vnd.viewcvs-markup">TReplicantTray::LoadAddon()</A>
indicates that it also looks for a symbol called "BView *instantiate_deskbar_entry(image_id, entry_ref *)" indicates that it also looks for a symbol called "BView *instantiate_deskbar_entry(image_id, entry_ref*, float, float)"
first, but there is no documentation on this.</P></LI> first, but there is no documentation on this.</P></LI>
<LI><P><B>Remove Item 1:</B> The RemoveItem() member function takes an integer id and removes it <LI><P><B>Remove Item 1:</B> The RemoveItem() member function takes an integer id and removes it
@@ -155,7 +155,7 @@ theMsg.AddMessage("view", &amp;viewMsg); // This puts the archived view in th
</PRE> </PRE>
<P>Or, the AddItem() member sends the following message to the deskbar to add an item from a file <P>Or, the AddItem() member sends the following message to the deskbar to add an item from a file
that exports the "BView *instantiate_deskbar_item(void)" function:</P> that exports the "BView *instantiate_deskbar_item(float, float)" function:</P>
<PRE> <PRE>
BMessage theMsg; BMessage theMsg;
+3 -1
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2006-2009, Haiku, Inc. All rights reserved. * Copyright 2006-2018, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef _DESKBAR_H #ifndef _DESKBAR_H
@@ -56,6 +56,8 @@ public:
bool HasItem(int32 id) const; bool HasItem(int32 id) const;
bool HasItem(const char* name) const; bool HasItem(const char* name) const;
uint32 CountItems() const; uint32 CountItems() const;
float MaxItemWidth() const;
float MaxItemHeight() const;
// Item modification methods // Item modification methods
status_t AddItem(BView* archivableView, status_t AddItem(BView* archivableView,
@@ -29,6 +29,7 @@ static const uint32 kMsgAddAddOn = 'adon';
static const uint32 kMsgHasItem = 'exst'; static const uint32 kMsgHasItem = 'exst';
static const uint32 kMsgGetItemInfo = 'info'; static const uint32 kMsgGetItemInfo = 'info';
static const uint32 kMsgCountItems = 'cwnt'; static const uint32 kMsgCountItems = 'cwnt';
static const uint32 kMsgMaxItemSize = 'mxsz';
static const uint32 kMsgRemoveItem = 'remv'; static const uint32 kMsgRemoveItem = 'remv';
static const uint32 kMsgLocation = 'gloc'; static const uint32 kMsgLocation = 'gloc';
static const uint32 kMsgIsExpanded = 'gexp'; static const uint32 kMsgIsExpanded = 'gexp';
+1
View File
@@ -400,6 +400,7 @@ TBarApp::MessageReceived(BMessage* message)
case kMsgGetItemInfo: case kMsgGetItemInfo:
case kMsgHasItem: case kMsgHasItem:
case kMsgCountItems: case kMsgCountItems:
case kMsgMaxItemSize:
case kMsgAddView: case kMsgAddView:
case kMsgRemoveItem: case kMsgRemoveItem:
case kMsgAddAddOn: case kMsgAddAddOn:
+8
View File
@@ -1119,6 +1119,14 @@ TBarView::CountItems(DeskbarShelf)
} }
BSize
TBarView::MaxItemSize(DeskbarShelf shelf)
{
return BSize(fReplicantTray->MaxReplicantWidth(),
fReplicantTray->MaxReplicantHeight());
}
status_t status_t
TBarView::AddItem(BMessage* item, DeskbarShelf, int32* id) TBarView::AddItem(BMessage* item, DeskbarShelf, int32* id)
{ {
+2
View File
@@ -143,6 +143,8 @@ public:
int32 CountItems(DeskbarShelf shelf); int32 CountItems(DeskbarShelf shelf);
BSize MaxItemSize(DeskbarShelf shelf);
status_t AddItem(BMessage* archive, DeskbarShelf shelf, status_t AddItem(BMessage* archive, DeskbarShelf shelf,
int32* id); int32* id);
status_t AddItem(BEntry* entry, DeskbarShelf shelf, status_t AddItem(BEntry* entry, DeskbarShelf shelf,
+22
View File
@@ -198,6 +198,10 @@ TBarWindow::MessageReceived(BMessage* message)
CountItems(message); CountItems(message);
break; break;
case kMsgMaxItemSize:
MaxItemSize(message);
break;
case kMsgAddAddOn: case kMsgAddAddOn:
case kMsgAddView: case kMsgAddView:
AddItem(message); AddItem(message);
@@ -545,6 +549,24 @@ TBarWindow::CountItems(BMessage* message)
} }
void
TBarWindow::MaxItemSize(BMessage* message)
{
DeskbarShelf shelf;
#if SHELF_AWARE
if (message->FindInt32("shelf", (int32*)&shelf) != B_OK)
#endif
shelf = B_DESKBAR_TRAY;
BSize size = fBarView->MaxItemSize(shelf);
BMessage reply('rply');
reply.AddFloat("width", size.width);
reply.AddFloat("height", size.height);
message->SendReply(&reply);
}
void void
TBarWindow::AddItem(BMessage* message) TBarWindow::AddItem(BMessage* message)
{ {
+1
View File
@@ -78,6 +78,7 @@ public:
void ItemExists(BMessage* message); void ItemExists(BMessage* message);
void CountItems(BMessage* message); void CountItems(BMessage* message);
void MaxItemSize(BMessage* message);
void AddItem(BMessage* message); void AddItem(BMessage* message);
void RemoveItem(BMessage* message); void RemoveItem(BMessage* message);
+23 -15
View File
@@ -136,13 +136,20 @@ TReplicantTray::TReplicantTray(TBarView* parent, bool vertical)
fMultiRowMode(vertical), fMultiRowMode(vertical),
fAlignmentSupport(false) fAlignmentSupport(false)
{ {
fMaxReplicantHeight = std::max(kMinReplicantHeight,
floorf(kMinReplicantHeight * be_plain_font->Size() / 12));
// TODO: depends on window size... (so use something like
// max(129, height * 3), and restrict the minimum window width for it)
fMaxReplicantWidth = 129;
fMinTrayHeight = kGutter + fMaxReplicantHeight + kGutter;
if (vertical) if (vertical)
fMinimumTrayWidth = gMinimumWindowWidth - kGutter - kDragRegionWidth; fMinimumTrayWidth = gMinimumWindowWidth - kGutter - kDragRegionWidth;
else else
fMinimumTrayWidth = kMinimumTrayWidth; fMinimumTrayWidth = kMinimumTrayWidth;
// Create the time view // Create the time view
fTime = new TTimeView(fMinimumTrayWidth, kMaxReplicantHeight - 1.0); fTime = new TTimeView(fMinimumTrayWidth, fMaxReplicantHeight - 1.0);
} }
@@ -211,7 +218,7 @@ void
TReplicantTray::GetPreferredSize(float* preferredWidth, float* preferredHeight) TReplicantTray::GetPreferredSize(float* preferredWidth, float* preferredHeight)
{ {
float width = 0; float width = 0;
float height = kMinimumTrayHeight; float height = fMinTrayHeight;
if (fMultiRowMode) { if (fMultiRowMode) {
width = static_cast<TBarApp*>(be_app)->Settings()->width width = static_cast<TBarApp*>(be_app)->Settings()->width
@@ -221,12 +228,12 @@ TReplicantTray::GetPreferredSize(float* preferredWidth, float* preferredHeight)
else if (ReplicantCount() > 0) { else if (ReplicantCount() > 0) {
// The height will be uniform for the number of rows necessary // The height will be uniform for the number of rows necessary
// to show all the replicants and gutters. // to show all the replicants and gutters.
int32 rowCount = (int32)(height / kMaxReplicantHeight); int32 rowCount = (int32)(height / fMaxReplicantHeight);
height = kGutter + (rowCount * kMaxReplicantHeight) height = kGutter + (rowCount * fMaxReplicantHeight)
+ ((rowCount - 1) * kIconGap) + kGutter; + ((rowCount - 1) * kIconGap) + kGutter;
height = std::max(kMinimumTrayHeight, height); height = std::max(fMinTrayHeight, height);
} else } else
height = kMinimumTrayHeight; height = fMinTrayHeight;
} else { } else {
// if last replicant overruns clock then resize to accomodate // if last replicant overruns clock then resize to accomodate
if (ReplicantCount() > 0) { if (ReplicantCount() > 0) {
@@ -240,7 +247,7 @@ TReplicantTray::GetPreferredSize(float* preferredWidth, float* preferredHeight)
} }
// this view has a fixed minimum width // this view has a fixed minimum width
width = std::max(fMinimumTrayWidth, width); width = std::max(kMinimumTrayWidth, width);
height = kGutter + static_cast<TBarApp*>(be_app)->IconSize() + kGutter; height = kGutter + static_cast<TBarApp*>(be_app)->IconSize() + kGutter;
} }
@@ -641,8 +648,8 @@ TReplicantTray::LoadAddOn(BEntry* entry, int32* id, bool addToSettings)
// we first look for a symbol that takes an image_id // we first look for a symbol that takes an image_id
// and entry_ref pointer, if not found, go with normal // and entry_ref pointer, if not found, go with normal
// instantiate function // instantiate function
BView* (*entryFunction)(image_id, const entry_ref*); BView* (*entryFunction)(image_id, const entry_ref*, float, float);
BView* (*itemFunction)(void); BView* (*itemFunction)(float, float);
BView* view = NULL; BView* view = NULL;
entry_ref ref; entry_ref ref;
@@ -650,10 +657,11 @@ TReplicantTray::LoadAddOn(BEntry* entry, int32* id, bool addToSettings)
if (get_image_symbol(image, kInstantiateEntryCFunctionName, if (get_image_symbol(image, kInstantiateEntryCFunctionName,
B_SYMBOL_TYPE_TEXT, (void**)&entryFunction) >= B_OK) { B_SYMBOL_TYPE_TEXT, (void**)&entryFunction) >= B_OK) {
view = (*entryFunction)(image, &ref); view = (*entryFunction)(image, &ref, fMaxReplicantWidth,
fMaxReplicantHeight);
} else if (get_image_symbol(image, kInstantiateItemCFunctionName, } else if (get_image_symbol(image, kInstantiateItemCFunctionName,
B_SYMBOL_TYPE_TEXT, (void**)&itemFunction) >= B_OK) { B_SYMBOL_TYPE_TEXT, (void**)&itemFunction) >= B_OK) {
view = (*itemFunction)(); view = (*itemFunction)(fMaxReplicantWidth, fMaxReplicantHeight);
} else { } else {
unload_add_on(image); unload_add_on(image);
return B_ERROR; return B_ERROR;
@@ -1121,7 +1129,7 @@ TReplicantTray::AcceptAddon(BRect replicantFrame, BMessage* message)
if (message == NULL) if (message == NULL)
return false; return false;
if (replicantFrame.Height() > kMaxReplicantHeight) if (replicantFrame.Height() > fMaxReplicantHeight)
return false; return false;
alignment align = B_ALIGN_LEFT; alignment align = B_ALIGN_LEFT;
@@ -1163,12 +1171,12 @@ TReplicantTray::LocationForReplicant(int32 index, float replicantWidth)
if (fMultiRowMode) { if (fMultiRowMode) {
// try to find free space in every row // try to find free space in every row
for (int32 row = 0; ; loc.y += kMaxReplicantHeight + kIconGap, row++) { for (int32 row = 0; ; loc.y += fMaxReplicantHeight + kIconGap, row++) {
// determine free space in this row // determine free space in this row
BRect rowRect(loc.x, loc.y, BRect rowRect(loc.x, loc.y,
loc.x + static_cast<TBarApp*>(be_app)->Settings()->width loc.x + static_cast<TBarApp*>(be_app)->Settings()->width
- (kTrayPadding + kDragWidth + kGutter) * 2, - (kTrayPadding + kDragWidth + kGutter) * 2,
loc.y + kMaxReplicantHeight); loc.y + fMaxReplicantHeight);
if (row == 0 && !fTime->IsHidden()) if (row == 0 && !fTime->IsHidden())
rowRect.right -= kClockMargin + fTime->Frame().Width(); rowRect.right -= kClockMargin + fTime->Frame().Width();
@@ -1210,7 +1218,7 @@ TReplicantTray::LocationForReplicant(int32 index, float replicantWidth)
|| (loc.y == fRightBottomReplicant.top || (loc.y == fRightBottomReplicant.top
&& loc.x > fRightBottomReplicant.left)) { && loc.x > fRightBottomReplicant.left)) {
fRightBottomReplicant.Set(loc.x, loc.y, loc.x + replicantWidth, fRightBottomReplicant.Set(loc.x, loc.y, loc.x + replicantWidth,
loc.y + kMaxReplicantHeight); loc.y + fMaxReplicantHeight);
fLastReplicant = index; fLastReplicant = index;
} }
+11 -5
View File
@@ -47,8 +47,8 @@ All rights reserved.
const float kDragWidth = 4.0f; const float kDragWidth = 4.0f;
const float kMaxReplicantHeight = 16.0f; const float kMinReplicantHeight = 16.0f;
const float kMaxReplicantWidth = 16.0f; const float kMinReplicantWidth = 16.0f;
const int32 kMinimumReplicantCount = 6; const int32 kMinimumReplicantCount = 6;
const int32 kIconGap = 2; const int32 kIconGap = 2;
const int32 kGutter = 1; const int32 kGutter = 1;
@@ -59,10 +59,9 @@ const int32 kClockMargin = 12;
// 1 pixel for left gutter // 1 pixel for left gutter
// space for replicant tray (6 items) // space for replicant tray (6 items)
// 6 pixel drag region // 6 pixel drag region
const float kMinimumTrayWidth = kIconGap + kMaxReplicantWidth const float kMinimumTrayWidth = kIconGap + kMinReplicantWidth
+ (kMinimumReplicantCount * kIconGap) + (kMinimumReplicantCount * kIconGap)
+ (kMinimumReplicantCount * kMaxReplicantWidth) + kGutter; + (kMinimumReplicantCount * kMinReplicantWidth) + kGutter;
const float kMinimumTrayHeight = kGutter + kMaxReplicantHeight + kGutter;
extern float gMinimumWindowWidth; extern float gMinimumWindowWidth;
extern float gMaximumWindowWidth; extern float gMaximumWindowWidth;
@@ -109,6 +108,10 @@ public:
bool IconExists(const char* name); bool IconExists(const char* name);
int32 ReplicantCount() const; int32 ReplicantCount() const;
float MaxReplicantWidth() const
{ return fMaxReplicantWidth; }
float MaxReplicantHeight() const
{ return fMaxReplicantHeight; }
status_t AddIcon(BMessage*, int32* id, status_t AddIcon(BMessage*, int32* id,
const entry_ref* = NULL); const entry_ref* = NULL);
@@ -174,6 +177,9 @@ private:
TReplicantShelf* fShelf; TReplicantShelf* fShelf;
BRect fRightBottomReplicant; BRect fRightBottomReplicant;
int32 fLastReplicant; int32 fLastReplicant;
float fMaxReplicantWidth;
float fMaxReplicantHeight;
float fMinTrayHeight;
bool fMultiRowMode; bool fMultiRowMode;
float fMinimumTrayWidth; float fMinimumTrayWidth;
+3 -3
View File
@@ -64,7 +64,7 @@ static const char *kStatusDescriptions[] = {
B_TRANSLATE("Ready") B_TRANSLATE("Ready")
}; };
extern "C" _EXPORT BView *instantiate_deskbar_item(void); extern "C" _EXPORT BView *instantiate_deskbar_item(float maxWidth, float maxHeight);
const uint32 kMsgShowConfiguration = 'shcf'; const uint32 kMsgShowConfiguration = 'shcf';
@@ -574,9 +574,9 @@ NetworkStatusView::_OpenNetworksPreferences()
extern "C" _EXPORT BView * extern "C" _EXPORT BView *
instantiate_deskbar_item(void) instantiate_deskbar_item(float maxWidth, float maxHeight)
{ {
return new NetworkStatusView(BRect(0, 0, 15, 15), return new NetworkStatusView(BRect(0, 0, maxHeight - 1, maxHeight - 1),
B_FOLLOW_LEFT | B_FOLLOW_TOP, true); B_FOLLOW_LEFT | B_FOLLOW_TOP, true);
} }
+7 -5
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2006-2017, Haiku, Inc. All Rights Reserved. * Copyright 2006-2018, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -49,7 +49,8 @@
#define B_TRANSLATION_CONTEXT "PowerStatus" #define B_TRANSLATION_CONTEXT "PowerStatus"
extern "C" _EXPORT BView *instantiate_deskbar_item(void); extern "C" _EXPORT BView *instantiate_deskbar_item(float maxWidth,
float maxHeight);
extern const char* kDeskbarItemName; extern const char* kDeskbarItemName;
const uint32 kMsgToggleLabel = 'tglb'; const uint32 kMsgToggleLabel = 'tglb';
@@ -397,7 +398,7 @@ PowerStatusView::Update(bool force)
if (fInDeskbar) { if (fInDeskbar) {
// make sure the tray icon is (just) large enough // make sure the tray icon is (just) large enough
float width = fShowStatusIcon ? kMinIconWidth - 1 : 0; float width = fShowStatusIcon ? Bounds().Height() : 0;
if (fShowLabel) { if (fShowLabel) {
char text[64]; char text[64];
@@ -870,7 +871,8 @@ PowerStatusReplicant::_OpenExtendedWindow()
extern "C" _EXPORT BView* extern "C" _EXPORT BView*
instantiate_deskbar_item(void) instantiate_deskbar_item(float maxWidth, float maxHeight)
{ {
return new PowerStatusReplicant(BRect(0, 0, 15, 15), B_FOLLOW_NONE, true); return new PowerStatusReplicant(BRect(0, 0, maxHeight - 1, maxHeight - 1),
B_FOLLOW_NONE, true);
} }
@@ -1,7 +1,7 @@
/* /*
ProcessController © 2000, Georges-Edouard Berenger, All Rights Reserved. ProcessController © 2000, Georges-Edouard Berenger, All Rights Reserved.
Copyright (C) 2004 beunited.org Copyright (C) 2004 beunited.org
Copyright (c) 2006-2015, Haiku, Inc. All rights reserved. Copyright (c) 2006-2018, Haiku, Inc. All rights reserved.
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
@@ -117,6 +117,7 @@ typedef struct {
} Tdebug_thead_param; } Tdebug_thead_param;
// Bar layout depending on number of CPUs // Bar layout depending on number of CPUs
// This is used only in case the replicant width is 16
typedef struct { typedef struct {
float cpu_width; float cpu_width;
@@ -141,13 +142,14 @@ layoutT layout[] = {
}; };
extern "C" _EXPORT BView *instantiate_deskbar_item(void); extern "C" _EXPORT BView* instantiate_deskbar_item(float maxWidth,
float maxHeight);
extern "C" _EXPORT BView * extern "C" _EXPORT BView*
instantiate_deskbar_item(void) instantiate_deskbar_item(float maxWidth, float maxHeight)
{ {
gInDeskbar = true; gInDeskbar = true;
return new ProcessController(); return new ProcessController(maxHeight - 1, maxHeight - 1);
} }
@@ -196,8 +198,10 @@ ProcessController::ProcessController(BMessage *data)
} }
ProcessController::ProcessController() ProcessController::ProcessController(float width, float height)
: BView(BRect (0, 0, 15, 15), kDeskbarItemName, B_FOLLOW_NONE, B_WILL_DRAW), :
BView(BRect (0, 0, width, height), kDeskbarItemName, B_FOLLOW_NONE,
B_WILL_DRAW),
fProcessControllerIcon(kSignature), fProcessControllerIcon(kSignature),
fProcessorIcon(k_cpu_mini), fProcessorIcon(k_cpu_mini),
fTrackerIcon(kTrackerSig), fTrackerIcon(kTrackerSig),
@@ -602,10 +606,23 @@ ProcessController::DoDraw(bool force)
float h = floorf(bounds.Height ()) - 2; float h = floorf(bounds.Height ()) - 2;
float top = 1, left = 1; float top = 1, left = 1;
float bottom = top + h; float bottom = top + h;
float barWidth = layout[gCPUcount].cpu_width; float barWidth;
float barGap;
float memWidth;
if (gCPUcount < 12 && bounds.Width() == 15) {
// Use fixed sizes for small icon sizes
barWidth = layout[gCPUcount].cpu_width;
barGap = layout[gCPUcount].cpu_inter;
memWidth = layout[gCPUcount].mem_width;
} else {
memWidth = floorf((bounds.Height() + 1) / 8);
barGap = bounds.Width() / gCPUcount > 3 ? 1 : 0;
barWidth = floorf((bounds.Width() - 2 - memWidth - barGap * gCPUcount)
/ gCPUcount);
}
// interspace // interspace
float right = left + gCPUcount * (barWidth + layout[gCPUcount].cpu_inter) float right = left + gCPUcount * (barWidth + barGap) - barGap;
- layout[gCPUcount].cpu_inter; // right of CPU frame... // right of CPU frame...
if (force && Parent()) { if (force && Parent()) {
SetHighColor(Parent()->ViewColor()); SetHighColor(Parent()->ViewColor());
FillRect(BRect(right + 1, top - 1, right + 2, bottom + 1)); FillRect(BRect(right + 1, top - 1, right + 2, bottom + 1));
@@ -614,16 +631,15 @@ ProcessController::DoDraw(bool force)
if (force) { if (force) {
SetHighColor(frame_color); SetHighColor(frame_color);
StrokeRect(BRect(left - 1, top - 1, right, bottom + 1)); StrokeRect(BRect(left - 1, top - 1, right, bottom + 1));
if (gCPUcount > 1 && layout[gCPUcount].cpu_inter == 1) { if (gCPUcount > 1 && barGap == 1) {
for (unsigned int x = 1; x < gCPUcount; x++) for (unsigned int x = 1; x < gCPUcount; x++)
StrokeLine(BPoint(left + x * barWidth + x - 1, top), StrokeLine(BPoint(left + x * barWidth + x - 1, top),
BPoint(left + x * barWidth + x - 1, bottom)); BPoint(left + x * barWidth + x - 1, bottom));
} }
} }
float leftMem = bounds.Width() - layout[gCPUcount].mem_width; float leftMem = bounds.Width() - memWidth;
if (force) if (force)
StrokeRect(BRect(leftMem - 1, top - 1, StrokeRect(BRect(leftMem - 1, top - 1, leftMem + memWidth, bottom + 1));
leftMem + layout[gCPUcount].mem_width, bottom + 1));
for (unsigned int x = 0; x < gCPUcount; x++) { for (unsigned int x = 0; x < gCPUcount; x++) {
right = left + barWidth - 1; right = left + barWidth - 1;
@@ -654,7 +670,7 @@ ProcessController::DoDraw(bool force)
SetHighColor(active_color); SetHighColor(active_color);
FillRect(BRect(left, limit + 1, right, active_bottom)); FillRect(BRect(left, limit + 1, right, active_bottom));
} }
left += layout[gCPUcount].cpu_width + layout[gCPUcount].cpu_inter; left += barWidth + barGap;
fLastBarHeight[x] = barHeight; fLastBarHeight[x] = barHeight;
} }
@@ -1,7 +1,7 @@
/* /*
ProcessController © 2000, Georges-Edouard Berenger, All Rights Reserved. ProcessController © 2000, Georges-Edouard Berenger, All Rights Reserved.
Copyright (C) 2004 beunited.org Copyright (C) 2004 beunited.org
Copyright (c) 2006-2013, Haiku, Inc. All rights reserved. Copyright (c) 2006-2018, Haiku, Inc. All rights reserved.
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
@@ -34,7 +34,7 @@ class ProcessController : public BView {
public: public:
ProcessController(BRect frame, bool temp = false); ProcessController(BRect frame, bool temp = false);
ProcessController(BMessage *data); ProcessController(BMessage *data);
ProcessController(); ProcessController(float width, float height);
virtual ~ProcessController(); virtual ~ProcessController();
virtual void MessageReceived(BMessage *message); virtual void MessageReceived(BMessage *message);
+1 -1
View File
@@ -138,7 +138,7 @@ void DeskbarPulseView::MessageReceived(BMessage *message) {
break; break;
case PRV_DESKBAR_ICON_WIDTH: { case PRV_DESKBAR_ICON_WIDTH: {
int width = message->FindInt32("width"); int width = message->FindInt32("width");
ResizeTo(width - 1, 15); ResizeTo(width - 1, Bounds().Height());
Draw(Bounds()); Draw(Bounds());
break; break;
} }
+2 -1
View File
@@ -266,7 +266,8 @@ LoadInDeskbar()
width = min_width; width = min_width;
} }
BRect rect(0, 0, width - 1, 15); float height = deskbar->MaxItemHeight();
BRect rect(0, 0, width - 1, height - 1);
DeskbarPulseView *replicant = new DeskbarPulseView(rect); DeskbarPulseView *replicant = new DeskbarPulseView(rect);
status_t err = deskbar->AddItem(replicant); status_t err = deskbar->AddItem(replicant);
delete replicant; delete replicant;
+21 -17
View File
@@ -58,7 +58,8 @@ static const uint32 kMsgToggleLiveInDeskbar = 'tgDb';
static const uint32 kMsgToggleSwitchOnWheel = 'tgWh'; static const uint32 kMsgToggleSwitchOnWheel = 'tgWh';
extern "C" _EXPORT BView* instantiate_deskbar_item(); extern "C" _EXPORT BView* instantiate_deskbar_item(float maxWidth,
float maxHeight);
static status_t static status_t
@@ -1092,7 +1093,18 @@ WorkspacesApp::ArgvReceived(int32 argc, char **argv)
} }
BView* instantiate_deskbar_item() void
WorkspacesApp::ReadyToRun()
{
fWindow->Show();
}
// #pragma mark -
BView*
instantiate_deskbar_item(float maxWidth, float maxHeight)
{ {
// Calculate the correct size of the Deskbar replicant first // Calculate the correct size of the Deskbar replicant first
@@ -1103,15 +1115,14 @@ BView* instantiate_deskbar_item()
uint32 columns, rows; uint32 columns, rows;
BPrivate::get_workspaces_layout(&columns, &rows); BPrivate::get_workspaces_layout(&columns, &rows);
// ╔═╤═╕ A Deskbar replicant can be 16px tall and 129px wide at most. // We use 1px for the top and left borders (shown as double)
// ║ │ │ We use 1px for the top and left borders (shown as double) // and divide the remainder equally. However, we keep in mind
// ╟─┼─┤ and divide the remainder equally. However, we keep in mind // that the actual width and height of each workspace is smaller
// ║ │ │ that the actual width and height of each workspace is smaller // by 1px, because of bottom/right borders (shown as single).
// ╙─┴─┘ by 1px, because of bottom/right borders (shown as single).
// When calculating workspace width, we must ensure that the assumed // When calculating workspace width, we must ensure that the assumed
// actual workspace height is not negative. Zero is OK. // actual workspace height is not negative. Zero is OK.
float height = 16; float height = maxHeight;
float rowHeight = floor((height - 1) / rows); float rowHeight = floor((height - 1) / rows);
if (rowHeight < 1) if (rowHeight < 1)
rowHeight = 1; rowHeight = 1;
@@ -1119,20 +1130,13 @@ BView* instantiate_deskbar_item()
float columnWidth = floor((rowHeight - 1) * aspectRatio) + 1; float columnWidth = floor((rowHeight - 1) * aspectRatio) + 1;
float width = columnWidth * columns + 1; float width = columnWidth * columns + 1;
if (width > 129) if (width > maxWidth)
width = 129; width = maxWidth;
return new WorkspacesView(BRect (0, 0, width - 1, height - 1), false); return new WorkspacesView(BRect (0, 0, width - 1, height - 1), false);
} }
void
WorkspacesApp::ReadyToRun()
{
fWindow->Show();
}
// #pragma mark - // #pragma mark -
+3 -2
View File
@@ -640,8 +640,9 @@ MediaReplicant::_ConnectMixer()
extern "C" BView* extern "C" BView*
instantiate_deskbar_item(void) instantiate_deskbar_item(float maxWidth, float maxHeight)
{ {
return new MediaReplicant(BRect(0, 0, 16, 16), kReplicantName); return new MediaReplicant(BRect(0, 0, maxHeight - 1, maxHeight - 1),
kReplicantName);
} }
+27 -1
View File
@@ -320,7 +320,33 @@ BDeskbar::CountItems() const
} }
// #pragma mark - Item querying methods float
BDeskbar::MaxItemWidth() const
{
BMessage request(kMsgMaxItemSize);
BMessage reply;
if (fMessenger->SendMessage(&request, &reply) == B_OK)
return reply.GetFloat("width", 129);
return 129;
}
float
BDeskbar::MaxItemHeight() const
{
BMessage request(kMsgMaxItemSize);
BMessage reply;
if (fMessenger->SendMessage(&request, &reply) == B_OK)
return reply.GetFloat("height", 16);
return 16;
}
// #pragma mark - Item modification methods
status_t status_t
+14 -9
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2004-2012, Haiku Inc. All Rights Reserved. * Copyright 2004-2018, Haiku Inc. All Rights Reserved.
* Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved. * Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
* *
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
@@ -65,29 +65,34 @@ const char* kTrackerSignature = "application/x-vnd.Be-TRAK";
#define text_part_size data_size #define text_part_size data_size
#endif #endif
extern "C" _EXPORT BView* instantiate_deskbar_item();
extern "C" _EXPORT BView* instantiate_deskbar_item(float maxWidth,
float maxHeight);
status_t our_image(image_info* image) status_t
our_image(image_info* image)
{ {
int32 cookie = 0; int32 cookie = 0;
status_t ret; status_t ret;
while ((ret = get_next_image_info(0, &cookie,image)) == B_OK) { while ((ret = get_next_image_info(0, &cookie, image)) == B_OK) {
if ((char*)our_image >= (char*)image->text_part && if ((char*)our_image >= (char*)image->text_part
(char*)our_image <= (char*)image->text_part + image->text_part_size) && (char*)our_image <= (char*)image->text_part
+ image->text_part_size)
break; break;
} }
return ret; return ret;
} }
BView* instantiate_deskbar_item(void)
BView*
instantiate_deskbar_item(float maxWidth, float maxHeight)
{ {
return new DeskbarView(BRect(0, 0, 15, 15)); return new DeskbarView(BRect(0, 0, maxHeight - 1, maxHeight - 1));
} }
//-------------------------------------------------------------------------------
// #pragma mark - // #pragma mark -