From 57810fe9e0e25aa2fd6d035a9f6e3046ab688976 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Wed, 29 Oct 2014 10:55:04 +0100 Subject: [PATCH] Sounds: zoom to fit instead of going fullscreen. Fixes #5588. --- src/preferences/sounds/HEventList.cpp | 2 ++ src/preferences/sounds/HWindow.cpp | 51 +++++++++++++++++---------- src/preferences/sounds/HWindow.h | 1 + 3 files changed, 36 insertions(+), 18 deletions(-) diff --git a/src/preferences/sounds/HEventList.cpp b/src/preferences/sounds/HEventList.cpp index ad971f4014..5e7edd04f4 100644 --- a/src/preferences/sounds/HEventList.cpp +++ b/src/preferences/sounds/HEventList.cpp @@ -93,6 +93,8 @@ HEventList::SetType(const char* type) else AddRow(new HEventRow(name.String(), path.Path())); } + + ResizeAllColumnsToPreferred(); } diff --git a/src/preferences/sounds/HWindow.cpp b/src/preferences/sounds/HWindow.cpp index 85598420c1..6fba4171ee 100644 --- a/src/preferences/sounds/HWindow.cpp +++ b/src/preferences/sounds/HWindow.cpp @@ -224,6 +224,21 @@ HWindow::MessageReceived(BMessage* message) if (item != NULL) item->SetMarked(true); } + + HEventRow* row = (HEventRow*)fEventList->CurrentSelection(); + BButton* button = dynamic_cast(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; } @@ -231,8 +246,10 @@ HWindow::MessageReceived(BMessage* message) case M_ITEM_MESSAGE: { entry_ref ref; - if (message->FindRef("refs", &ref) == B_OK) + if (message->FindRef("refs", &ref) == B_OK) { fEventList->SetPath(BPath(&ref).Path()); + _UpdateZoomLimits(); + } break; } @@ -316,33 +333,19 @@ HWindow::_InitGUI() BMenuItem* noneItem = menu->FindItem(B_TRANSLATE("")); if (noneItem != NULL) noneItem->SetMarked(true); + + _UpdateZoomLimits(); } void HWindow::_Pulse() { - HEventRow* row = (HEventRow*)fEventList->CurrentSelection(); - BMenuField* menufield = dynamic_cast(FindView("filemenu")); - BButton* button = dynamic_cast(FindView("play")); BButton* stop = dynamic_cast(FindView("stop")); - if (menufield == NULL || button == NULL || stop == NULL) + if (stop == NULL) 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->IsPlaying()) 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); +} diff --git a/src/preferences/sounds/HWindow.h b/src/preferences/sounds/HWindow.h index 28a5afac5f..7402340c28 100644 --- a/src/preferences/sounds/HWindow.h +++ b/src/preferences/sounds/HWindow.h @@ -47,6 +47,7 @@ private: void _InitGUI(); void _Pulse(); void _SetupMenuField(); + void _UpdateZoomLimits(); private: HEventList* fEventList;