diff --git a/src/apps/deskbar/BarApp.cpp b/src/apps/deskbar/BarApp.cpp
index 3a5716a..f0fd9a6 100644
a
|
b
|
TBarApp::SaveSettings()
|
205 | 205 | storedSettings.AddBool("sortRunningApps", fSettings.sortRunningApps); |
206 | 206 | storedSettings.AddBool("superExpando", fSettings.superExpando); |
207 | 207 | storedSettings.AddBool("expandNewTeams", fSettings.expandNewTeams); |
| 208 | storedSettings.AddInt32("iconSize", fSettings.iconSize); |
208 | 209 | storedSettings.AddBool("autoRaise", fSettings.autoRaise); |
209 | 210 | storedSettings.AddBool("recentAppsEnabled", |
210 | 211 | fSettings.recentAppsEnabled); |
… |
… |
TBarApp::InitSettings()
|
240 | 241 | settings.sortRunningApps = false; |
241 | 242 | settings.superExpando = false; |
242 | 243 | settings.expandNewTeams = false; |
| 244 | settings.iconSize = kMinimumIconSize; |
243 | 245 | settings.autoRaise = false; |
244 | 246 | settings.recentAppsEnabled = true; |
245 | 247 | settings.recentDocsEnabled = true; |
… |
… |
TBarApp::InitSettings()
|
289 | 291 | &settings.sortRunningApps); |
290 | 292 | storedSettings.FindBool("superExpando", &settings.superExpando); |
291 | 293 | storedSettings.FindBool("expandNewTeams", &settings.expandNewTeams); |
| 294 | storedSettings.FindInt32("iconSize", (int32*)&settings.iconSize); |
292 | 295 | storedSettings.FindBool("autoRaise", &settings.autoRaise); |
293 | 296 | storedSettings.FindBool("recentAppsEnabled", |
294 | 297 | &settings.recentAppsEnabled); |
… |
… |
TBarApp::MessageReceived(BMessage* message)
|
461 | 464 | fBarWindow->Unlock(); |
462 | 465 | break; |
463 | 466 | |
| 467 | case kResizeTeamIcons: |
| 468 | { |
| 469 | int32 iconSize; |
| 470 | |
| 471 | if (message->FindInt32("be:value", &iconSize) == B_OK) |
| 472 | fSettings.iconSize = iconSize * 8; |
| 473 | |
| 474 | if (fSettings.iconSize < kMinimumIconSize) |
| 475 | fSettings.iconSize = kMinimumIconSize; |
| 476 | else if (fSettings.iconSize > kMaximumIconSize) |
| 477 | fSettings.iconSize = kMaximumIconSize; |
| 478 | |
| 479 | ResizeTeamIcons(); |
| 480 | |
| 481 | fBarWindow->Lock(); |
| 482 | BarView()->UpdatePlacement(); |
| 483 | fBarWindow->Unlock(); |
| 484 | break; |
| 485 | } |
| 486 | |
464 | 487 | case 'TASK': |
465 | 488 | fSwitcherMessenger.SendMessage(message); |
466 | 489 | break; |
… |
… |
TBarApp::AddTeam(team_id team, uint32 flags, const char* sig, entry_ref* ref)
|
624 | 647 | name = ref->name; |
625 | 648 | |
626 | 649 | BarTeamInfo* barInfo = new BarTeamInfo(new BList(), flags, strdup(sig), |
627 | | new BBitmap(kIconRect, kIconFormat), strdup(name.String())); |
| 650 | new BBitmap(IconRect(), kIconFormat), strdup(ref->name)); |
| 651 | |
| 652 | if ((barInfo->flags & B_BACKGROUND_APP) == 0 |
| 653 | && strcasecmp(barInfo->sig, kDeskbarSignature) != 0) |
| 654 | FetchAppIcon(barInfo->sig, barInfo->icon); |
628 | 655 | |
629 | 656 | barInfo->teams->AddItem((void*)team); |
630 | | if (appMime.GetIcon(barInfo->icon, B_MINI_ICON) != B_OK) |
631 | | appMime.GetTrackerIcon(barInfo->icon, B_MINI_ICON); |
632 | 657 | |
633 | 658 | sBarTeamInfoList.AddItem(barInfo); |
634 | 659 | |
… |
… |
TBarApp::RemoveTeam(team_id team)
|
690 | 715 | |
691 | 716 | |
692 | 717 | void |
| 718 | TBarApp::ResizeTeamIcons() |
| 719 | { |
| 720 | for (int32 i = 0; i < sBarTeamInfoList.CountItems(); i++) { |
| 721 | BarTeamInfo* barInfo = (BarTeamInfo*)sBarTeamInfoList.ItemAt(i); |
| 722 | if ((barInfo->flags & B_BACKGROUND_APP) == 0 |
| 723 | && strcasecmp(barInfo->sig, kDeskbarSignature) != 0) { |
| 724 | barInfo->icon = new BBitmap(IconRect(), kIconFormat); |
| 725 | FetchAppIcon(barInfo->sig, barInfo->icon); |
| 726 | } |
| 727 | } |
| 728 | } |
| 729 | |
| 730 | |
| 731 | void |
693 | 732 | TBarApp::ShowPreferencesWindow() |
694 | 733 | { |
695 | 734 | if (fPreferencesWindow) |
… |
… |
TBarApp::ShowPreferencesWindow()
|
701 | 740 | } |
702 | 741 | |
703 | 742 | |
| 743 | void |
| 744 | TBarApp::FetchAppIcon(const char* signature, BBitmap* icon) |
| 745 | { |
| 746 | app_info appInfo; |
| 747 | |
| 748 | if (be_roster->GetAppInfo(signature, &appInfo) == B_OK) { |
| 749 | BFile file(&appInfo.ref, B_READ_ONLY); |
| 750 | BAppFileInfo appMime(&file); |
| 751 | icon_size size = icon->Bounds().IntegerHeight() >= 31 |
| 752 | ? B_LARGE_ICON : B_MINI_ICON; |
| 753 | |
| 754 | if (appMime.GetIcon(icon, size) != B_OK) |
| 755 | appMime.GetTrackerIcon(icon, size); |
| 756 | } |
| 757 | } |
| 758 | |
| 759 | |
| 760 | const BRect |
| 761 | TBarApp::IconRect() |
| 762 | { |
| 763 | return BRect(0, 0, fSettings.iconSize - 1, fSettings.iconSize - 1); |
| 764 | } |
| 765 | |
| 766 | |
704 | 767 | // #pragma mark - |
705 | 768 | |
706 | 769 | |
diff --git a/src/apps/deskbar/BarApp.h b/src/apps/deskbar/BarApp.h
index 6996151..4756c0b 100644
a
|
b
|
const uint32 kTrackerFirst = 'TkFt';
|
80 | 80 | const uint32 kSortRunningApps = 'SAps'; |
81 | 81 | const uint32 kSuperExpando = 'SprE'; |
82 | 82 | const uint32 kExpandNewTeams = 'ExTm'; |
| 83 | const uint32 kResizeTeamIcons = 'RTIs'; |
83 | 84 | const uint32 kAutoRaise = 'AtRs'; |
84 | 85 | const uint32 kRestartTracker = 'Trak'; |
85 | 86 | |
… |
… |
const uint32 kShutdownSystem = 301;
|
88 | 89 | const uint32 kRebootSystem = 302; |
89 | 90 | const uint32 kSuspendSystem = 304; |
90 | 91 | |
| 92 | // icon size constants |
| 93 | const int32 kMinimumIconSize = 16; |
| 94 | const int32 kMaximumIconSize = 64; |
| 95 | const int32 kIconSizeInterval = 8; |
| 96 | |
91 | 97 | /* --------------------------------------------- */ |
92 | 98 | |
93 | 99 | struct desk_settings { |
… |
… |
struct desk_settings {
|
109 | 115 | bool sortRunningApps; |
110 | 116 | bool superExpando; |
111 | 117 | bool expandNewTeams; |
| 118 | int32 iconSize; |
112 | 119 | bool autoRaise; |
113 | 120 | bool recentAppsEnabled; |
114 | 121 | bool recentDocsEnabled; |
… |
… |
class TBarApp : public BApplication {
|
126 | 133 | TBarApp(); |
127 | 134 | virtual ~TBarApp(); |
128 | 135 | |
129 | | virtual bool QuitRequested(); |
| 136 | virtual bool QuitRequested(); |
130 | 137 | virtual void MessageReceived(BMessage* message); |
131 | 138 | virtual void RefsReceived(BMessage* refs); |
132 | 139 | |
… |
… |
class TBarApp : public BApplication {
|
139 | 146 | |
140 | 147 | static void Subscribe(const BMessenger &subscriber, BList*); |
141 | 148 | static void Unsubscribe(const BMessenger &subscriber); |
| 149 | void ResizeTeamIcons(); |
142 | 150 | |
143 | 151 | private: |
144 | 152 | void AddTeam(team_id team, uint32 flags, const char* sig, entry_ref*); |
… |
… |
class TBarApp : public BApplication {
|
148 | 156 | void SaveSettings(); |
149 | 157 | |
150 | 158 | void ShowPreferencesWindow(); |
| 159 | void FetchAppIcon(const char* signature, BBitmap* icon); |
| 160 | const BRect IconRect(); |
151 | 161 | |
152 | 162 | TBarWindow* fBarWindow; |
153 | 163 | BMessenger fSwitcherMessenger; |
diff --git a/src/apps/deskbar/BarView.cpp b/src/apps/deskbar/BarView.cpp
index cac3472..980e76e 100644
a
|
b
|
TBarView::PlaceBeMenu()
|
224 | 224 | return; |
225 | 225 | |
226 | 226 | float width = sMinimumWindowWidth; |
| 227 | desk_settings* settings = ((TBarApp*)be_app)->Settings(); |
227 | 228 | BPoint loc(B_ORIGIN); |
228 | 229 | BRect menuFrame(fBarMenuBar->Frame()); |
229 | 230 | if (fState == kFullState) { |
230 | 231 | fBarMenuBar->RemoveTeamMenu(); |
| 232 | // TODO: Magic constants need explination |
231 | 233 | width = 8 + 16 + 8; |
232 | 234 | loc = Bounds().LeftTop(); |
233 | 235 | } else if (fState == kExpandoState) { |
234 | 236 | // shows apps below tray |
235 | 237 | fBarMenuBar->RemoveTeamMenu(); |
236 | | if (fVertical) |
| 238 | if (fVertical) { |
237 | 239 | width += 1; |
238 | | else |
| 240 | width += settings->iconSize - kMinimumIconSize; |
| 241 | } else |
239 | 242 | width = floorf(width) / 2; |
240 | 243 | loc = Bounds().LeftTop(); |
241 | 244 | } else { |
… |
… |
TBarView::PlaceApplicationBar(BRect screenFrame)
|
300 | 303 | if (fState == kMiniState) |
301 | 304 | return; |
302 | 305 | |
| 306 | desk_settings* settings = ((TBarApp*)be_app)->Settings(); |
303 | 307 | BRect expandoFrame(0, 0, 0, 0); |
304 | 308 | if (fVertical) { |
305 | 309 | // top left/right |
… |
… |
TBarView::PlaceApplicationBar(BRect screenFrame)
|
311 | 315 | expandoFrame.bottom = expandoFrame.top + 1; |
312 | 316 | if (fState == kFullState) |
313 | 317 | expandoFrame.right = fBarMenuBar->Frame().Width(); |
314 | | else |
315 | | expandoFrame.right = sMinimumWindowWidth; |
| 318 | else { |
| 319 | expandoFrame.right = sMinimumWindowWidth + settings->iconSize |
| 320 | - kMinimumIconSize; |
| 321 | } |
316 | 322 | } else { |
317 | 323 | // top or bottom |
318 | 324 | expandoFrame.top = 0; |
319 | | expandoFrame.bottom = kHModeHeight; |
| 325 | expandoFrame.bottom = settings->iconSize + 4; |
320 | 326 | if (fTrayLocation != 0) |
321 | 327 | expandoFrame.right = fDragRegion->Frame().left - 1; |
322 | 328 | else |
… |
… |
TBarView::GetPreferredWindowSize(BRect screenFrame, float* width, float* height)
|
338 | 344 | windowHeight = screenFrame.bottom; |
339 | 345 | windowWidth = fBarMenuBar->Frame().Width(); |
340 | 346 | } else if (fState == kExpandoState) { |
| 347 | desk_settings* settings = ((TBarApp*)be_app)->Settings(); |
341 | 348 | if (fVertical) { |
342 | 349 | // top left or right |
343 | 350 | windowHeight = fExpando->Frame().bottom; |
| 351 | windowWidth += settings->iconSize - kMinimumIconSize; |
344 | 352 | } else { |
345 | 353 | // top or bottom, full |
346 | 354 | fExpando->CheckItemSizes(0); |
347 | | windowHeight = kHModeHeight; |
| 355 | windowHeight = settings->iconSize + 4; |
348 | 356 | windowWidth = screenFrame.Width(); |
349 | 357 | } |
350 | 358 | } else { |
… |
… |
BRect
|
942 | 950 | TBarView::OffsetIconFrame(BRect rect) const |
943 | 951 | { |
944 | 952 | BRect frame(Frame()); |
| 953 | desk_settings* settings = ((TBarApp*)be_app)->Settings(); |
| 954 | |
945 | 955 | frame.left += fDragRegion->Frame().left + fReplicantTray->Frame().left |
946 | | + rect.left; |
| 956 | + rect.left + settings->iconSize - kMinimumIconSize; |
947 | 957 | frame.top += fDragRegion->Frame().top + fReplicantTray->Frame().top |
948 | 958 | + rect.top; |
949 | 959 | |
diff --git a/src/apps/deskbar/BarView.h b/src/apps/deskbar/BarView.h
index 8f4e5b8..8a60bb5 100644
a
|
b
|
class TBarView : public BView {
|
136 | 136 | TExpandoMenuBar* ExpandoMenuBar() const; |
137 | 137 | TBarMenuBar* BarMenuBar() const; |
138 | 138 | TDragRegion* DragRegion() const { return fDragRegion; } |
| 139 | TReplicantTray* ReplicantTray() const { return fReplicantTray; } |
139 | 140 | |
140 | 141 | private: |
141 | 142 | friend class TBeMenu; |
diff --git a/src/apps/deskbar/ExpandoMenuBar.cpp b/src/apps/deskbar/ExpandoMenuBar.cpp
index 739f076..adbdaf3 100644
a
|
b
|
All rights reserved.
|
61 | 61 | |
62 | 62 | const float kDefaultBeMenuWidth = 50.0f; |
63 | 63 | const float kSepItemWidth = 5.0f; |
| 64 | const float kIconPadding = 8.0f; |
64 | 65 | |
65 | 66 | const uint32 kMinimizeTeam = 'mntm'; |
66 | 67 | const uint32 kBringTeamToFront = 'bftm'; |
… |
… |
TExpandoMenuBar::TExpandoMenuBar(TBarView* bar, BRect frame, const char* name,
|
90 | 91 | { |
91 | 92 | SetItemMargins(0.0f, 0.0f, 0.0f, 0.0f); |
92 | 93 | SetFont(be_plain_font); |
93 | | SetMaxContentWidth(sMinimumWindowWidth); |
94 | 94 | } |
95 | 95 | |
96 | 96 | |
… |
… |
TExpandoMenuBar::AttachedToWindow()
|
134 | 134 | |
135 | 135 | desk_settings* settings = ((TBarApp*)be_app)->Settings(); |
136 | 136 | |
| 137 | // Add in the width of the icon |
| 138 | width += settings->iconSize - kMinimumIconSize; |
| 139 | |
137 | 140 | if (settings->sortRunningApps) |
138 | 141 | teamList.SortItems(CompareByName); |
139 | 142 | |
… |
… |
void
|
499 | 502 | TExpandoMenuBar::AddTeam(BList* team, BBitmap* icon, char* name, |
500 | 503 | char* signature) |
501 | 504 | { |
| 505 | desk_settings* settings = ((TBarApp*)be_app)->Settings(); |
502 | 506 | float itemWidth = fVertical ? fBarView->Bounds().Width() |
503 | | : sMinimumWindowWidth; |
| 507 | : sMinimumWindowWidth + settings->iconSize - kMinimumIconSize; |
504 | 508 | float itemHeight = -1.0f; |
505 | 509 | |
506 | | desk_settings* settings = ((TBarApp*)be_app)->Settings(); |
507 | 510 | TTeamMenuItem* item = new TTeamMenuItem(team, icon, name, signature, |
508 | 511 | itemWidth, itemHeight, fDrawLabel, fVertical); |
509 | 512 | |
… |
… |
TExpandoMenuBar::RemoveTeam(team_id team, bool partial)
|
606 | 609 | void |
607 | 610 | TExpandoMenuBar::CheckItemSizes(int32 delta) |
608 | 611 | { |
609 | | float width = Frame().Width(); |
610 | | int32 count = CountItems(); |
| 612 | if (fBarView->Vertical()) |
| 613 | return; |
| 614 | |
| 615 | float iconSize = ((TBarApp*)be_app)->Settings()->iconSize; |
| 616 | float maxContentWidth = sMinimumWindowWidth + iconSize - |
| 617 | kMinimumIconSize; |
| 618 | |
| 619 | // There are 2 extra items: |
| 620 | // The Be Menu |
| 621 | // The little separator item |
| 622 | int32 count = CountItems() - 2; |
| 623 | float width = Frame().Width() - fBeMenuWidth - kSepItemWidth * 2; |
| 624 | float fullWidth = maxContentWidth * count + fBeMenuWidth + kSepItemWidth; |
| 625 | |
611 | 626 | bool reset = false; |
612 | | float newWidth = 0; |
613 | | float fullWidth = (sMinimumWindowWidth * count); |
614 | | |
615 | | if (!fBarView->Vertical()) { |
616 | | // in this case there are 2 extra items: |
617 | | // - The Be Menu |
618 | | // - The little separator item |
619 | | fullWidth = fullWidth - (sMinimumWindowWidth * 2) |
620 | | + (fBeMenuWidth + kSepItemWidth); |
621 | | width -= (fBeMenuWidth + kSepItemWidth); |
622 | | count -= 2; |
623 | | } |
| 627 | float newWidth = 0.0f; |
624 | 628 | |
625 | 629 | if (delta >= 0 && fullWidth > width) { |
626 | 630 | fOverflow = true; |
627 | 631 | reset = true; |
628 | | newWidth = floorf(width / count); |
| 632 | //newWidth = floorf(width / count); |
| 633 | newWidth = kIconPadding + iconSize + kIconPadding; |
629 | 634 | } else if (delta < 0 && fOverflow) { |
630 | 635 | reset = true; |
631 | 636 | if (fullWidth > width) |
632 | | newWidth = floorf(width / count); |
| 637 | newWidth = kIconPadding + iconSize + kIconPadding; |
633 | 638 | else |
634 | | newWidth = sMinimumWindowWidth; |
| 639 | newWidth = maxContentWidth; |
635 | 640 | } |
636 | | if (newWidth > sMinimumWindowWidth) |
637 | | newWidth = sMinimumWindowWidth; |
| 641 | |
| 642 | if (newWidth > maxContentWidth) |
| 643 | newWidth = maxContentWidth; |
638 | 644 | |
639 | 645 | if (reset) { |
640 | 646 | SetMaxContentWidth(newWidth); |
641 | | if (newWidth == sMinimumWindowWidth) |
| 647 | if (newWidth == maxContentWidth) |
642 | 648 | fOverflow = false; |
643 | 649 | InvalidateLayout(); |
644 | 650 | |
… |
… |
TExpandoMenuBar::CheckItemSizes(int32 delta)
|
647 | 653 | if (!item) |
648 | 654 | break; |
649 | 655 | item->SetOverrideWidth(newWidth); |
| 656 | item->SetDrawLabel(!fOverflow); |
650 | 657 | } |
651 | 658 | |
652 | 659 | Invalidate(); |
diff --git a/src/apps/deskbar/PreferencesWindow.cpp b/src/apps/deskbar/PreferencesWindow.cpp
index bb378f1..59d369f 100644
a
|
b
|
|
17 | 17 | #include <OpenWithTracker.h> |
18 | 18 | #include <RadioButton.h> |
19 | 19 | #include <SeparatorView.h> |
| 20 | #include <Slider.h> |
20 | 21 | |
21 | 22 | #include <ctype.h> |
22 | 23 | |
… |
… |
PreferencesWindow::PreferencesWindow(BRect frame)
|
55 | 56 | new BMessage(kSuperExpando)); |
56 | 57 | fAppsExpandNew = new BCheckBox(B_TRANSLATE("Expand new applications"), |
57 | 58 | new BMessage(kExpandNewTeams)); |
| 59 | fAppsIconSizeSlider = new BSlider("icon_size", B_TRANSLATE("Icon size"), |
| 60 | NULL, kMinimumIconSize / kIconSizeInterval, |
| 61 | kMaximumIconSize / kIconSizeInterval, B_HORIZONTAL); |
| 62 | fAppsIconSizeSlider->SetHashMarks(B_HASH_MARKS_BOTTOM); |
| 63 | fAppsIconSizeSlider->SetHashMarkCount(((kMaximumIconSize - kMinimumIconSize) |
| 64 | / kIconSizeInterval) + 1); |
| 65 | fAppsIconSizeSlider->SetLimitLabels(B_TRANSLATE("Small"), |
| 66 | B_TRANSLATE("Large")); |
| 67 | fAppsIconSizeSlider->SetModificationMessage(new BMessage(kResizeTeamIcons)); |
58 | 68 | |
59 | 69 | fClockSeconds = new BCheckBox(B_TRANSLATE("Show seconds"), |
60 | 70 | new BMessage(kShowSeconds)); |
… |
… |
PreferencesWindow::PreferencesWindow(BRect frame)
|
87 | 97 | fAppsSortTrackerFirst->SetValue(appSettings->trackerAlwaysFirst); |
88 | 98 | fAppsShowExpanders->SetValue(appSettings->superExpando); |
89 | 99 | fAppsExpandNew->SetValue(appSettings->expandNewTeams); |
| 100 | fAppsIconSizeSlider->SetValue(appSettings->iconSize / 8); |
90 | 101 | |
91 | 102 | int32 docCount = appSettings->recentDocsCount; |
92 | 103 | int32 appCount = appSettings->recentAppsCount; |
… |
… |
PreferencesWindow::PreferencesWindow(BRect frame)
|
129 | 140 | fAppsSort->SetTarget(be_app); |
130 | 141 | fAppsSortTrackerFirst->SetTarget(be_app); |
131 | 142 | fAppsExpandNew->SetTarget(be_app); |
| 143 | fAppsIconSizeSlider->SetTarget(be_app); |
132 | 144 | |
133 | 145 | fClockSeconds->SetTarget(replicantTray); |
134 | 146 | |
… |
… |
PreferencesWindow::PreferencesWindow(BRect frame)
|
177 | 189 | .SetInsets(20, 0, 0, 0) |
178 | 190 | .Add(fAppsExpandNew) |
179 | 191 | .End() |
| 192 | .Add(fAppsIconSizeSlider) |
180 | 193 | .AddGlue() |
181 | 194 | .SetInsets(10, 10, 10, 10) |
182 | 195 | .End() |
diff --git a/src/apps/deskbar/PreferencesWindow.h b/src/apps/deskbar/PreferencesWindow.h
index a45005c..92d6450 100644
a
|
b
|
|
10 | 10 | #include <Button.h> |
11 | 11 | #include <CheckBox.h> |
12 | 12 | #include <RadioButton.h> |
| 13 | #include <Slider.h> |
13 | 14 | #include <StringView.h> |
14 | 15 | #include <TextControl.h> |
15 | 16 | #include <Window.h> |
… |
… |
private:
|
52 | 53 | BCheckBox* fAppsSortTrackerFirst; |
53 | 54 | BCheckBox* fAppsShowExpanders; |
54 | 55 | BCheckBox* fAppsExpandNew; |
| 56 | BSlider* fAppsIconSizeSlider; |
55 | 57 | |
56 | 58 | BCheckBox* fClockSeconds; |
57 | 59 | |
diff --git a/src/apps/deskbar/StatusView.cpp b/src/apps/deskbar/StatusView.cpp
index 620e84a..fe1b502 100644
a
|
b
|
DumpList(BList* itemlist)
|
110 | 110 | printf("no items in list\n"); |
111 | 111 | return; |
112 | 112 | } |
113 | | for (int32 i = count ; i >= 0 ; i--) { |
| 113 | for (int32 i = count; i >= 0; i--) { |
114 | 114 | DeskbarItemInfo* item = (DeskbarItemInfo*)itemlist->ItemAt(i); |
115 | 115 | if (!item) |
116 | 116 | continue; |
… |
… |
TReplicantTray::TReplicantTray(TBarView* parent, bool vertical)
|
137 | 137 | fAlignmentSupport(false) |
138 | 138 | { |
139 | 139 | // init the minimum window width according to the logo. |
| 140 | desk_settings* settings = ((TBarApp*)be_app)->Settings(); |
140 | 141 | const BBitmap* logoBitmap = AppResSet()->FindBitmap(B_MESSAGE_TYPE, |
141 | 142 | R_LeafLogoBitmap); |
142 | 143 | if (logoBitmap != NULL) { |
143 | 144 | sMinimumWindowWidth = max_c(sMinimumWindowWidth, |
144 | | 2 * (logoBitmap->Bounds().Width() + 8)); |
| 145 | 2 * (logoBitmap->Bounds().Width() + 8) + settings->iconSize |
| 146 | - kMinimumIconSize); |
145 | 147 | fMinimumTrayWidth = sMinimumWindowWidth - kGutter - kDragRegionWidth; |
146 | 148 | } |
147 | 149 | } |
… |
… |
TReplicantTray::DetachedFromWindow()
|
196 | 198 | void |
197 | 199 | TReplicantTray::RememberClockSettings() |
198 | 200 | { |
199 | | if (fClock) { |
| 201 | if (fClock) { |
200 | 202 | desk_settings* settings = ((TBarApp*)be_app)->Settings(); |
201 | 203 | |
202 | 204 | settings->timeShowSeconds = fClock->ShowingSeconds(); |
… |
… |
TReplicantTray::DealWithClock(bool showClock)
|
243 | 245 | |
244 | 246 | /*! Width is set to a minimum of kMinimumReplicantCount by kMaxReplicantWidth |
245 | 247 | if not in multirowmode and greater than kMinimumReplicantCount |
246 | | the width should be calculated based on the actual |
247 | | replicant widths |
| 248 | the width should be calculated based on the actual replicant widths |
248 | 249 | */ |
249 | 250 | void |
250 | 251 | TReplicantTray::GetPreferredSize(float* preferredWidth, float* preferredHeight) |
251 | 252 | { |
252 | 253 | float width = 0, height = kMinimumTrayHeight; |
| 254 | desk_settings* settings = ((TBarApp*)be_app)->Settings(); |
253 | 255 | |
254 | 256 | if (fMultiRowMode) { |
255 | 257 | if (fShelf->CountReplicants() > 0) |
… |
… |
TReplicantTray::GetPreferredSize(float* preferredWidth, float* preferredHeight)
|
261 | 263 | height = kGutter + (rowCount * kMaxReplicantHeight) |
262 | 264 | + ((rowCount - 1) * kIconGap) + kGutter; |
263 | 265 | height = max(kMinimumTrayHeight, height); |
264 | | width = fMinimumTrayWidth; |
| 266 | |
| 267 | if (fBarView->Expando()) |
| 268 | width = fMinimumTrayWidth + settings->iconSize - kMinimumIconSize; |
| 269 | else |
| 270 | width = fMinimumTrayWidth; |
265 | 271 | } else { |
266 | 272 | // if last replicant overruns clock then resize to accomodate |
267 | 273 | if (fShelf->CountReplicants() > 0) { |
268 | | if (fBarView->ShowingClock() |
269 | | && fRightBottomReplicant.right + 6 >= fClock->Frame().left) { |
| 274 | if (fBarView->ShowingClock() && fRightBottomReplicant.right + 6 |
| 275 | >= fClock->Frame().left) { |
270 | 276 | width = fRightBottomReplicant.right + 6 |
271 | 277 | + fClock->Frame().Width(); |
272 | 278 | } else |
… |
… |
TReplicantTray::GetPreferredSize(float* preferredWidth, float* preferredHeight)
|
275 | 281 | |
276 | 282 | // this view has a fixed minimum width |
277 | 283 | width = max(fMinimumTrayWidth, width); |
| 284 | height = kGutter + settings->iconSize + kGutter; |
278 | 285 | } |
279 | 286 | |
280 | 287 | *preferredWidth = width; |
… |
… |
TReplicantTray::AcceptAddon(BRect replicantFrame, BMessage* message)
|
1229 | 1236 | BPoint |
1230 | 1237 | TReplicantTray::LocationForReplicant(int32 index, float width) |
1231 | 1238 | { |
| 1239 | desk_settings* settings = ((TBarApp*)be_app)->Settings(); |
1232 | 1240 | BPoint loc(kIconGap + 1, kGutter + 1); |
1233 | 1241 | |
1234 | 1242 | if (fMultiRowMode) { |
1235 | 1243 | // try to find free space in every row |
1236 | 1244 | for (int32 row = 0; ; loc.y += kMaxReplicantHeight + kIconGap, row++) { |
1237 | 1245 | // determine free space in this row |
1238 | | BRect rect(loc.x, loc.y, loc.x + fMinimumTrayWidth - kIconGap - 2.0, |
| 1246 | BRect rect(loc.x, loc.y, loc.x + fMinimumTrayWidth |
| 1247 | + settings->iconSize - kMinimumIconSize - kIconGap - 2.0, |
1239 | 1248 | loc.y + kMaxReplicantHeight); |
1240 | 1249 | if (row == 0 && fBarView->ShowingClock()) |
1241 | 1250 | rect.right -= fClock->Frame().Width() + kIconGap; |
diff --git a/src/apps/deskbar/StatusView.h b/src/apps/deskbar/StatusView.h
index 31fb82f..9989e41 100644
a
|
b
|
All rights reserved.
|
48 | 48 | const float kMaxReplicantHeight = 16.0f; |
49 | 49 | const float kMaxReplicantWidth = 16.0f; |
50 | 50 | const int32 kMinimumReplicantCount = 6; |
51 | | const int32 kIconGap = 2; |
| 51 | const int32 kIconGap = 2; |
52 | 52 | const int32 kGutter = 1; |
53 | 53 | const int32 kDragRegionWidth = 6; |
54 | 54 | |
55 | | // 1 pixel left gutter |
| 55 | // 1 pixel for left gutter |
56 | 56 | // space for replicant tray (6 items) |
57 | 57 | // 6 pixel drag region |
58 | | const float kMinimumTrayWidth = kIconGap + (kMinimumReplicantCount * kIconGap) |
59 | | + (kMinimumReplicantCount * kMaxReplicantWidth) + kGutter; |
| 58 | const float kMinimumTrayWidth = kIconGap |
| 59 | + (kMinimumReplicantCount * kIconGap) |
| 60 | + (kMinimumReplicantCount * kMaxReplicantWidth) + kGutter; |
60 | 61 | const float kMinimumTrayHeight = kGutter + kMaxReplicantHeight + kGutter; |
61 | 62 | |
62 | 63 | extern float sMinimumWindowWidth; |
diff --git a/src/apps/deskbar/TeamMenu.cpp b/src/apps/deskbar/TeamMenu.cpp
index 3053969..ade9dcb 100644
a
|
b
|
TTeamMenu::AttachedToWindow()
|
85 | 85 | if (((barInfo->flags & B_BACKGROUND_APP) == 0) |
86 | 86 | && (strcasecmp(barInfo->sig, kDeskbarSignature) != 0)) { |
87 | 87 | TTeamMenuItem* item = new TTeamMenuItem(barInfo->teams, |
88 | | barInfo->icon, barInfo->name, barInfo->sig, -1, -1, true, true); |
| 88 | barInfo->icon, barInfo->name, barInfo->sig, -1, -1, true, |
| 89 | true); |
89 | 90 | |
90 | 91 | if ((settings->trackerAlwaysFirst) |
91 | 92 | && (strcmp(barInfo->sig, kTrackerSignature) == 0)) |
diff --git a/src/apps/deskbar/TeamMenuItem.cpp b/src/apps/deskbar/TeamMenuItem.cpp
index a3f3619..727eb27 100644
a
|
b
|
status_t
|
127 | 127 | TTeamMenuItem::Invoke(BMessage* message) |
128 | 128 | { |
129 | 129 | if ((static_cast<TBarApp*>(be_app))->BarView()->InvokeItem(Signature())) |
130 | | // handles drop on application |
| 130 | // handles drop on application |
131 | 131 | return B_OK; |
132 | 132 | |
133 | | // if the app could not handle the drag message |
134 | | // and we were dragging, then kill the drag |
135 | | // should never get here, disabled item will not invoke |
| 133 | // if the app could not handle the drag message |
| 134 | // and we were dragging, then kill the drag |
| 135 | // should never get here, disabled item will not invoke |
136 | 136 | TBarView* barview = (static_cast<TBarApp*>(be_app))->BarView(); |
137 | 137 | if (barview && barview->Dragging()) |
138 | 138 | barview->DragStop(); |
… |
… |
TTeamMenuItem::Invoke(BMessage* message)
|
141 | 141 | uint32 mods = modifiers(); |
142 | 142 | if (mods & B_CONTROL_KEY) { |
143 | 143 | TShowHideMenuItem::TeamShowHideCommon((mods & B_SHIFT_KEY) |
144 | | ? B_MINIMIZE_WINDOW : B_BRING_TO_FRONT, Teams()); |
| 144 | ? B_MINIMIZE_WINDOW : B_BRING_TO_FRONT, Teams()); |
145 | 145 | } |
146 | 146 | |
147 | 147 | return BMenuItem::Invoke(message); |
… |
… |
TTeamMenuItem::SetOverrideSelected(bool selected)
|
170 | 170 | } |
171 | 171 | |
172 | 172 | |
| 173 | void |
| 174 | TTeamMenuItem::SetDrawLabel(bool drawLabel) |
| 175 | { |
| 176 | fDrawLabel = drawLabel; |
| 177 | } |
| 178 | |
| 179 | |
173 | 180 | float |
174 | 181 | TTeamMenuItem::LabelWidth() const |
175 | 182 | { |
… |
… |
TTeamMenuItem::GetContentSize(float* width, float* height)
|
206 | 213 | if (fIcon) |
207 | 214 | iconBounds = fIcon->Bounds(); |
208 | 215 | else |
209 | | iconBounds = BRect(0, 0, 15, 15); |
| 216 | iconBounds = BRect(0, 0, kMinimumIconSize - 1, kMinimumIconSize - 1); |
210 | 217 | |
211 | 218 | BMenuItem::GetContentSize(width, height); |
212 | 219 | |
213 | 220 | if (fOverrideWidth != -1.0f) |
214 | 221 | *width = fOverrideWidth; |
215 | | else |
216 | | *width = kHPad + iconBounds.Width() + kLabelOffset + fLabelWidth + kHPad |
217 | | + 20; |
| 222 | else { |
| 223 | *width = kHPad + iconBounds.Width() + kLabelOffset; |
| 224 | if (fDrawLabel) |
| 225 | *width += LabelWidth() + kHPad + 10.0f; |
| 226 | } |
218 | 227 | |
219 | 228 | if (fOverrideHeight != -1.0f) |
220 | 229 | *height = fOverrideHeight; |
221 | 230 | else { |
222 | 231 | *height = iconBounds.Height(); |
223 | | float labelHeight = fLabelAscent + fLabelDescent; |
224 | | if (labelHeight > *height) |
225 | | *height = labelHeight; |
| 232 | if (fDrawLabel) { |
| 233 | float labelHeight = fLabelAscent + fLabelDescent; |
| 234 | if (labelHeight > *height) |
| 235 | *height = labelHeight; |
| 236 | } |
226 | 237 | *height += (kVPad * 2) + 2; |
227 | 238 | } |
228 | 239 | *height += 2; |
diff --git a/src/apps/deskbar/TeamMenuItem.h b/src/apps/deskbar/TeamMenuItem.h
index 9bfd28b..851d029 100644
a
|
b
|
class TTeamMenuItem : public BMenuItem {
|
62 | 62 | void SetOverrideWidth(float width); |
63 | 63 | void SetOverrideHeight(float height); |
64 | 64 | void SetOverrideSelected(bool selected); |
| 65 | void SetDrawLabel(bool drawLabel); |
65 | 66 | |
66 | 67 | bool IsExpanded(); |
67 | 68 | void ToggleExpandState(bool resizeWindow); |
diff --git a/src/apps/deskbar/TimeView.cpp b/src/apps/deskbar/TimeView.cpp
index 96a7936..f6d50bb 100644
a
|
b
|
TTimeView::Pulse()
|
332 | 332 | Update(); |
333 | 333 | |
334 | 334 | strlcpy(fLastTimeStr, fTimeStr, sizeof(fLastTimeStr)); |
335 | | strlcpy(fLastDateStr, fDateStr, sizeof(fLastDateStr)); |
336 | 335 | fNeedToUpdate = true; |
337 | 336 | } |
338 | 337 | |
| 338 | // Update the tooltip if the date has changed |
| 339 | if (strcmp(fDateStr, fLastDateStr) != 0) { |
| 340 | strlcpy(fLastDateStr, fDateStr, sizeof(fLastDateStr)); |
| 341 | SetToolTip(fDateStr); |
| 342 | } |
| 343 | |
339 | 344 | if (fNeedToUpdate) { |
340 | 345 | fSeconds = ct->tm_sec; |
341 | 346 | fMinute = ct->tm_min; |