Chromium Code Reviews| Index: ash/wm/overview/window_selector_window.cc |
| diff --git a/ash/wm/overview/window_selector_window.cc b/ash/wm/overview/window_selector_window.cc |
| index 942edf41efddcbb4e92a1f439d7e138dd449acaa..3f9a06b7b67d038f4d1f0ba893895973ab710f86 100644 |
| --- a/ash/wm/overview/window_selector_window.cc |
| +++ b/ash/wm/overview/window_selector_window.cc |
| @@ -14,12 +14,42 @@ |
| #include "ui/gfx/rect.h" |
| #include "ui/gfx/transform.h" |
| #include "ui/views/controls/button/image_button.h" |
| +#include "ui/views/controls/label.h" |
| #include "ui/views/widget/widget.h" |
| namespace ash { |
| namespace { |
| +// Foreground label color. Right now it's white |
| +static const int kLabelColor = 0xFFFFFFFF; |
|
flackr
2014/04/10 15:03:05
Use SK_ColorWHITE, the type should be SkColor
|
| + |
| +// Background label color. Right now it's black. |
| +static const int kLabelBackground = 0x000000; |
|
flackr
2014/04/10 15:03:05
Ditto, use SkColor type and color constant SK_Colo
|
| + |
| +views::Widget* CreateWindowLabel(aura::Window* root_window, |
| + const base::string16 title) { |
| + views::Widget* widget = new views::Widget; |
| + views::Widget::InitParams params; |
| + params.type = views::Widget::InitParams::TYPE_POPUP; |
| + params.can_activate = false; |
| + params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| + params.opacity = views::Widget::InitParams::OPAQUE_WINDOW; |
| + params.parent = |
| + Shell::GetContainer(root_window, ash::kShellWindowId_OverlayContainer); |
| + widget->set_focus_on_creation(false); |
| + widget->Init(params); |
| + views::Label* label = new views::Label; |
| + label->SetEnabledColor(kLabelColor); |
| + label->SetBackgroundColor(kLabelBackground); |
| + ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| + label->SetFontList(bundle.GetFontList(ui::ResourceBundle::BoldFont)); |
| + label->SetText(title); |
| + widget->SetContentsView(label); |
| + widget->Show(); |
| + return widget; |
| +} |
| + |
| views::Widget* CreateCloseWindowButton(aura::Window* root_window, |
| views::ButtonListener* listener) { |
| views::Widget* widget = new views::Widget; |
| @@ -102,11 +132,14 @@ void WindowSelectorWindow::SetItemBounds(aura::Window* root_window, |
| const gfx::Rect& target_bounds, |
| bool animate) { |
| gfx::Rect src_rect = transform_window_.GetBoundsInScreen(); |
| - set_bounds(ScopedTransformOverviewWindow:: |
| - ShrinkRectToFitPreservingAspectRatio(src_rect, target_bounds)); |
| + const gfx::Rect window_bounds = |
| + ScopedTransformOverviewWindow:: |
| + ShrinkRectToFitPreservingAspectRatio(src_rect, target_bounds); |
| + set_bounds(window_bounds); |
| transform_window_.SetTransform(root_window, |
| ScopedTransformOverviewWindow::GetTransformForRect(src_rect, bounds()), |
| animate); |
| + UpdateWindowLabels(window_bounds); |
| UpdateCloseButtonBounds(); |
| } |
| @@ -116,6 +149,19 @@ void WindowSelectorWindow::ButtonPressed(views::Button* sender, |
| transform_window_.window())->Close(); |
| } |
| +void WindowSelectorWindow::UpdateWindowLabels(const gfx::Rect& window_bounds) { |
| + // TODO Animate the labels with some cute effects |
|
flackr
2014/04/10 15:03:05
TODO(nsatragno). That being said, given everything
|
| + base::string16 window_title = transform_window_.window()->title(); |
|
flackr
2014/04/10 15:03:05
nit, move this to the scope where it's used, i.e.
|
| + if (!window_label_) |
| + window_label_.reset(CreateWindowLabel(GetRootWindow(), window_title)); |
| + // TODO use constant for box height? Calculate dynamically? |
|
flackr
2014/04/10 15:03:05
Seems like it already uses a constant. That being
|
| + gfx::Rect label_bounds(window_bounds.x(), |
| + window_bounds.y() + window_bounds.height(), |
| + window_bounds.width(), |
| + 40); |
|
flackr
2014/04/10 15:03:05
nit: this height should be defined as a constant.
|
| + window_label_->GetNativeWindow()->SetBounds(label_bounds); |
| +} |
| + |
| void WindowSelectorWindow::UpdateCloseButtonBounds() { |
| aura::Window* root_window = GetRootWindow(); |
| gfx::Rect align_bounds(bounds()); |