hrev45272 adds 3 changesets to branch 'master' old head: 19ec4667bc7ca7b40bba7ac54499df4a50c33405 new head: 66e94108063bab01c7859442fe0d9ed777de9808 overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=66e9410+%5E19ec466 ---------------------------------------------------------------------------- 9f7ac43: Add methods to get and set the name, version, and icon 381629a: Close about window on escape 66e9410: Switch about window to current workspace if hidden. [ John Scipione <jscipione@xxxxxxxxx> ] ---------------------------------------------------------------------------- 2 files changed, 217 insertions(+), 10 deletions(-) headers/private/shared/AboutWindow.h | 11 ++ src/kits/shared/AboutWindow.cpp | 216 +++++++++++++++++++++++++++++-- ############################################################################ Commit: 9f7ac4312ab99b6246252305143592c8c78c900e URL: http://cgit.haiku-os.org/haiku/commit/?id=9f7ac43 Author: John Scipione <jscipione@xxxxxxxxx> Date: Sun Feb 10 23:11:01 2013 UTC Add methods to get and set the name, version, and icon ---------------------------------------------------------------------------- diff --git a/headers/private/shared/AboutWindow.h b/headers/private/shared/AboutWindow.h index 6dcaa77..33bc35b 100644 --- a/headers/private/shared/AboutWindow.h +++ b/headers/private/shared/AboutWindow.h @@ -16,6 +16,7 @@ class AboutView; +class BBitmap; class BPoint; class BHandler; @@ -37,6 +38,15 @@ class BAboutWindow : public BWindow { void AddVersionHistory(const char** history); void AddExtraInfo(const char* extraInfo); + BBitmap* Icon(); + void SetIcon(BBitmap* icon); + + const char* Name(); + void SetName(const char* name); + + const char* Version(); + void SetVersion(const char* version); + private: AboutView* fAboutView; BHandler* fCaller; diff --git a/src/kits/shared/AboutWindow.cpp b/src/kits/shared/AboutWindow.cpp index 8e4d103..363e6f3 100644 --- a/src/kits/shared/AboutWindow.cpp +++ b/src/kits/shared/AboutWindow.cpp @@ -49,6 +49,9 @@ class StripeView : public BView { virtual void Draw(BRect updateRect); + BBitmap* Icon() const { return fIcon; }; + void SetIcon(BBitmap* icon); + private: BBitmap* fIcon; }; @@ -62,14 +65,24 @@ class AboutView : public BGroupView { BTextView* InfoView() const { return fInfoView; }; + BBitmap* Icon(); + status_t SetIcon(BBitmap* icon); + + const char* Name(); + status_t SetName(const char* name); + + const char* Version(); + status_t SetVersion(const char* version); + protected: - const char* AppVersion(const char* signature); - BBitmap* AppIcon(const char* signature); + const char* _GetVersionFromSignature(const char* signature); + BBitmap* _GetIconFromSignature(const char* signature); private: BStringView* fNameView; BStringView* fVersionView; BTextView* fInfoView; + StripeView* fStripeView; }; @@ -81,13 +94,14 @@ StripeView::StripeView(BBitmap* icon) BView("StripeView", B_WILL_DRAW), fIcon(icon) { + SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + float width = 0.0f; if (icon != NULL) width += icon->Bounds().Width() + 32.0f; SetExplicitMinSize(BSize(width, B_SIZE_UNSET)); SetExplicitPreferredSize(BSize(width, B_SIZE_UNLIMITED)); - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); } @@ -116,7 +130,24 @@ StripeView::Draw(BRect updateRect) } -// #pragma mark - +void +StripeView::SetIcon(BBitmap* icon) +{ + if (fIcon != NULL) + delete fIcon; + + fIcon = icon; + + float width = 0.0f; + if (icon != NULL) + width += icon->Bounds().Width() + 32.0f; + + SetExplicitMinSize(BSize(width, B_SIZE_UNSET)); + SetExplicitPreferredSize(BSize(width, B_SIZE_UNLIMITED)); +}; + + +// #pragma mark - AboutView AboutView::AboutView(const char* appName, const char* signature) @@ -131,7 +162,8 @@ AboutView::AboutView(const char* appName, const char* signature) fNameView->SetFont(&font, B_FONT_FAMILY_AND_STYLE | B_FONT_SIZE | B_FONT_FLAGS); - fVersionView = new BStringView("version", AppVersion(signature)); + fVersionView = new BStringView("version", + _GetVersionFromSignature(signature)); fInfoView = new BTextView("info", B_WILL_DRAW); fInfoView->SetExplicitMinSize(BSize(210.0, 160.0)); @@ -145,10 +177,12 @@ AboutView::AboutView(const char* appName, const char* signature) "infoViewScroller", fInfoView, B_WILL_DRAW | B_FRAME_EVENTS, false, true, B_PLAIN_BORDER); + fStripeView = new StripeView(_GetIconFromSignature(signature)); + GroupLayout()->SetSpacing(0); BLayoutBuilder::Group<>(this) .AddGroup(B_HORIZONTAL, 0) - .Add(new StripeView(AppIcon(signature))) + .Add(fStripeView) .AddGroup(B_VERTICAL, B_USE_SMALL_SPACING) .SetInsets(0, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING) @@ -166,8 +200,11 @@ AboutView::~AboutView() } +// #pragma mark - AboutView protected methods + + const char* -AboutView::AppVersion(const char* signature) +AboutView::_GetVersionFromSignature(const char* signature) { if (signature == NULL) return NULL; @@ -228,7 +265,7 @@ AboutView::AppVersion(const char* signature) BBitmap* -AboutView::AppIcon(const char* signature) +AboutView::_GetIconFromSignature(const char* signature) { if (signature == NULL) return NULL; @@ -251,7 +288,64 @@ AboutView::AppIcon(const char* signature) } -// #pragma mark - +// #pragma mark - AboutView public methods + + +const char* +AboutView::Name() +{ + return fNameView->Text(); +} + + +status_t +AboutView::SetName(const char* name) +{ + fNameView->SetText(name); + + return B_OK; +} + + +const char* +AboutView::Version() +{ + return fVersionView->Text(); +} + + +status_t +AboutView::SetVersion(const char* version) +{ + fVersionView->SetText(version); + + return B_OK; +} + + +BBitmap* +AboutView::Icon() +{ + if (fStripeView == NULL) + return NULL; + + return fStripeView->Icon(); +} + + +status_t +AboutView::SetIcon(BBitmap* icon) +{ + if (fStripeView == NULL) + return B_NO_INIT; + + fStripeView->SetIcon(icon); + + return B_OK; +} + + +// #pragma mark - BAboutWindow BAboutWindow::BAboutWindow(const char* appName, const char* signature) @@ -283,6 +377,9 @@ BAboutWindow::~BAboutWindow() } +// #pragma mark - BAboutWindow virtual methods + + bool BAboutWindow::QuitRequested() { @@ -292,7 +389,7 @@ BAboutWindow::QuitRequested() } -// #pragma mark - +// #pragma mark - BAboutWindow public methods BPoint @@ -463,3 +560,45 @@ BAboutWindow::AddExtraInfo(const char* extraInfo) fAboutView->InfoView()->Insert(extra.String()); } + + +const char* +BAboutWindow::Name() +{ + return fAboutView->Name(); +} + + +void +BAboutWindow::SetName(const char* name) +{ + fAboutView->SetName(name); +} + + +const char* +BAboutWindow::Version() +{ + return fAboutView->Version(); +} + + +void +BAboutWindow::SetVersion(const char* version) +{ + fAboutView->SetVersion(version); +} + + +BBitmap* +BAboutWindow::Icon() +{ + return fAboutView->Icon(); +} + + +void +BAboutWindow::SetIcon(BBitmap* icon) +{ + fAboutView->SetIcon(icon); +} ############################################################################ Commit: 381629a7b6d4c88f2fe857b6220dca8438fcfdb1 URL: http://cgit.haiku-os.org/haiku/commit/?id=381629a Author: John Scipione <jscipione@xxxxxxxxx> Date: Mon Feb 11 00:30:45 2013 UTC Close about window on escape ---------------------------------------------------------------------------- diff --git a/src/kits/shared/AboutWindow.cpp b/src/kits/shared/AboutWindow.cpp index 363e6f3..d8e66c2 100644 --- a/src/kits/shared/AboutWindow.cpp +++ b/src/kits/shared/AboutWindow.cpp @@ -20,7 +20,10 @@ #include <Font.h> #include <GroupLayoutBuilder.h> #include <GroupView.h> +#include <InterfaceDefs.h> #include <LayoutBuilder.h> +#include <Message.h> +#include <MessageFilter.h> #include <Point.h> #include <Roster.h> #include <Screen.h> @@ -42,6 +45,46 @@ using BPrivate::gSystemCatalog; #define B_TRANSLATION_CONTEXT "AboutWindow" +class EscapeFilter : public BMessageFilter { + public: + EscapeFilter(BWindow* target) + : + BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE), + fTarget(target) + { + } + virtual ~EscapeFilter() + { + } + virtual filter_result + Filter(BMessage* message, BHandler** target) + { + filter_result result = B_DISPATCH_MESSAGE; + switch (message->what) { + case B_KEY_DOWN: + case B_UNMAPPED_KEY_DOWN: { + uint32 key; + if (message->FindInt32("raw_char", + (int32*)&key) >= B_OK) { + if (key == B_ESCAPE) { + result = B_SKIP_MESSAGE; + fTarget->PostMessage( + B_QUIT_REQUESTED); + } + } + break; + } + default: + break; + } + + return result; + } + private: + BWindow* fTarget; +}; + + class StripeView : public BView { public: StripeView(BBitmap* icon); @@ -366,6 +409,8 @@ BAboutWindow::BAboutWindow(const char* appName, const char* signature) AddChild(fAboutView); MoveTo(AboutPosition(Frame().Width(), Frame().Height())); + + AddCommonFilter(new EscapeFilter(this)); } ############################################################################ Revision: hrev45272 Commit: 66e94108063bab01c7859442fe0d9ed777de9808 URL: http://cgit.haiku-os.org/haiku/commit/?id=66e9410 Author: John Scipione <jscipione@xxxxxxxxx> Date: Tue Feb 12 02:25:51 2013 UTC Switch about window to current workspace if hidden. ---------------------------------------------------------------------------- diff --git a/headers/private/shared/AboutWindow.h b/headers/private/shared/AboutWindow.h index 33bc35b..16a9f42 100644 --- a/headers/private/shared/AboutWindow.h +++ b/headers/private/shared/AboutWindow.h @@ -27,6 +27,7 @@ class BAboutWindow : public BWindow { virtual ~BAboutWindow(); virtual bool QuitRequested(); + virtual void Show(); BPoint AboutPosition(float width, float height); void AddDescription(const char* description); diff --git a/src/kits/shared/AboutWindow.cpp b/src/kits/shared/AboutWindow.cpp index d8e66c2..350968d 100644 --- a/src/kits/shared/AboutWindow.cpp +++ b/src/kits/shared/AboutWindow.cpp @@ -434,6 +434,18 @@ BAboutWindow::QuitRequested() } +void +BAboutWindow::Show() +{ + if (IsHidden()) { + // move to current workspace + SetWorkspaces(B_CURRENT_WORKSPACE); + } + + BWindow::Show(); +} + + // #pragma mark - BAboutWindow public methods