Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1871)

Unified Diff: ash/wm/overview/window_selector_item.cc

Issue 331643004: Update the window labels if they change in overview mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed Sky's comments Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ash/wm/overview/window_selector_item.cc
diff --git a/ash/wm/overview/window_selector_item.cc b/ash/wm/overview/window_selector_item.cc
index 7b0d872a9462a88a69efe6caccffec70ff599741..7c6663008f235c2f20227dc147eec51cad1dc163 100644
--- a/ash/wm/overview/window_selector_item.cc
+++ b/ash/wm/overview/window_selector_item.cc
@@ -73,42 +73,12 @@ static const int kVerticalShadowOffset = 1;
// Amount of blur applied to the label shadow
static const int kShadowBlur = 10;
-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.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
- params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
- params.parent =
- Shell::GetContainer(root_window, ash::kShellWindowId_OverlayContainer);
- params.accept_events = false;
- params.visible_on_all_workspaces = true;
- widget->set_focus_on_creation(false);
- widget->Init(params);
- views::Label* label = new views::Label;
- label->SetEnabledColor(kLabelColor);
- label->SetBackgroundColor(kLabelBackground);
- label->set_shadows(gfx::ShadowValues(1, gfx::ShadowValue(
- gfx::Point(0, kVerticalShadowOffset), kShadowBlur, kLabelShadow)));
- ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
- label->SetFontList(bundle.GetFontList(ui::ResourceBundle::BoldFont));
- label->SetText(title);
- views::BoxLayout* layout = new views::BoxLayout(views::BoxLayout::kVertical,
- 0,
- kVerticalLabelPadding,
- 0);
- label->SetLayoutManager(layout);
- widget->SetContentsView(label);
- widget->Show();
- return widget;
-}
-
const int WindowSelectorItem::kFadeInMilliseconds = 80;
WindowSelectorItem::WindowSelectorItem()
: root_window_(NULL),
- in_bounds_update_(false) {
+ in_bounds_update_(false),
+ window_label_view_(NULL) {
Nina 2014/06/25 19:54:40 This is so that the tests fail gracefully if, for
}
WindowSelectorItem::~WindowSelectorItem() {
@@ -141,7 +111,6 @@ void WindowSelectorItem::SetBounds(aura::Window* root_window,
}
activate_window_button_->SetBounds(target_bounds);
- // TODO(nsatragno): Handle window title updates.
UpdateWindowLabels(target_bounds, root_window, animate);
gfx::Rect inset_bounds(target_bounds);
@@ -170,6 +139,11 @@ void WindowSelectorItem::ButtonPressed(views::Button* sender,
views::Widget::GetWidgetForNativeView(SelectionWindow())->Close();
}
+void WindowSelectorItem::OnWindowTitleChanged(aura::Window* window) {
+ if (window == SelectionWindow())
+ window_label_view_->SetText(window->title());
+}
+
void WindowSelectorItem::UpdateCloseButtonBounds(aura::Window* root_window,
bool animate) {
gfx::RectF align_bounds(ScreenUtil::ConvertRectFromScreen(
@@ -252,12 +226,10 @@ void WindowSelectorItem::UpdateWindowLabels(const gfx::Rect& window_bounds,
}
if (!window_label_) {
- window_label_.reset(CreateWindowLabel(root_window,
- SelectionWindow()->title()));
- label_bounds.set_height(window_label_->
- GetContentsView()->GetPreferredSize().height());
- label_bounds.set_y(label_bounds.y() - window_label_->
- GetContentsView()->GetPreferredSize().height());
+ CreateWindowLabel(SelectionWindow()->title());
+ label_bounds.set_height(window_label_view_->GetPreferredSize().height());
+ label_bounds.set_y(label_bounds.y() - window_label_view_->
+ GetPreferredSize().height());
window_label_->GetNativeWindow()->SetBounds(label_bounds);
ui::Layer* layer = window_label_->GetNativeWindow()->layer();
@@ -294,4 +266,34 @@ void WindowSelectorItem::UpdateWindowLabels(const gfx::Rect& window_bounds,
}
}
+void WindowSelectorItem::CreateWindowLabel(const base::string16& title) {
+ window_label_.reset(new views::Widget);
+ views::Widget::InitParams params;
+ params.type = views::Widget::InitParams::TYPE_POPUP;
+ params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+ params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
+ params.parent =
+ Shell::GetContainer(root_window_, ash::kShellWindowId_OverlayContainer);
+ params.accept_events = false;
+ params.visible_on_all_workspaces = true;
+ window_label_->set_focus_on_creation(false);
+ window_label_->Init(params);
+ window_label_view_ = new views::Label;
+ window_label_view_->SetEnabledColor(kLabelColor);
+ window_label_view_->SetBackgroundColor(kLabelBackground);
+ window_label_view_->set_shadows(gfx::ShadowValues(1, gfx::ShadowValue(
+ gfx::Point(0, kVerticalShadowOffset), kShadowBlur, kLabelShadow)));
+ ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
+ window_label_view_->SetFontList(
+ bundle.GetFontList(ui::ResourceBundle::BoldFont));
+ window_label_view_->SetText(title);
+ views::BoxLayout* layout = new views::BoxLayout(views::BoxLayout::kVertical,
+ 0,
+ kVerticalLabelPadding,
+ 0);
+ window_label_view_->SetLayoutManager(layout);
+ window_label_->SetContentsView(window_label_view_);
+ window_label_->Show();
+}
+
} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698