ToolBarView: rename to BToolbar and move to libshared.

Also adjust ShowImage for this, it's the only thing that's using ToolBarView
right now.

Signed-off-by: Jessica Hamilton <[email protected]>
This commit is contained in:
Augustin Cavalier
2014-11-04 12:45:47 +13:00
committed by Jessica Hamilton
parent 361f5a857f
commit 6d93638b37
6 changed files with 64 additions and 64 deletions
@@ -2,8 +2,8 @@
* Copyright 2011 Stephan Aßmus <superstippi@gmx.de> * Copyright 2011 Stephan Aßmus <superstippi@gmx.de>
* All rights reserved. Distributed under the terms of the MIT license. * All rights reserved. Distributed under the terms of the MIT license.
*/ */
#ifndef TOOL_BAR_VIEW_H #ifndef _TOOLBAR_H
#define TOOL_BAR_VIEW_H #define _TOOLBAR_H
#include <GroupView.h> #include <GroupView.h>
@@ -11,10 +11,10 @@
class BButton; class BButton;
class ToolBarView : public BGroupView { class BToolbar : public BGroupView {
public: public:
ToolBarView(BRect frame); BToolbar(BRect frame);
virtual ~ToolBarView(); virtual ~BToolbar();
virtual void Hide(); virtual void Hide();
@@ -42,4 +42,4 @@ private:
void _HideToolTips() const; void _HideToolTips() const;
}; };
#endif // TOOL_BAR_VIEW_H #endif // _TOOLBAR_H
-1
View File
@@ -20,7 +20,6 @@ Application ShowImage :
ShowImageView.cpp ShowImageView.cpp
ShowImageWindow.cpp ShowImageWindow.cpp
ToolBarIcons.cpp ToolBarIcons.cpp
ToolBarView.cpp
: libshared.a be tracker translation localestub : libshared.a be tracker translation localestub
[ TargetLibstdc++ ] [ TargetLibsupc++ ] [ TargetLibstdc++ ] [ TargetLibsupc++ ]
: ShowImage.rdef : ShowImage.rdef
+39 -39
View File
@@ -44,6 +44,7 @@
#include <ScrollView.h> #include <ScrollView.h>
#include <String.h> #include <String.h>
#include <SupportDefs.h> #include <SupportDefs.h>
#include <Toolbar.h>
#include <TranslationDefs.h> #include <TranslationDefs.h>
#include <TranslationUtils.h> #include <TranslationUtils.h>
#include <TranslatorRoster.h> #include <TranslatorRoster.h>
@@ -55,7 +56,6 @@
#include "ShowImageStatusView.h" #include "ShowImageStatusView.h"
#include "ShowImageView.h" #include "ShowImageView.h"
#include "ToolBarIcons.h" #include "ToolBarIcons.h"
#include "ToolBarView.h"
// BMessage field names used in Save messages // BMessage field names used in Save messages
@@ -137,7 +137,7 @@ ShowImageWindow::ShowImageWindow(BRect frame, const entry_ref& ref,
fBrowseMenu(NULL), fBrowseMenu(NULL),
fGoToPageMenu(NULL), fGoToPageMenu(NULL),
fSlideShowDelayMenu(NULL), fSlideShowDelayMenu(NULL),
fToolBarView(NULL), fToolbar(NULL),
fImageView(NULL), fImageView(NULL),
fStatusView(NULL), fStatusView(NULL),
fProgressWindow(new ProgressWindow()), fProgressWindow(new ProgressWindow()),
@@ -170,48 +170,48 @@ ShowImageWindow::ShowImageWindow(BRect frame, const entry_ref& ref,
// Create the tool bar // Create the tool bar
BRect viewFrame = contentView->Bounds(); BRect viewFrame = contentView->Bounds();
viewFrame.right -= B_V_SCROLL_BAR_WIDTH; viewFrame.right -= B_V_SCROLL_BAR_WIDTH;
fToolBarView = new ToolBarView(viewFrame); fToolbar = new BToolbar(viewFrame);
// Add the tool icons. // Add the tool icons.
// fToolBarView->AddAction(MSG_FILE_OPEN, be_app, // fToolbar->AddAction(MSG_FILE_OPEN, be_app,
// tool_bar_icon(kIconDocumentOpen), B_TRANSLATE("Open" B_UTF8_ELLIPSIS)); // tool_bar_icon(kIconDocumentOpen), B_TRANSLATE("Open" B_UTF8_ELLIPSIS));
fToolBarView->AddAction(MSG_FILE_PREV, this, fToolbar->AddAction(MSG_FILE_PREV, this,
tool_bar_icon(kIconGoPrevious), B_TRANSLATE("Previous file"), false); tool_bar_icon(kIconGoPrevious), B_TRANSLATE("Previous file"), false);
fToolBarView->AddAction(MSG_FILE_NEXT, this, tool_bar_icon(kIconGoNext), fToolbar->AddAction(MSG_FILE_NEXT, this, tool_bar_icon(kIconGoNext),
B_TRANSLATE("Next file"), false); B_TRANSLATE("Next file"), false);
BMessage* fullScreenSlideShow = new BMessage(MSG_SLIDE_SHOW); BMessage* fullScreenSlideShow = new BMessage(MSG_SLIDE_SHOW);
fullScreenSlideShow->AddBool("full screen", true); fullScreenSlideShow->AddBool("full screen", true);
fToolBarView->AddAction(fullScreenSlideShow, this, fToolbar->AddAction(fullScreenSlideShow, this,
tool_bar_icon(kIconMediaMovieLibrary), B_TRANSLATE("Slide show"), tool_bar_icon(kIconMediaMovieLibrary), B_TRANSLATE("Slide show"),
false); false);
fToolBarView->AddSeparator(); fToolbar->AddSeparator();
fToolBarView->AddAction(MSG_SELECTION_MODE, this, fToolbar->AddAction(MSG_SELECTION_MODE, this,
tool_bar_icon(kIconDrawRectangularSelection), tool_bar_icon(kIconDrawRectangularSelection),
B_TRANSLATE("Selection mode"), false); B_TRANSLATE("Selection mode"), false);
fToolBarView->AddSeparator(); fToolbar->AddSeparator();
fToolBarView->AddAction(kMsgOriginalSize, this, fToolbar->AddAction(kMsgOriginalSize, this,
tool_bar_icon(kIconZoomOriginal), B_TRANSLATE("Original size"), true); tool_bar_icon(kIconZoomOriginal), B_TRANSLATE("Original size"), true);
fToolBarView->AddAction(kMsgFitToWindow, this, fToolbar->AddAction(kMsgFitToWindow, this,
tool_bar_icon(kIconZoomFitBest), B_TRANSLATE("Fit to window"), false); tool_bar_icon(kIconZoomFitBest), B_TRANSLATE("Fit to window"), false);
fToolBarView->AddAction(MSG_ZOOM_IN, this, tool_bar_icon(kIconZoomIn), fToolbar->AddAction(MSG_ZOOM_IN, this, tool_bar_icon(kIconZoomIn),
B_TRANSLATE("Zoom in"), false); B_TRANSLATE("Zoom in"), false);
fToolBarView->AddAction(MSG_ZOOM_OUT, this, tool_bar_icon(kIconZoomOut), fToolbar->AddAction(MSG_ZOOM_OUT, this, tool_bar_icon(kIconZoomOut),
B_TRANSLATE("Zoom out"), false); B_TRANSLATE("Zoom out"), false);
fToolBarView->AddGlue(); fToolbar->AddGlue();
fToolBarView->AddAction(MSG_FULL_SCREEN, this, fToolbar->AddAction(MSG_FULL_SCREEN, this,
tool_bar_icon(kIconViewWindowed), B_TRANSLATE("Leave full screen"), tool_bar_icon(kIconViewWindowed), B_TRANSLATE("Leave full screen"),
false); false);
fToolBarView->SetActionVisible(MSG_FULL_SCREEN, false); fToolbar->SetActionVisible(MSG_FULL_SCREEN, false);
fToolBarView->ResizeTo(viewFrame.Width(), fToolBarView->MinSize().height); fToolbar->ResizeTo(viewFrame.Width(), fToolbar->MinSize().height);
contentView->AddChild(fToolBarView); contentView->AddChild(fToolbar);
if (fShowToolBar) if (fShowToolBar)
viewFrame.top = fToolBarView->Frame().bottom + 1; viewFrame.top = fToolbar->Frame().bottom + 1;
else else
fToolBarView->Hide(); fToolbar->Hide();
fToolBarVisible = fShowToolBar; fToolBarVisible = fShowToolBar;
@@ -255,7 +255,7 @@ ShowImageWindow::ShowImageWindow(BRect frame, const entry_ref& ref,
contentView->AddChild(fVerticalScrollBar); contentView->AddChild(fVerticalScrollBar);
// Update minimum window size // Update minimum window size
float toolBarMinWidth = fToolBarView->MinSize().width; float toolBarMinWidth = fToolbar->MinSize().width;
SetSizeLimits(std::max(menuBarMinWidth, toolBarMinWidth), 100000, 100, SetSizeLimits(std::max(menuBarMinWidth, toolBarMinWidth), 100000, 100,
100000); 100000);
@@ -362,7 +362,7 @@ ShowImageWindow::_BuildViewMenu(BMenu* menu, bool popupMenu)
_AddItemMenu(menu, B_TRANSLATE("Show tool bar"), kMsgToggleToolBar, _AddItemMenu(menu, B_TRANSLATE("Show tool bar"), kMsgToggleToolBar,
'B', 0, this); 'B', 0, this);
_MarkMenuItem(menu, kMsgToggleToolBar, _MarkMenuItem(menu, kMsgToggleToolBar,
!fToolBarView->IsHidden(fToolBarView)); !fToolbar->IsHidden(fToolbar));
} }
if (popupMenu) { if (popupMenu) {
@@ -553,7 +553,7 @@ ShowImageWindow::_ToggleMenuItem(uint32 what)
marked = !item->IsMarked(); marked = !item->IsMarked();
item->SetMarked(marked); item->SetMarked(marked);
} }
fToolBarView->SetActionPressed(what, marked); fToolbar->SetActionPressed(what, marked);
return marked; return marked;
} }
@@ -564,7 +564,7 @@ ShowImageWindow::_EnableMenuItem(BMenu* menu, uint32 what, bool enable)
BMenuItem* item = menu->FindItem(what); BMenuItem* item = menu->FindItem(what);
if (item && item->IsEnabled() != enable) if (item && item->IsEnabled() != enable)
item->SetEnabled(enable); item->SetEnabled(enable);
fToolBarView->SetActionEnabled(what, enable); fToolbar->SetActionEnabled(what, enable);
} }
@@ -574,7 +574,7 @@ ShowImageWindow::_MarkMenuItem(BMenu* menu, uint32 what, bool marked)
BMenuItem* item = menu->FindItem(what); BMenuItem* item = menu->FindItem(what);
if (item && item->IsMarked() != marked) if (item && item->IsMarked() != marked)
item->SetMarked(marked); item->SetMarked(marked);
fToolBarView->SetActionPressed(what, marked); fToolbar->SetActionPressed(what, marked);
} }
@@ -893,13 +893,13 @@ ShowImageWindow::MessageReceived(BMessage* message)
if (item->IsMarked()) { if (item->IsMarked()) {
item->SetMarked(false); item->SetMarked(false);
_StopSlideShow(); _StopSlideShow();
fToolBarView->SetActionPressed(MSG_SLIDE_SHOW, false); fToolbar->SetActionPressed(MSG_SLIDE_SHOW, false);
} else if (_ClosePrompt()) { } else if (_ClosePrompt()) {
item->SetMarked(true); item->SetMarked(true);
if (!fFullScreen && fullScreen) if (!fFullScreen && fullScreen)
_ToggleFullScreen(); _ToggleFullScreen();
_StartSlideShow(); _StartSlideShow();
fToolBarView->SetActionPressed(MSG_SLIDE_SHOW, true); fToolbar->SetActionPressed(MSG_SLIDE_SHOW, true);
} }
break; break;
} }
@@ -911,7 +911,7 @@ ShowImageWindow::MessageReceived(BMessage* message)
item->SetMarked(false); item->SetMarked(false);
_StopSlideShow(); _StopSlideShow();
fToolBarView->SetActionPressed(MSG_SLIDE_SHOW, false); fToolbar->SetActionPressed(MSG_SLIDE_SHOW, false);
break; break;
} }
@@ -1032,7 +1032,7 @@ ShowImageWindow::MessageReceived(BMessage* message)
{ {
float offset; float offset;
if (message->FindFloat("offset", &offset) == B_OK) { if (message->FindFloat("offset", &offset) == B_OK) {
fToolBarView->MoveBy(0, offset); fToolbar->MoveBy(0, offset);
fScrollView->ResizeBy(0, -offset); fScrollView->ResizeBy(0, -offset);
fScrollView->MoveBy(0, offset); fScrollView->MoveBy(0, offset);
fVerticalScrollBar->ResizeBy(0, -offset); fVerticalScrollBar->ResizeBy(0, -offset);
@@ -1049,11 +1049,11 @@ ShowImageWindow::MessageReceived(BMessage* message)
if (message->FindFloat("offset", &offset) == B_OK if (message->FindFloat("offset", &offset) == B_OK
&& message->FindBool("show", &show) == B_OK) { && message->FindBool("show", &show) == B_OK) {
// Compensate rounding errors with the final placement // Compensate rounding errors with the final placement
fToolBarView->MoveTo(fToolBarView->Frame().left, offset); fToolbar->MoveTo(fToolbar->Frame().left, offset);
if (!show) if (!show)
fToolBarView->Hide(); fToolbar->Hide();
BRect frame = fToolBarView->Parent()->Bounds(); BRect frame = fToolbar->Parent()->Bounds();
frame.top = fToolBarView->Frame().bottom + 1; frame.top = fToolbar->Frame().bottom + 1;
fScrollView->MoveTo(fScrollView->Frame().left, frame.top); fScrollView->MoveTo(fScrollView->Frame().left, frame.top);
fScrollView->ResizeTo(fScrollView->Bounds().Width(), fScrollView->ResizeTo(fScrollView->Bounds().Width(),
frame.Height() - B_H_SCROLL_BAR_HEIGHT + 1); frame.Height() - B_H_SCROLL_BAR_HEIGHT + 1);
@@ -1286,7 +1286,7 @@ ShowImageWindow::_ToggleFullScreen()
SetFlags(Flags() & ~(B_NOT_RESIZABLE | B_NOT_MOVABLE)); SetFlags(Flags() & ~(B_NOT_RESIZABLE | B_NOT_MOVABLE));
} }
fToolBarView->SetActionVisible(MSG_FULL_SCREEN, fFullScreen); fToolbar->SetActionVisible(MSG_FULL_SCREEN, fFullScreen);
_SetToolBarVisible(!fFullScreen && fShowToolBar); _SetToolBarVisible(!fFullScreen && fShowToolBar);
MoveTo(frame.left, frame.top); MoveTo(frame.left, frame.top);
@@ -1518,11 +1518,11 @@ ShowImageWindow::_SetToolBarVisible(bool visible, bool animate)
return; return;
fToolBarVisible = visible; fToolBarVisible = visible;
float diff = fToolBarView->Bounds().Height() + 2; float diff = fToolbar->Bounds().Height() + 2;
if (!visible) if (!visible)
diff = -diff; diff = -diff;
else else
fToolBarView->Show(); fToolbar->Show();
if (animate) { if (animate) {
// Slide the controls into view. We do this with messages in order // Slide the controls into view. We do this with messages in order
@@ -1543,9 +1543,9 @@ ShowImageWindow::_SetToolBarVisible(bool visible, bool animate)
fScrollView->MoveBy(0, diff); fScrollView->MoveBy(0, diff);
fVerticalScrollBar->ResizeBy(0, -diff); fVerticalScrollBar->ResizeBy(0, -diff);
fVerticalScrollBar->MoveBy(0, diff); fVerticalScrollBar->MoveBy(0, diff);
fToolBarView->MoveBy(0, diff); fToolbar->MoveBy(0, diff);
if (!visible) if (!visible)
fToolBarView->Hide(); fToolbar->Hide();
} }
} }
+2 -2
View File
@@ -27,7 +27,7 @@ class BScrollView;
class ProgressWindow; class ProgressWindow;
class ShowImageView; class ShowImageView;
class ShowImageStatusView; class ShowImageStatusView;
class ToolBarView; class BToolbar;
// public message constants // public message constants
@@ -114,7 +114,7 @@ private:
BMenu* fGoToPageMenu; BMenu* fGoToPageMenu;
BMenu* fSlideShowDelayMenu; BMenu* fSlideShowDelayMenu;
BMenu* fRatingMenu; BMenu* fRatingMenu;
ToolBarView* fToolBarView; BToolbar* fToolbar;
bool fToolBarVisible; bool fToolBarVisible;
BScrollView* fScrollView; BScrollView* fScrollView;
BScrollBar* fVerticalScrollBar; BScrollBar* fVerticalScrollBar;
+1
View File
@@ -53,6 +53,7 @@ for architectureObject in [ MultiArchSubDirSetup ] {
StringForSize.cpp StringForSize.cpp
TextTable.cpp TextTable.cpp
Thread.cpp Thread.cpp
Toolbar.cpp
Variant.cpp Variant.cpp
; ;
@@ -2,7 +2,7 @@
* Copyright 2011 Stephan Aßmus <superstippi@gmx.de> * Copyright 2011 Stephan Aßmus <superstippi@gmx.de>
* All rights reserved. Distributed under the terms of the MIT license. * All rights reserved. Distributed under the terms of the MIT license.
*/ */
#include "ToolBarView.h" #include "Toolbar.h"
#include <Button.h> #include <Button.h>
#include <ControlLook.h> #include <ControlLook.h>
@@ -40,7 +40,7 @@ LockableButton::MouseDown(BPoint point)
} }
ToolBarView::ToolBarView(BRect frame) BToolbar::BToolbar(BRect frame)
: :
BGroupView(B_HORIZONTAL) BGroupView(B_HORIZONTAL)
{ {
@@ -56,13 +56,13 @@ ToolBarView::ToolBarView(BRect frame)
} }
ToolBarView::~ToolBarView() BToolbar::~BToolbar()
{ {
} }
void void
ToolBarView::Hide() BToolbar::Hide()
{ {
BView::Hide(); BView::Hide();
// TODO: This could be fixed in BView instead. Looking from the // TODO: This could be fixed in BView instead. Looking from the
@@ -72,7 +72,7 @@ ToolBarView::Hide()
void void
ToolBarView::AddAction(uint32 command, BHandler* target, const BBitmap* icon, BToolbar::AddAction(uint32 command, BHandler* target, const BBitmap* icon,
const char* toolTipText, bool lockable) const char* toolTipText, bool lockable)
{ {
AddAction(new BMessage(command), target, icon, toolTipText, lockable); AddAction(new BMessage(command), target, icon, toolTipText, lockable);
@@ -80,7 +80,7 @@ ToolBarView::AddAction(uint32 command, BHandler* target, const BBitmap* icon,
void void
ToolBarView::AddAction(BMessage* message, BHandler* target, BToolbar::AddAction(BMessage* message, BHandler* target,
const BBitmap* icon, const char* toolTipText, bool lockable) const BBitmap* icon, const char* toolTipText, bool lockable)
{ {
@@ -99,21 +99,21 @@ ToolBarView::AddAction(BMessage* message, BHandler* target,
void void
ToolBarView::AddSeparator() BToolbar::AddSeparator()
{ {
_AddView(new BSeparatorView(B_VERTICAL, B_PLAIN_BORDER)); _AddView(new BSeparatorView(B_VERTICAL, B_PLAIN_BORDER));
} }
void void
ToolBarView::AddGlue() BToolbar::AddGlue()
{ {
GroupLayout()->AddItem(BSpaceLayoutItem::CreateGlue()); GroupLayout()->AddItem(BSpaceLayoutItem::CreateGlue());
} }
void void
ToolBarView::SetActionEnabled(uint32 command, bool enabled) BToolbar::SetActionEnabled(uint32 command, bool enabled)
{ {
if (BButton* button = _FindButton(command)) if (BButton* button = _FindButton(command))
button->SetEnabled(enabled); button->SetEnabled(enabled);
@@ -121,7 +121,7 @@ ToolBarView::SetActionEnabled(uint32 command, bool enabled)
void void
ToolBarView::SetActionPressed(uint32 command, bool pressed) BToolbar::SetActionPressed(uint32 command, bool pressed)
{ {
if (BButton* button = _FindButton(command)) if (BButton* button = _FindButton(command))
button->SetValue(pressed); button->SetValue(pressed);
@@ -129,7 +129,7 @@ ToolBarView::SetActionPressed(uint32 command, bool pressed)
void void
ToolBarView::SetActionVisible(uint32 command, bool visible) BToolbar::SetActionVisible(uint32 command, bool visible)
{ {
BButton* button = _FindButton(command); BButton* button = _FindButton(command);
if (button == NULL) if (button == NULL)
@@ -144,7 +144,7 @@ ToolBarView::SetActionVisible(uint32 command, bool visible)
void void
ToolBarView::Pulse() BToolbar::Pulse()
{ {
// TODO: Perhaps this could/should be addressed in BView instead. // TODO: Perhaps this could/should be addressed in BView instead.
if (IsHidden()) if (IsHidden())
@@ -153,7 +153,7 @@ ToolBarView::Pulse()
void void
ToolBarView::FrameResized(float width, float height) BToolbar::FrameResized(float width, float height)
{ {
// TODO: There seems to be a bug in app_server which does not // TODO: There seems to be a bug in app_server which does not
// correctly trigger invalidation of views which are shown, when // correctly trigger invalidation of views which are shown, when
@@ -163,14 +163,14 @@ ToolBarView::FrameResized(float width, float height)
void void
ToolBarView::_AddView(BView* view) BToolbar::_AddView(BView* view)
{ {
GroupLayout()->AddView(view); GroupLayout()->AddView(view);
} }
BButton* BButton*
ToolBarView::_FindButton(uint32 command) const BToolbar::_FindButton(uint32 command) const
{ {
for (int32 i = 0; BView* view = ChildAt(i); i++) { for (int32 i = 0; BView* view = ChildAt(i); i++) {
BButton* button = dynamic_cast<BButton*>(view); BButton* button = dynamic_cast<BButton*>(view);
@@ -190,7 +190,7 @@ ToolBarView::_FindButton(uint32 command) const
void void
ToolBarView::_HideToolTips() const BToolbar::_HideToolTips() const
{ {
for (int32 i = 0; BView* view = ChildAt(i); i++) for (int32 i = 0; BView* view = ChildAt(i); i++)
view->HideToolTip(); view->HideToolTip();