diff options
Diffstat (limited to 'chrome/browser/chromeos/frame')
-rw-r--r-- | chrome/browser/chromeos/frame/bubble_frame_view.cc | 79 | ||||
-rw-r--r-- | chrome/browser/chromeos/frame/bubble_frame_view.h | 6 | ||||
-rw-r--r-- | chrome/browser/chromeos/frame/bubble_window.h | 6 |
3 files changed, 67 insertions, 24 deletions
diff --git a/chrome/browser/chromeos/frame/bubble_frame_view.cc b/chrome/browser/chromeos/frame/bubble_frame_view.cc index becfb78..9fe97c2 100644 --- a/chrome/browser/chromeos/frame/bubble_frame_view.cc +++ b/chrome/browser/chromeos/frame/bubble_frame_view.cc @@ -11,10 +11,12 @@ #include "gfx/path.h" #include "gfx/rect.h" #include "chrome/browser/chromeos/frame/bubble_window.h" +#include "chrome/browser/chromeos/login/helper.h" #include "chrome/browser/views/bubble_border.h" #include "grit/theme_resources.h" #include "views/controls/button/image_button.h" #include "views/controls/label.h" +#include "views/controls/throbber.h" #include "views/window/hit_test.h" #include "views/window/window.h" #include "views/window/window_delegate.h" @@ -35,7 +37,8 @@ BubbleFrameView::BubbleFrameView(views::Window* frame, : frame_(frame), style_(style), title_(NULL), - close_button_(NULL) { + close_button_(NULL), + throbber_(NULL) { set_border(new BubbleBorder(BubbleBorder::NONE)); if (frame_->GetDelegate()->ShouldShowWindowTitle()) { @@ -56,11 +59,30 @@ BubbleFrameView::BubbleFrameView(views::Window* frame, rb.GetBitmapNamed(IDR_CLOSE_BAR_P)); AddChildView(close_button_); } + + if (style_ & BubbleWindow::STYLE_THROBBER) { + throbber_ = CreateDefaultSmoothedThrobber(); + AddChildView(throbber_); + } } BubbleFrameView::~BubbleFrameView() { } +void BubbleFrameView::StartThrobber() { + DCHECK(throbber_ != NULL); + if (title_) + title_->SetText(std::wstring()); + throbber_->Start(); +} + +void BubbleFrameView::StopThrobber() { + DCHECK(throbber_ != NULL); + throbber_->Stop(); + if (title_) + title_->SetText(frame_->GetDelegate()->GetWindowTitle()); +} + gfx::Rect BubbleFrameView::GetBoundsForClientView() const { return client_view_bounds_; } @@ -68,20 +90,25 @@ gfx::Rect BubbleFrameView::GetBoundsForClientView() const { gfx::Rect BubbleFrameView::GetWindowBoundsForClientBounds( const gfx::Rect& client_bounds) const { gfx::Insets insets = GetInsets(); + gfx::Size title_size; - if (title_) { + if (title_) title_size = title_->GetPreferredSize(); - } - - gfx::Size close_button_size = gfx::Size(); - if (close_button_) { + gfx::Size close_button_size; + if (close_button_) close_button_size = close_button_->GetPreferredSize(); - } + gfx::Size throbber_size; + if (throbber_) + throbber_size = throbber_->GetPreferredSize(); int top_height = insets.top(); - if (title_size.height() > 0 || close_button_size.height() > 0) - top_height += std::max(title_size.height(), close_button_size.height()) + - kTitleContentPadding; + if (title_size.height() > 0 || + close_button_size.height() > 0 || + throbber_size.height() > 0) { + top_height += kTitleContentPadding + std::max( + std::max(title_size.height(), close_button_size.height()), + throbber_size.height()); + } return gfx::Rect(std::max(0, client_bounds.x() - insets.left()), std::max(0, client_bounds.y() - top_height), client_bounds.width() + insets.width(), @@ -125,14 +152,14 @@ void BubbleFrameView::Layout() { gfx::Insets insets = GetInsets(); gfx::Size title_size; - if (title_) { + if (title_) title_size = title_->GetPreferredSize(); - } - - gfx::Size close_button_size = gfx::Size(); - if (close_button_) { + gfx::Size close_button_size; + if (close_button_) close_button_size = close_button_->GetPreferredSize(); - } + gfx::Size throbber_size; + if (throbber_) + throbber_size = throbber_->GetPreferredSize(); if (title_) { title_->SetBounds( @@ -147,10 +174,21 @@ void BubbleFrameView::Layout() { close_button_size.width(), close_button_size.height()); } + if (throbber_) { + throbber_->SetBounds( + insets.left(), insets.top(), + std::min(throbber_size.width(), width()), + throbber_size.height()); + } + int top_height = insets.top(); - if (title_size.height() > 0 || close_button_size.height() > 0) - top_height += std::max(title_size.height(), close_button_size.height()) + - kTitleContentPadding; + if (title_size.height() > 0 || + close_button_size.height() > 0 || + throbber_size.height() > 0) { + top_height += kTitleContentPadding + std::max( + std::max(title_size.height(), close_button_size.height()), + throbber_size.height()); + } client_view_bounds_.SetRect(insets.left(), top_height, std::max(0, width() - insets.width()), std::max(0, height() - top_height - insets.bottom())); @@ -177,9 +215,8 @@ void BubbleFrameView::Paint(gfx::Canvas* canvas) { void BubbleFrameView::ButtonPressed(views::Button* sender, const views::Event& event) { - if (close_button_ != NULL && sender == close_button_) { + if (close_button_ != NULL && sender == close_button_) frame_->Close(); - } } } // namespace chromeos diff --git a/chrome/browser/chromeos/frame/bubble_frame_view.h b/chrome/browser/chromeos/frame/bubble_frame_view.h index 7ebb29e..dd32530 100644 --- a/chrome/browser/chromeos/frame/bubble_frame_view.h +++ b/chrome/browser/chromeos/frame/bubble_frame_view.h @@ -52,6 +52,9 @@ class BubbleFrameView : public views::NonClientFrameView, virtual void ButtonPressed(views::Button* sender, const views::Event& event); + void StartThrobber(); + void StopThrobber(); + private: // The window that owns this view. views::Window* frame_; @@ -68,6 +71,9 @@ class BubbleFrameView : public views::NonClientFrameView, // Close button for STYLE_XBAR case. views::ImageButton* close_button_; + // Throbber is optional. Employed by STYLE_THROBBER. + views::Throbber* throbber_; + DISALLOW_COPY_AND_ASSIGN(BubbleFrameView); }; diff --git a/chrome/browser/chromeos/frame/bubble_window.h b/chrome/browser/chromeos/frame/bubble_window.h index fca4805..a3b313e 100644 --- a/chrome/browser/chromeos/frame/bubble_window.h +++ b/chrome/browser/chromeos/frame/bubble_window.h @@ -14,6 +14,7 @@ class Rect; } namespace views { +class Throbber; class WindowDelegate; } @@ -24,7 +25,8 @@ class BubbleWindow : public views::WindowGtk { public: enum Style { STYLE_GENERIC = 0, // Default style. - STYLE_XBAR = 1 << 0 // Show close button at the top right (left for RTL). + STYLE_XBAR = 1 << 0, // Show close button at the top right (left for RTL). + STYLE_THROBBER = 1 << 1 // Show throbber for slow rendering. }; static views::Window* Create(gfx::NativeWindow parent, @@ -39,8 +41,6 @@ class BubbleWindow : public views::WindowGtk { // Overidden from views::WindowGtk: virtual void Init(GtkWindow* parent, const gfx::Rect& bounds); - - Style style_; }; } // namespace chromeos |