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

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

Issue 231643002: Added labels under the windows in OverviewMode displaying their current name. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added blurred shadows to labels Created 6 years, 8 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 a2c25b617e9c872b1c2849209cc383ff59a14657..7ec91074259eb7f9152613109e4c1c6330909cf9 100644
--- a/ash/wm/overview/window_selector_item.cc
+++ b/ash/wm/overview/window_selector_item.cc
@@ -3,11 +3,70 @@
// found in the LICENSE file.
#include "ash/wm/overview/window_selector_item.h"
+
+#include "ash/shell.h"
+#include "ash/shell_window_ids.h"
+#include "ash/wm/overview/scoped_transform_overview_window.h"
#include "base/auto_reset.h"
+#include "base/memory/scoped_ptr.h"
+#include "third_party/skia/include/core/SkColor.h"
#include "ui/aura/window.h"
+#include "ui/base/resource/resource_bundle.h"
+#include "ui/compositor/scoped_layer_animation_settings.h"
+#include "ui/views/controls/label.h"
+#include "ui/views/layout/box_layout.h"
+#include "ui/views/widget/widget.h"
namespace ash {
+// Foreground label color.
+static const SkColor kLabelColor = SK_ColorWHITE;
+
+// Background label color.
+static const SkColor kLabelBackground = SK_ColorTRANSPARENT;
+
+// Label shadow color.
+static const SkColor kLabelShadow = SK_ColorBLACK;
+
+// Vertical padding for the label, both over and beneath it.
+static const int kVerticalLabelPadding = 20;
+
+// Label height, ie. distance from the border of the window to the label bottom.
+static const int kLabelHeight = 20;
+
+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::TRANSLUCENT_WINDOW;
+ params.parent =
+ Shell::GetContainer(root_window, ash::kShellWindowId_OverlayContainer);
+ params.accept_events = false;
+ widget->set_focus_on_creation(false);
+ widget->Init(params);
+ views::Label* label = new views::Label;
+ label->SetEnabledColor(kLabelColor);
+ label->SetBackgroundColor(kLabelBackground);
+ label->SetShadowColors(kLabelShadow, kLabelShadow);
+ label->SetShadowOffset(1, 1);
+ label->SetShadowBlur(2);
+ label->SetMirrorShadow(true);
+ 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;
+}
+
WindowSelectorItem::WindowSelectorItem()
: root_window_(NULL),
in_bounds_update_(false) {
@@ -24,6 +83,7 @@ void WindowSelectorItem::SetBounds(aura::Window* root_window,
root_window_ = root_window;
target_bounds_ = target_bounds;
SetItemBounds(root_window, target_bounds, true);
+ UpdateWindowLabels(target_bounds);
}
void WindowSelectorItem::RecomputeWindowTransforms() {
@@ -34,4 +94,50 @@ void WindowSelectorItem::RecomputeWindowTransforms() {
SetItemBounds(root_window_, target_bounds_, false);
}
+void WindowSelectorItem::UpdateWindowLabels(const gfx::Rect& window_bounds) {
+ aura::Window* root_window = GetRootWindow();
+
+ gfx::Rect label_bounds(window_bounds.x(),
+ window_bounds.y() + window_bounds.height(),
+ window_bounds.width(),
+ kLabelHeight);
+
+ // If the root window has changed, force the window label to be recreated
+ // and faded in on the new root window.
+ if (window_label_ &&
+ window_label_->GetNativeWindow()->GetRootWindow() != root_window) {
+ window_label_.reset();
+ }
+
+ if (!window_label_) {
+ window_label_.reset(CreateWindowLabel(GetRootWindow(), GetLabelName()));
+ window_label_->GetNativeWindow()->SetBounds(label_bounds);
+ ui::Layer* layer = window_label_->GetNativeWindow()->layer();
+
+ layer->SetOpacity(0);
+ layer->GetAnimator()->StopAnimating();
+
+ layer->GetAnimator()->SchedulePauseForProperties(
+ base::TimeDelta::FromMilliseconds(
+ ScopedTransformOverviewWindow::kTransitionMilliseconds),
+ ui::LayerAnimationElement::OPACITY);
+
+ ui::ScopedLayerAnimationSettings settings(layer->GetAnimator());
+ settings.SetPreemptionStrategy(
+ ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
+ settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds(
+ ScopedTransformOverviewWindow::kFadeInMilliseconds));
+ layer->SetOpacity(1);
+ } else {
+ ui::ScopedLayerAnimationSettings settings(
+ window_label_->GetNativeWindow()->layer()->GetAnimator());
+ settings.SetPreemptionStrategy(
+ ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
+ settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds(
+ ScopedTransformOverviewWindow::kTransitionMilliseconds));
+ window_label_->GetNativeWindow()->SetBounds(label_bounds);
+ }
+
+}
+
} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698