Skip to content

Commit

Permalink
BToolBar: Add a "text" parameter.
Browse files Browse the repository at this point in the history
For defining the text that appears alongside the icon.

This function really has too many parameters; we probably should break
it out into a BAction class...
  • Loading branch information
waddlesplash committed Jul 22, 2015
1 parent 006fd65 commit 58ee42e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
2 changes: 2 additions & 0 deletions headers/private/shared/ToolBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ class BToolBar : public BGroupView {
void AddAction(uint32 command, BHandler* target,
const BBitmap* icon,
const char* toolTipText = NULL,
const char* text = NULL,
bool lockable = false);
void AddAction(BMessage* message, BHandler* target,
const BBitmap* icon,
const char* toolTipText = NULL,
const char* text = NULL,
bool lockable = false);
void AddSeparator();
void AddGlue();
Expand Down
25 changes: 12 additions & 13 deletions src/apps/showimage/ShowImageWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,36 +178,35 @@ ShowImageWindow::ShowImageWindow(BRect frame, const entry_ref& ref,
// fToolBar->AddAction(MSG_FILE_OPEN, be_app,
// tool_bar_icon(kIconDocumentOpen), B_TRANSLATE("Open" B_UTF8_ELLIPSIS));
fToolBar->AddAction(MSG_FILE_PREV, this,
tool_bar_icon(kIconGoPrevious), B_TRANSLATE("Previous file"), false);
tool_bar_icon(kIconGoPrevious), B_TRANSLATE("Previous file"));
fToolBar->AddAction(MSG_FILE_NEXT, this, tool_bar_icon(kIconGoNext),
B_TRANSLATE("Next file"), false);
B_TRANSLATE("Next file"));
BMessage* fullScreenSlideShow = new BMessage(MSG_SLIDE_SHOW);
fullScreenSlideShow->AddBool("full screen", true);
fToolBar->AddAction(fullScreenSlideShow, this,
tool_bar_icon(kIconMediaMovieLibrary), B_TRANSLATE("Slide show"),
false);
tool_bar_icon(kIconMediaMovieLibrary), B_TRANSLATE("Slide show"));
fToolBar->AddSeparator();
fToolBar->AddAction(MSG_SELECTION_MODE, this,
tool_bar_icon(kIconDrawRectangularSelection),
B_TRANSLATE("Selection mode"), false);
B_TRANSLATE("Selection mode"));
fToolBar->AddSeparator();
fToolBar->AddAction(kMsgOriginalSize, this,
tool_bar_icon(kIconZoomOriginal), B_TRANSLATE("Original size"), true);
tool_bar_icon(kIconZoomOriginal), B_TRANSLATE("Original size"), NULL,
true);
fToolBar->AddAction(kMsgFitToWindow, this,
tool_bar_icon(kIconZoomFitBest), B_TRANSLATE("Fit to window"), false);
tool_bar_icon(kIconZoomFitBest), B_TRANSLATE("Fit to window"));
fToolBar->AddAction(MSG_ZOOM_IN, this, tool_bar_icon(kIconZoomIn),
B_TRANSLATE("Zoom in"), false);
B_TRANSLATE("Zoom in"));
fToolBar->AddAction(MSG_ZOOM_OUT, this, tool_bar_icon(kIconZoomOut),
B_TRANSLATE("Zoom out"), false);
B_TRANSLATE("Zoom out"));
fToolBar->AddSeparator();
fToolBar->AddAction(MSG_PAGE_PREV, this, tool_bar_icon(kIconPagePrevious),
B_TRANSLATE("Previous page"), false);
B_TRANSLATE("Previous page"));
fToolBar->AddAction(MSG_PAGE_NEXT, this, tool_bar_icon(kIconPageNext),
B_TRANSLATE("Next page"), false);
B_TRANSLATE("Next page"));
fToolBar->AddGlue();
fToolBar->AddAction(MSG_FULL_SCREEN, this,
tool_bar_icon(kIconViewWindowed), B_TRANSLATE("Leave full screen"),
false);
tool_bar_icon(kIconViewWindowed), B_TRANSLATE("Leave full screen"));
fToolBar->SetActionVisible(MSG_FULL_SCREEN, false);

fToolBar->ResizeTo(viewFrame.Width(), fToolBar->MinSize().height);
Expand Down
10 changes: 6 additions & 4 deletions src/kits/shared/ToolBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,17 @@ BToolBar::Hide()

void
BToolBar::AddAction(uint32 command, BHandler* target, const BBitmap* icon,
const char* toolTipText, bool lockable)
const char* toolTipText, const char* text, bool lockable)
{
AddAction(new BMessage(command), target, icon, toolTipText, lockable);
AddAction(new BMessage(command), target, icon, toolTipText, text, lockable);
}


void
BToolBar::AddAction(BMessage* message, BHandler* target,
const BBitmap* icon, const char* toolTipText, bool lockable)
const BBitmap* icon, const char* toolTipText, const char* text,
bool lockable)
{

BButton* button;
if (lockable)
button = new LockableButton(NULL, NULL, message);
Expand All @@ -103,6 +103,8 @@ BToolBar::AddAction(BMessage* message, BHandler* target,
button->SetFlat(true);
if (toolTipText != NULL)
button->SetToolTip(toolTipText);
if (text != NULL)
button->SetLabel(text);
AddView(button);
button->SetTarget(target);
}
Expand Down

0 comments on commit 58ee42e

Please sign in to comment.