Sounds: zoom to fit instead of going fullscreen.

Fixes #5588.
This commit is contained in:
Adrien Destugues
2014-10-29 10:55:04 +01:00
parent 3a8e734bdd
commit 57810fe9e0
3 changed files with 36 additions and 18 deletions
+2
View File
@@ -93,6 +93,8 @@ HEventList::SetType(const char* type)
else else
AddRow(new HEventRow(name.String(), path.Path())); AddRow(new HEventRow(name.String(), path.Path()));
} }
ResizeAllColumnsToPreferred();
} }
+33 -18
View File
@@ -224,6 +224,21 @@ HWindow::MessageReceived(BMessage* message)
if (item != NULL) if (item != NULL)
item->SetMarked(true); item->SetMarked(true);
} }
HEventRow* row = (HEventRow*)fEventList->CurrentSelection();
BButton* button = dynamic_cast<BButton*>(FindView("play"));
if (row != NULL) {
menufield->SetEnabled(true);
const char* path = row->Path();
if (path != NULL && strcmp(path, ""))
button->SetEnabled(true);
else
button->SetEnabled(false);
} else {
menufield->SetEnabled(false);
button->SetEnabled(false);
}
} }
break; break;
} }
@@ -231,8 +246,10 @@ HWindow::MessageReceived(BMessage* message)
case M_ITEM_MESSAGE: case M_ITEM_MESSAGE:
{ {
entry_ref ref; entry_ref ref;
if (message->FindRef("refs", &ref) == B_OK) if (message->FindRef("refs", &ref) == B_OK) {
fEventList->SetPath(BPath(&ref).Path()); fEventList->SetPath(BPath(&ref).Path());
_UpdateZoomLimits();
}
break; break;
} }
@@ -316,33 +333,19 @@ HWindow::_InitGUI()
BMenuItem* noneItem = menu->FindItem(B_TRANSLATE("<none>")); BMenuItem* noneItem = menu->FindItem(B_TRANSLATE("<none>"));
if (noneItem != NULL) if (noneItem != NULL)
noneItem->SetMarked(true); noneItem->SetMarked(true);
_UpdateZoomLimits();
} }
void void
HWindow::_Pulse() HWindow::_Pulse()
{ {
HEventRow* row = (HEventRow*)fEventList->CurrentSelection();
BMenuField* menufield = dynamic_cast<BMenuField*>(FindView("filemenu"));
BButton* button = dynamic_cast<BButton*>(FindView("play"));
BButton* stop = dynamic_cast<BButton*>(FindView("stop")); BButton* stop = dynamic_cast<BButton*>(FindView("stop"));
if (menufield == NULL || button == NULL || stop == NULL) if (stop == NULL)
return; return;
if (row != NULL) {
menufield->SetEnabled(true);
const char* path = row->Path();
if (path != NULL && strcmp(path, ""))
button->SetEnabled(true);
else
button->SetEnabled(false);
} else {
menufield->SetEnabled(false);
button->SetEnabled(false);
}
if (fPlayer != NULL) { if (fPlayer != NULL) {
if (fPlayer->IsPlaying()) if (fPlayer->IsPlaying())
stop->SetEnabled(true); stop->SetEnabled(true);
@@ -414,3 +417,15 @@ HWindow::_SetupMenuField()
} }
} }
} }
void
HWindow::_UpdateZoomLimits()
{
const float kInset = be_control_look->DefaultItemSpacing();
BSize size = fEventList->PreferredSize();
SetZoomLimits(size.width + 2 * kInset + B_V_SCROLL_BAR_WIDTH,
size.height + 5 * kInset + 2 * B_H_SCROLL_BAR_HEIGHT
+ 2 * be_plain_font->Size() * 2.5);
}
+1
View File
@@ -47,6 +47,7 @@ private:
void _InitGUI(); void _InitGUI();
void _Pulse(); void _Pulse();
void _SetupMenuField(); void _SetupMenuField();
void _UpdateZoomLimits();
private: private:
HEventList* fEventList; HEventList* fEventList;