void ModulesView::_CloseSaver() { // remove old screen saver preview & config BScreenSaver* saver = _ScreenSaver(); BView* view = fPreviewView->RemovePreview(); if (fSettingsView != NULL) fSettingsBox->RemoveChild(fSettingsView); if (fSaverRunner != NULL) fSaverRunner->Quit(); if (saver != NULL) saver->StopConfig(); delete view; delete fSettingsView; delete fSaverRunner; // the saver runner also unloads the add-on, so it must // be deleted last fSettingsView = NULL; fSaverRunner = NULL; }
void ModulesView::_OpenSaver() { // create new screen saver preview & config BView* view = fPreviewView->AddPreview(); fCurrentName = fSettings.ModuleName(); fSaverRunner = new ScreenSaverRunner(Window(), view, true, fSettings); BScreenSaver* saver = _ScreenSaver(); #ifdef __HAIKU__ BRect rect = fSettingsBox->InnerFrame().InsetByCopy(4, 4); #else BRect rect = fSettingsBox->Bounds().InsetByCopy(4, 4); rect.top += 14; #endif fSettingsView = new BView(rect, "SettingsView", B_FOLLOW_ALL, B_WILL_DRAW); fSettingsView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fSettingsBox->AddChild(fSettingsView); if (saver != NULL && fSaverRunner->Run() == B_OK) saver->StartConfig(fSettingsView); if (fSettingsView->ChildAt(0) == NULL) { // There are no settings at all, we add the module name here to // let it look a bit better at least. BPrivate::BuildScreenSaverDefaultSettingsView(fSettingsView, fSettings.ModuleName()[0] ? fSettings.ModuleName() : B_TRANSLATE("Blackness"), saver != NULL || !fSettings.ModuleName()[0] ? B_TRANSLATE("No options available") : B_TRANSLATE("Could not load screen saver")); } }
void ModulesView::_OpenSaver() { // create new screen saver preview & config BView* view = fPreviewView->AddPreview(); fCurrentName = fSettings.ModuleName(); fSaverRunner = new ScreenSaverRunner(view->Window(), view, fSettings); #ifdef __HAIKU__ BRect rect = fSettingsBox->InnerFrame().InsetByCopy(4, 4); #else BRect rect = fSettingsBox->Bounds().InsetByCopy(4, 4); rect.top += 14; #endif fSettingsView = new BView(rect, "SettingsView", B_FOLLOW_ALL, B_WILL_DRAW); fSettingsView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); fSettingsBox->AddChild(fSettingsView); BScreenSaver* saver = ScreenSaver(); if (saver != NULL && fSettingsView != NULL) { saver->StartConfig(fSettingsView); if (saver->StartSaver(view, true) == B_OK) { fPreviewView->HideNoPreview(); fSaverRunner->Run(); } else fPreviewView->ShowNoPreview(); } else { // Failed to load OR this is the "Blackness" screensaver. Show a black // preview (this is what will happen in both cases when screen_blanker // runs). fPreviewView->HideNoPreview(); } if (fSettingsView->ChildAt(0) == NULL) { // There are no settings at all, we add the module name here to // let it look a bit better at least. BPrivate::BuildDefaultSettingsView(fSettingsView, fSettings.ModuleName()[0] ? fSettings.ModuleName() : B_TRANSLATE("Blackness"), saver != NULL || !fSettings.ModuleName()[0] ? B_TRANSLATE("No options available") : B_TRANSLATE("Could not load screen saver")); } }
virtual void TextChangedCallback(ui::Textbox * sender) { v->commentBoxAutoHeight(); }
virtual void ActionCallback(ui::Button * sender) { v->submitComment(); }
void updatePreview() { preview->update(); }
void ModulesView::_OpenSaver() { // create new screen saver preview & config BView* view = fPreviewView->AddPreview(); fCurrentName = fSettings.ModuleName(); fSaverRunner = new ScreenSaverRunner(Window(), view, true, fSettings); BScreenSaver* saver = _ScreenSaver(); #ifdef __HAIKU__ BRect rect = fSettingsBox->InnerFrame().InsetByCopy(4, 4); #else BRect rect = fSettingsBox->Bounds().InsetByCopy(4, 4); rect.top += 14; #endif fSettingsView = new BView(rect, "SettingsView", B_FOLLOW_ALL, B_WILL_DRAW); fSettingsView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fSettingsBox->AddChild(fSettingsView); if (saver != NULL) { fSaverRunner->Run(); saver->StartConfig(fSettingsView); } if (fSettingsView->ChildAt(0) == NULL) { // There are no settings at all, we add the module name here to // let it look a bit better at least. BPrivate::BuildScreenSaverDefaultSettingsView(fSettingsView, fSettings.ModuleName()[0] ? fSettings.ModuleName() : B_TRANSLATE("Blackness"), saver || !fSettings.ModuleName()[0] ? B_TRANSLATE("No options available") : B_TRANSLATE("Could not load screen saver")); } ScreenSaverWindow* window = dynamic_cast<ScreenSaverWindow*>(Window()); if (window == NULL) return; // find the minimal size of the settings view float right = 0, bottom = 0; int32 i = 0; while ((view = fSettingsView->ChildAt(i++)) != NULL) { // very simple heuristic... float viewRight = view->Frame().right; if ((view->ResizingMode() & _rule_(0, 0xf, 0, 0xf)) == B_FOLLOW_LEFT_RIGHT) { float width, height; view->GetPreferredSize(&width, &height); viewRight = view->Frame().left + width / 2; } else if ((view->ResizingMode() & _rule_(0, 0xf, 0, 0xf)) == B_FOLLOW_RIGHT) viewRight = 8 + view->Frame().Width(); float viewBottom = view->Frame().bottom; if ((view->ResizingMode() & _rule_(0xf, 0, 0xf, 0)) == B_FOLLOW_TOP_BOTTOM) { float width, height; view->GetPreferredSize(&width, &height); viewBottom = view->Frame().top + height; } else if ((view->ResizingMode() & _rule_(0xf, 0, 0xf, 0)) == B_FOLLOW_BOTTOM) viewBottom = 8 + view->Frame().Height(); if (viewRight > right) right = viewRight; if (viewBottom > bottom) bottom = viewBottom; } if (right < kMinSettingsWidth) right = kMinSettingsWidth; if (bottom < kMinSettingsHeight) bottom = kMinSettingsHeight; BPoint leftTop = fSettingsView->LeftTop(); fSettingsView->ConvertToScreen(&leftTop); window->ConvertFromScreen(&leftTop); window->SetMinimalSizeLimit(leftTop.x + right + 16, leftTop.y + bottom + 16); }