diff --git a/docs/develop/kits/interface/usecases/BDeskbarUseCases.html b/docs/develop/kits/interface/usecases/BDeskbarUseCases.html
index e64c36e970..96aeceb229 100644
--- a/docs/develop/kits/interface/usecases/BDeskbarUseCases.html
+++ b/docs/develop/kits/interface/usecases/BDeskbarUseCases.html
@@ -40,20 +40,20 @@ persists.
Add Item 1: The AddItem() member function can be used to take a passed in pointer to
a BView and send it to the deskbar for inclusion in its shelf. This BView must be archivable
-and must be exported by the application (for details on how to do this,
+and must be exported by the application (for details on how to do this,
this article
may help). The item will be added and the id of the new item will be passed back to the caller
through a pointer to an int32.
Add Item 2: 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
-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
the Deskbar Release Notes
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
TReplicantTray::LoadAddon()
-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.
Remove Item 1: The RemoveItem() member function takes an integer id and removes it
@@ -76,12 +76,12 @@ example, the small email icon often found in the deskbar is one such item.
Has Item 2: The HasItem() member function also takes a string name parameter and
returns a true or false value which indicates whether or not an item by than name exists in
-the deskbar shelf. For example, the small email icon often found in the deskbar is named
+the deskbar shelf. For example, the small email icon often found in the deskbar is named
"mail".
Get Item Info 1: The GetItemInfo() member function takes an integer id and a pointer
to a const char * (ie a string). It checks to see if the id passed in exists in the deskbar and
-sets the value of the const char * to point to a allocated buffer which contains the name of the
+sets the value of the const char * to point to a allocated buffer which contains the name of the
item which corresponds to this id and the function returns B_OK. Ownership of this allocated
buffer is assigned to the caller of this member function so it is up to the caller to free the
memory. If the id doesn't exist, then it still returns B_OK but the pointer to the string is set
@@ -122,7 +122,7 @@ when in left or right top position.
BDeskbar Implementation:
-Internally, the BDeskbar uses a BMessenger to communicate with the deskbar itself.
+
Internally, the BDeskbar uses a BMessenger to communicate with the deskbar itself.
The source code from the OpenTracker project will be used as a reference for this effort.
You can find the deskbar source code here:
@@ -137,7 +137,7 @@ here:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/opentracker/opentracker/deskbar/BarWindow.cpp?rev=1.2&content-type=text/vnd.viewcvs-markup
-The following describes the messages used to communicate between BDeskbar and the deskbar
+
The following describes the messages used to communicate between BDeskbar and the deskbar
itself.
@@ -155,7 +155,7 @@ theMsg.AddMessage("view", &viewMsg); // This puts the archived view in th
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:
+that exports the "BView *instantiate_deskbar_item(float, float)" function:
BMessage theMsg;
@@ -174,9 +174,9 @@ theMsg.AddInt32("id", theID); // This is the id of the new item
Note that in both cases, the deskbar does not set the what code of the reply. Checking the
-source code for
+source code for
TBarWindow::AddItem()
-confirms this.
+confirms this.
HasItem:
@@ -199,7 +199,7 @@ theMsg.AddBool("exists", IDorNameExists()); // This is a true/false value whi
Note that the deskbar does not set the what code of the reply. Checking the source code
-for
+for
TBarWindow::ItemExists()
confirms this.
@@ -226,7 +226,7 @@ theMsg.AddInt32("id", theID); // This is the id corresponding to the nam
Note that the deskbar does not set the what code of the reply. Checking the source code
-for
+for
TBarWindow::ItemInfo()
confirms this.
diff --git a/headers/os/interface/Deskbar.h b/headers/os/interface/Deskbar.h
index 0781139ef5..8440c86bf4 100644
--- a/headers/os/interface/Deskbar.h
+++ b/headers/os/interface/Deskbar.h
@@ -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.
*/
#ifndef _DESKBAR_H
@@ -56,6 +56,8 @@ public:
bool HasItem(int32 id) const;
bool HasItem(const char* name) const;
uint32 CountItems() const;
+ float MaxItemWidth() const;
+ float MaxItemHeight() const;
// Item modification methods
status_t AddItem(BView* archivableView,
diff --git a/headers/private/interface/DeskbarPrivate.h b/headers/private/interface/DeskbarPrivate.h
index 9289e6b6ba..4a43a34cbe 100644
--- a/headers/private/interface/DeskbarPrivate.h
+++ b/headers/private/interface/DeskbarPrivate.h
@@ -29,6 +29,7 @@ static const uint32 kMsgAddAddOn = 'adon';
static const uint32 kMsgHasItem = 'exst';
static const uint32 kMsgGetItemInfo = 'info';
static const uint32 kMsgCountItems = 'cwnt';
+static const uint32 kMsgMaxItemSize = 'mxsz';
static const uint32 kMsgRemoveItem = 'remv';
static const uint32 kMsgLocation = 'gloc';
static const uint32 kMsgIsExpanded = 'gexp';
diff --git a/src/apps/deskbar/BarApp.cpp b/src/apps/deskbar/BarApp.cpp
index 386cfd64c5..fe89bd4978 100644
--- a/src/apps/deskbar/BarApp.cpp
+++ b/src/apps/deskbar/BarApp.cpp
@@ -400,6 +400,7 @@ TBarApp::MessageReceived(BMessage* message)
case kMsgGetItemInfo:
case kMsgHasItem:
case kMsgCountItems:
+ case kMsgMaxItemSize:
case kMsgAddView:
case kMsgRemoveItem:
case kMsgAddAddOn:
diff --git a/src/apps/deskbar/BarView.cpp b/src/apps/deskbar/BarView.cpp
index b9ba42a4f3..570348d4e8 100644
--- a/src/apps/deskbar/BarView.cpp
+++ b/src/apps/deskbar/BarView.cpp
@@ -1119,6 +1119,14 @@ TBarView::CountItems(DeskbarShelf)
}
+BSize
+TBarView::MaxItemSize(DeskbarShelf shelf)
+{
+ return BSize(fReplicantTray->MaxReplicantWidth(),
+ fReplicantTray->MaxReplicantHeight());
+}
+
+
status_t
TBarView::AddItem(BMessage* item, DeskbarShelf, int32* id)
{
diff --git a/src/apps/deskbar/BarView.h b/src/apps/deskbar/BarView.h
index 3e919b4fba..6ed2b6eb87 100644
--- a/src/apps/deskbar/BarView.h
+++ b/src/apps/deskbar/BarView.h
@@ -143,6 +143,8 @@ public:
int32 CountItems(DeskbarShelf shelf);
+ BSize MaxItemSize(DeskbarShelf shelf);
+
status_t AddItem(BMessage* archive, DeskbarShelf shelf,
int32* id);
status_t AddItem(BEntry* entry, DeskbarShelf shelf,
diff --git a/src/apps/deskbar/BarWindow.cpp b/src/apps/deskbar/BarWindow.cpp
index c59f138c9a..1207eef98c 100644
--- a/src/apps/deskbar/BarWindow.cpp
+++ b/src/apps/deskbar/BarWindow.cpp
@@ -198,6 +198,10 @@ TBarWindow::MessageReceived(BMessage* message)
CountItems(message);
break;
+ case kMsgMaxItemSize:
+ MaxItemSize(message);
+ break;
+
case kMsgAddAddOn:
case kMsgAddView:
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
TBarWindow::AddItem(BMessage* message)
{
diff --git a/src/apps/deskbar/BarWindow.h b/src/apps/deskbar/BarWindow.h
index 2e8c2dddb8..212a7ef5fb 100644
--- a/src/apps/deskbar/BarWindow.h
+++ b/src/apps/deskbar/BarWindow.h
@@ -78,6 +78,7 @@ public:
void ItemExists(BMessage* message);
void CountItems(BMessage* message);
+ void MaxItemSize(BMessage* message);
void AddItem(BMessage* message);
void RemoveItem(BMessage* message);
diff --git a/src/apps/deskbar/StatusView.cpp b/src/apps/deskbar/StatusView.cpp
index cc3ed6e632..5ff13b4d58 100644
--- a/src/apps/deskbar/StatusView.cpp
+++ b/src/apps/deskbar/StatusView.cpp
@@ -136,13 +136,20 @@ TReplicantTray::TReplicantTray(TBarView* parent, bool vertical)
fMultiRowMode(vertical),
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)
fMinimumTrayWidth = gMinimumWindowWidth - kGutter - kDragRegionWidth;
else
fMinimumTrayWidth = kMinimumTrayWidth;
// 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)
{
float width = 0;
- float height = kMinimumTrayHeight;
+ float height = fMinTrayHeight;
if (fMultiRowMode) {
width = static_cast(be_app)->Settings()->width
@@ -221,12 +228,12 @@ TReplicantTray::GetPreferredSize(float* preferredWidth, float* preferredHeight)
else if (ReplicantCount() > 0) {
// The height will be uniform for the number of rows necessary
// to show all the replicants and gutters.
- int32 rowCount = (int32)(height / kMaxReplicantHeight);
- height = kGutter + (rowCount * kMaxReplicantHeight)
+ int32 rowCount = (int32)(height / fMaxReplicantHeight);
+ height = kGutter + (rowCount * fMaxReplicantHeight)
+ ((rowCount - 1) * kIconGap) + kGutter;
- height = std::max(kMinimumTrayHeight, height);
+ height = std::max(fMinTrayHeight, height);
} else
- height = kMinimumTrayHeight;
+ height = fMinTrayHeight;
} else {
// if last replicant overruns clock then resize to accomodate
if (ReplicantCount() > 0) {
@@ -240,7 +247,7 @@ TReplicantTray::GetPreferredSize(float* preferredWidth, float* preferredHeight)
}
// this view has a fixed minimum width
- width = std::max(fMinimumTrayWidth, width);
+ width = std::max(kMinimumTrayWidth, width);
height = kGutter + static_cast(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
// and entry_ref pointer, if not found, go with normal
// instantiate function
- BView* (*entryFunction)(image_id, const entry_ref*);
- BView* (*itemFunction)(void);
+ BView* (*entryFunction)(image_id, const entry_ref*, float, float);
+ BView* (*itemFunction)(float, float);
BView* view = NULL;
entry_ref ref;
@@ -650,10 +657,11 @@ TReplicantTray::LoadAddOn(BEntry* entry, int32* id, bool addToSettings)
if (get_image_symbol(image, kInstantiateEntryCFunctionName,
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,
B_SYMBOL_TYPE_TEXT, (void**)&itemFunction) >= B_OK) {
- view = (*itemFunction)();
+ view = (*itemFunction)(fMaxReplicantWidth, fMaxReplicantHeight);
} else {
unload_add_on(image);
return B_ERROR;
@@ -1121,7 +1129,7 @@ TReplicantTray::AcceptAddon(BRect replicantFrame, BMessage* message)
if (message == NULL)
return false;
- if (replicantFrame.Height() > kMaxReplicantHeight)
+ if (replicantFrame.Height() > fMaxReplicantHeight)
return false;
alignment align = B_ALIGN_LEFT;
@@ -1163,12 +1171,12 @@ TReplicantTray::LocationForReplicant(int32 index, float replicantWidth)
if (fMultiRowMode) {
// 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
BRect rowRect(loc.x, loc.y,
loc.x + static_cast(be_app)->Settings()->width
- (kTrayPadding + kDragWidth + kGutter) * 2,
- loc.y + kMaxReplicantHeight);
+ loc.y + fMaxReplicantHeight);
if (row == 0 && !fTime->IsHidden())
rowRect.right -= kClockMargin + fTime->Frame().Width();
@@ -1210,7 +1218,7 @@ TReplicantTray::LocationForReplicant(int32 index, float replicantWidth)
|| (loc.y == fRightBottomReplicant.top
&& loc.x > fRightBottomReplicant.left)) {
fRightBottomReplicant.Set(loc.x, loc.y, loc.x + replicantWidth,
- loc.y + kMaxReplicantHeight);
+ loc.y + fMaxReplicantHeight);
fLastReplicant = index;
}
diff --git a/src/apps/deskbar/StatusView.h b/src/apps/deskbar/StatusView.h
index ccaf881929..aa9326f576 100644
--- a/src/apps/deskbar/StatusView.h
+++ b/src/apps/deskbar/StatusView.h
@@ -47,8 +47,8 @@ All rights reserved.
const float kDragWidth = 4.0f;
-const float kMaxReplicantHeight = 16.0f;
-const float kMaxReplicantWidth = 16.0f;
+const float kMinReplicantHeight = 16.0f;
+const float kMinReplicantWidth = 16.0f;
const int32 kMinimumReplicantCount = 6;
const int32 kIconGap = 2;
const int32 kGutter = 1;
@@ -59,10 +59,9 @@ const int32 kClockMargin = 12;
// 1 pixel for left gutter
// space for replicant tray (6 items)
// 6 pixel drag region
-const float kMinimumTrayWidth = kIconGap + kMaxReplicantWidth
+const float kMinimumTrayWidth = kIconGap + kMinReplicantWidth
+ (kMinimumReplicantCount * kIconGap)
- + (kMinimumReplicantCount * kMaxReplicantWidth) + kGutter;
-const float kMinimumTrayHeight = kGutter + kMaxReplicantHeight + kGutter;
+ + (kMinimumReplicantCount * kMinReplicantWidth) + kGutter;
extern float gMinimumWindowWidth;
extern float gMaximumWindowWidth;
@@ -109,6 +108,10 @@ public:
bool IconExists(const char* name);
int32 ReplicantCount() const;
+ float MaxReplicantWidth() const
+ { return fMaxReplicantWidth; }
+ float MaxReplicantHeight() const
+ { return fMaxReplicantHeight; }
status_t AddIcon(BMessage*, int32* id,
const entry_ref* = NULL);
@@ -174,6 +177,9 @@ private:
TReplicantShelf* fShelf;
BRect fRightBottomReplicant;
int32 fLastReplicant;
+ float fMaxReplicantWidth;
+ float fMaxReplicantHeight;
+ float fMinTrayHeight;
bool fMultiRowMode;
float fMinimumTrayWidth;
diff --git a/src/apps/networkstatus/NetworkStatusView.cpp b/src/apps/networkstatus/NetworkStatusView.cpp
index 9eb567f339..f229bdaa14 100644
--- a/src/apps/networkstatus/NetworkStatusView.cpp
+++ b/src/apps/networkstatus/NetworkStatusView.cpp
@@ -64,7 +64,7 @@ static const char *kStatusDescriptions[] = {
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';
@@ -574,9 +574,9 @@ NetworkStatusView::_OpenNetworksPreferences()
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);
}
diff --git a/src/apps/powerstatus/PowerStatusView.cpp b/src/apps/powerstatus/PowerStatusView.cpp
index 7dc49608e8..a8b34133fa 100644
--- a/src/apps/powerstatus/PowerStatusView.cpp
+++ b/src/apps/powerstatus/PowerStatusView.cpp
@@ -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.
*
* Authors:
@@ -49,7 +49,8 @@
#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;
const uint32 kMsgToggleLabel = 'tglb';
@@ -397,7 +398,7 @@ PowerStatusView::Update(bool force)
if (fInDeskbar) {
// make sure the tray icon is (just) large enough
- float width = fShowStatusIcon ? kMinIconWidth - 1 : 0;
+ float width = fShowStatusIcon ? Bounds().Height() : 0;
if (fShowLabel) {
char text[64];
@@ -870,7 +871,8 @@ PowerStatusReplicant::_OpenExtendedWindow()
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);
}
diff --git a/src/apps/processcontroller/ProcessController.cpp b/src/apps/processcontroller/ProcessController.cpp
index 773305dda7..a1d67f47f9 100644
--- a/src/apps/processcontroller/ProcessController.cpp
+++ b/src/apps/processcontroller/ProcessController.cpp
@@ -1,7 +1,7 @@
/*
ProcessController © 2000, Georges-Edouard Berenger, All Rights Reserved.
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
modify it under the terms of the GNU Lesser General Public
@@ -117,6 +117,7 @@ typedef struct {
} Tdebug_thead_param;
// Bar layout depending on number of CPUs
+// This is used only in case the replicant width is 16
typedef struct {
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 *
-instantiate_deskbar_item(void)
+extern "C" _EXPORT BView*
+instantiate_deskbar_item(float maxWidth, float maxHeight)
{
gInDeskbar = true;
- return new ProcessController();
+ return new ProcessController(maxHeight - 1, maxHeight - 1);
}
@@ -196,8 +198,10 @@ ProcessController::ProcessController(BMessage *data)
}
-ProcessController::ProcessController()
- : BView(BRect (0, 0, 15, 15), kDeskbarItemName, B_FOLLOW_NONE, B_WILL_DRAW),
+ProcessController::ProcessController(float width, float height)
+ :
+ BView(BRect (0, 0, width, height), kDeskbarItemName, B_FOLLOW_NONE,
+ B_WILL_DRAW),
fProcessControllerIcon(kSignature),
fProcessorIcon(k_cpu_mini),
fTrackerIcon(kTrackerSig),
@@ -602,10 +606,23 @@ ProcessController::DoDraw(bool force)
float h = floorf(bounds.Height ()) - 2;
float top = 1, left = 1;
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
- float right = left + gCPUcount * (barWidth + layout[gCPUcount].cpu_inter)
- - layout[gCPUcount].cpu_inter; // right of CPU frame...
+ float right = left + gCPUcount * (barWidth + barGap) - barGap;
+ // right of CPU frame...
if (force && Parent()) {
SetHighColor(Parent()->ViewColor());
FillRect(BRect(right + 1, top - 1, right + 2, bottom + 1));
@@ -614,16 +631,15 @@ ProcessController::DoDraw(bool force)
if (force) {
SetHighColor(frame_color);
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++)
StrokeLine(BPoint(left + x * barWidth + x - 1, top),
BPoint(left + x * barWidth + x - 1, bottom));
}
}
- float leftMem = bounds.Width() - layout[gCPUcount].mem_width;
+ float leftMem = bounds.Width() - memWidth;
if (force)
- StrokeRect(BRect(leftMem - 1, top - 1,
- leftMem + layout[gCPUcount].mem_width, bottom + 1));
+ StrokeRect(BRect(leftMem - 1, top - 1, leftMem + memWidth, bottom + 1));
for (unsigned int x = 0; x < gCPUcount; x++) {
right = left + barWidth - 1;
@@ -654,7 +670,7 @@ ProcessController::DoDraw(bool force)
SetHighColor(active_color);
FillRect(BRect(left, limit + 1, right, active_bottom));
}
- left += layout[gCPUcount].cpu_width + layout[gCPUcount].cpu_inter;
+ left += barWidth + barGap;
fLastBarHeight[x] = barHeight;
}
diff --git a/src/apps/processcontroller/ProcessController.h b/src/apps/processcontroller/ProcessController.h
index 8317d17747..c45f7a5a90 100644
--- a/src/apps/processcontroller/ProcessController.h
+++ b/src/apps/processcontroller/ProcessController.h
@@ -1,7 +1,7 @@
/*
ProcessController © 2000, Georges-Edouard Berenger, All Rights Reserved.
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
modify it under the terms of the GNU Lesser General Public
@@ -34,7 +34,7 @@ class ProcessController : public BView {
public:
ProcessController(BRect frame, bool temp = false);
ProcessController(BMessage *data);
- ProcessController();
+ ProcessController(float width, float height);
virtual ~ProcessController();
virtual void MessageReceived(BMessage *message);
diff --git a/src/apps/pulse/DeskbarPulseView.cpp b/src/apps/pulse/DeskbarPulseView.cpp
index b20c3236f0..b5be675fe3 100644
--- a/src/apps/pulse/DeskbarPulseView.cpp
+++ b/src/apps/pulse/DeskbarPulseView.cpp
@@ -138,7 +138,7 @@ void DeskbarPulseView::MessageReceived(BMessage *message) {
break;
case PRV_DESKBAR_ICON_WIDTH: {
int width = message->FindInt32("width");
- ResizeTo(width - 1, 15);
+ ResizeTo(width - 1, Bounds().Height());
Draw(Bounds());
break;
}
diff --git a/src/apps/pulse/PulseApp.cpp b/src/apps/pulse/PulseApp.cpp
index 75445e7771..8b18e99f09 100644
--- a/src/apps/pulse/PulseApp.cpp
+++ b/src/apps/pulse/PulseApp.cpp
@@ -266,7 +266,8 @@ LoadInDeskbar()
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);
status_t err = deskbar->AddItem(replicant);
delete replicant;
diff --git a/src/apps/workspaces/Workspaces.cpp b/src/apps/workspaces/Workspaces.cpp
index eae4e3d0c9..b2f1b42880 100644
--- a/src/apps/workspaces/Workspaces.cpp
+++ b/src/apps/workspaces/Workspaces.cpp
@@ -58,7 +58,8 @@ static const uint32 kMsgToggleLiveInDeskbar = 'tgDb';
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
@@ -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
@@ -1103,15 +1115,14 @@ BView* instantiate_deskbar_item()
uint32 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)
- // ╟─┼─┤ and divide the remainder equally. However, we keep in mind
- // ║ │ │ that the actual width and height of each workspace is smaller
- // ╙─┴─┘ by 1px, because of bottom/right borders (shown as single).
+ // We use 1px for the top and left borders (shown as double)
+ // and divide the remainder equally. However, we keep in mind
+ // that the actual width and height of each workspace is smaller
+ // by 1px, because of bottom/right borders (shown as single).
// When calculating workspace width, we must ensure that the assumed
// actual workspace height is not negative. Zero is OK.
- float height = 16;
+ float height = maxHeight;
float rowHeight = floor((height - 1) / rows);
if (rowHeight < 1)
rowHeight = 1;
@@ -1119,20 +1130,13 @@ BView* instantiate_deskbar_item()
float columnWidth = floor((rowHeight - 1) * aspectRatio) + 1;
float width = columnWidth * columns + 1;
- if (width > 129)
- width = 129;
+ if (width > maxWidth)
+ width = maxWidth;
return new WorkspacesView(BRect (0, 0, width - 1, height - 1), false);
}
-void
-WorkspacesApp::ReadyToRun()
-{
- fWindow->Show();
-}
-
-
// #pragma mark -
diff --git a/src/bin/desklink/MediaReplicant.cpp b/src/bin/desklink/MediaReplicant.cpp
index ac1866ffbc..b70ed15fe7 100644
--- a/src/bin/desklink/MediaReplicant.cpp
+++ b/src/bin/desklink/MediaReplicant.cpp
@@ -640,8 +640,9 @@ MediaReplicant::_ConnectMixer()
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);
}
diff --git a/src/kits/interface/Deskbar.cpp b/src/kits/interface/Deskbar.cpp
index 1964e0a8a8..6715fc945c 100644
--- a/src/kits/interface/Deskbar.cpp
+++ b/src/kits/interface/Deskbar.cpp
@@ -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
diff --git a/src/servers/mail/DeskbarView.cpp b/src/servers/mail/DeskbarView.cpp
index 36012a219a..37edb3b07f 100644
--- a/src/servers/mail/DeskbarView.cpp
+++ b/src/servers/mail/DeskbarView.cpp
@@ -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.
*
* 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
#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;
status_t ret;
- while ((ret = get_next_image_info(0, &cookie,image)) == B_OK) {
- if ((char*)our_image >= (char*)image->text_part &&
- (char*)our_image <= (char*)image->text_part + image->text_part_size)
+ while ((ret = get_next_image_info(0, &cookie, image)) == B_OK) {
+ if ((char*)our_image >= (char*)image->text_part
+ && (char*)our_image <= (char*)image->text_part
+ + image->text_part_size)
break;
}
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 -