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:
committed by
waddlesplash
parent
1ad1c1c87b
commit
efafab643c
@@ -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
|
||||
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 <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
|
||||
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>
|
||||
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>
|
||||
|
||||
<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", &viewMsg); // This puts the archived view in th
|
||||
</PRE>
|
||||
|
||||
<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>
|
||||
BMessage theMsg;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -400,6 +400,7 @@ TBarApp::MessageReceived(BMessage* message)
|
||||
case kMsgGetItemInfo:
|
||||
case kMsgHasItem:
|
||||
case kMsgCountItems:
|
||||
case kMsgMaxItemSize:
|
||||
case kMsgAddView:
|
||||
case kMsgRemoveItem:
|
||||
case kMsgAddAddOn:
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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<TBarApp*>(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<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
|
||||
// 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<TBarApp*>(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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 -
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
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 -
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user