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

Unified Diff: athena/activity/activity_frame_view.cc

Issue 518673007: Make activities have a thick border when in overview mode part 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@athena_overview2
Patch Set: Rebased Created 6 years, 3 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
« no previous file with comments | « athena/activity/activity_frame_view.h ('k') | athena/activity/public/activity_view_model.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: athena/activity/activity_frame_view.cc
diff --git a/athena/activity/activity_frame_view.cc b/athena/activity/activity_frame_view.cc
index 83b93885b5fcc64482e0c51d0bd3b55de8482d8d..e4ff4131d10947bde6ce12b2aa45de76fbfe4b90 100644
--- a/athena/activity/activity_frame_view.cc
+++ b/athena/activity/activity_frame_view.cc
@@ -4,64 +4,97 @@
#include "athena/activity/activity_frame_view.h"
-#include <algorithm>
-#include <vector>
-
#include "athena/activity/public/activity_view_model.h"
+#include "athena/wm/public/window_manager.h"
+#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/hit_test.h"
+#include "ui/gfx/canvas.h"
+#include "ui/gfx/image/image_skia.h"
#include "ui/views/background.h"
-#include "ui/views/border.h"
+#include "ui/views/controls/image_view.h"
#include "ui/views/controls/label.h"
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"
+#include "ui/views/window/client_view.h"
namespace athena {
+namespace {
+
+// The icon size.
+const int kIconSize = 32;
+
+// The distance between the icon and the title when the icon is visible.
+const int kIconTitleSpacing = 5;
+
+// The height of the top border necessary to display the title without the icon.
+const int kDefaultTitleHeight = 25;
-////////////////////////////////////////////////////////////////////////////////
-// FrameViewAthena, public:
+// The height of the top border in overview mode.
+const int kOverviewTitleHeight = 55;
+
+// The height of the top border for fullscreen and frameless activities in
+// overview mode.
+const int kOverviewShortTitleHeight = 30;
+
+// The thickness of the left, right and bottom borders in overview mode.
+const int kOverviewBorderThickness = 5;
+
+} // namespace
// static
const char ActivityFrameView::kViewClassName[] = "ActivityFrameView";
ActivityFrameView::ActivityFrameView(views::Widget* frame,
ActivityViewModel* view_model)
- : frame_(frame), view_model_(view_model), title_(new views::Label) {
- title_->SetHorizontalAlignment(gfx::ALIGN_CENTER);
+ : frame_(frame),
+ view_model_(view_model),
+ title_(new views::Label),
+ icon_(new views::ImageView),
+ in_overview_(false) {
title_->SetEnabledColor(SkColorSetA(SK_ColorBLACK, 0xe5));
- title_->SetBorder(views::Border::CreateSolidSidedBorder(0, 0, 1, 0,
- SkColorSetA(SK_ColorGRAY, 0x7f)));
+
+ SkBitmap bitmap;
+ bitmap.allocN32Pixels(kIconSize, kIconSize);
+ bitmap.eraseARGB(255, 0, 255, 0);
+ icon_->SetImage(gfx::ImageSkia::CreateFrom1xBitmap(bitmap));
+
AddChildView(title_);
+ AddChildView(icon_);
+
+ SkColor bgcolor = view_model_->GetRepresentativeColor();
+ set_background(views::Background::CreateSolidBackground(bgcolor));
UpdateWindowTitle();
+
+ WindowManager::GetInstance()->AddObserver(this);
}
ActivityFrameView::~ActivityFrameView() {
+ WindowManager::GetInstance()->RemoveObserver(this);
}
-////////////////////////////////////////////////////////////////////////////////
-// ActivityFrameView, views::NonClientFrameView overrides:
-
gfx::Rect ActivityFrameView::GetBoundsForClientView() const {
gfx::Rect client_bounds = bounds();
- if (view_model_->UsesFrame())
- client_bounds.Inset(0, NonClientTopBorderHeight(), 0, 0);
+ client_bounds.Inset(NonClientBorderInsets());
return client_bounds;
}
gfx::Rect ActivityFrameView::GetWindowBoundsForClientBounds(
const gfx::Rect& client_bounds) const {
gfx::Rect window_bounds = client_bounds;
- if (view_model_->UsesFrame())
- window_bounds.Inset(0, -NonClientTopBorderHeight(), 0, 0);
+ window_bounds.Inset(-NonClientBorderInsets());
return window_bounds;
}
int ActivityFrameView::NonClientHitTest(const gfx::Point& point) {
- if (frame_->IsFullscreen())
- return 0;
- if (title_->bounds().Contains(point))
- return HTCAPTION;
- return 0;
+ if (!bounds().Contains(point))
+ return HTNOWHERE;
+ int client_hit_test = frame_->client_view()->NonClientHitTest(point);
+ if (client_hit_test != HTNOWHERE)
+ return client_hit_test;
+ int window_hit_test =
+ GetHTComponentForFrame(point, 0, NonClientBorderThickness(), 0, 0, false);
+ return (window_hit_test == HTNOWHERE) ? HTCAPTION : client_hit_test;
}
void ActivityFrameView::GetWindowMask(const gfx::Size& size,
@@ -85,11 +118,9 @@ void ActivityFrameView::UpdateWindowTitle() {
if (!view_model_->UsesFrame())
return;
title_->SetText(frame_->widget_delegate()->GetWindowTitle());
+ Layout();
}
-////////////////////////////////////////////////////////////////////////////////
-// ActivityFrameView, views::View overrides:
-
gfx::Size ActivityFrameView::GetPreferredSize() const {
gfx::Size pref = frame_->client_view()->GetPreferredSize();
gfx::Rect bounds(0, 0, pref.width(), pref.height());
@@ -103,15 +134,83 @@ const char* ActivityFrameView::GetClassName() const {
}
void ActivityFrameView::Layout() {
- title_->SetBounds(0, 0, width(), NonClientTopBorderHeight());
+ if (frame_->IsFullscreen() || !view_model_->UsesFrame()) {
+ title_->SetVisible(false);
+ icon_->SetVisible(false);
+ return;
+ }
+
+ title_->SetVisible(true);
+ icon_->SetVisible(in_overview_);
+
+ gfx::Size preferred_title_size = title_->GetPreferredSize();
+ int top_height = NonClientTopBorderHeight();
+ int title_x = 0;
+ if (in_overview_) {
+ int edge = (top_height - kIconSize) / 2;
+ icon_->SetBounds(edge, edge, kIconSize, kIconSize);
+
+ title_x = icon_->bounds().right() + kIconTitleSpacing;
+ } else {
+ title_x = (width() - preferred_title_size.width()) / 2;
+ }
+
+ title_->SetBounds(title_x,
+ (top_height - preferred_title_size.height()) / 2,
+ preferred_title_size.width(),
+ preferred_title_size.height());
}
-////////////////////////////////////////////////////////////////////////////////
-// ActivityFrameView, private:
+void ActivityFrameView::OnPaintBackground(gfx::Canvas* canvas) {
+ View::OnPaintBackground(canvas);
+
+ // Paint a border around the client view.
+ gfx::Rect border_bounds = GetLocalBounds();
+ border_bounds.Inset(NonClientBorderInsets());
+ border_bounds.Inset(-1, -1, 0, 0);
+ canvas->DrawRect(border_bounds, SkColorSetA(SK_ColorGRAY, 0x7f));
+}
+
+void ActivityFrameView::OnOverviewModeEnter() {
+ view_model_->PrepareContentsForOverview();
+ in_overview_ = true;
+ InvalidateLayout();
+ frame_->client_view()->InvalidateLayout();
+ frame_->GetRootView()->Layout();
+ SchedulePaint();
+}
+
+void ActivityFrameView::OnOverviewModeExit() {
+ in_overview_ = false;
+ InvalidateLayout();
+ frame_->client_view()->InvalidateLayout();
+ frame_->GetRootView()->Layout();
+ SchedulePaint();
+ view_model_->ResetContentsView();
+}
+
+void ActivityFrameView::OnSplitViewModeEnter() {
+}
+
+void ActivityFrameView::OnSplitViewModeExit() {
+}
+
+gfx::Insets ActivityFrameView::NonClientBorderInsets() const {
+ int border_thickness = NonClientBorderThickness();
+ return gfx::Insets(NonClientTopBorderHeight(),
+ border_thickness,
+ border_thickness,
+ border_thickness);
+}
+
+int ActivityFrameView::NonClientBorderThickness() const {
+ return in_overview_ ? kOverviewBorderThickness : 0;
+}
int ActivityFrameView::NonClientTopBorderHeight() const {
- const int kDefaultTitleHeight = 25;
- return frame_->IsFullscreen() ? 0 : kDefaultTitleHeight;
+ if (frame_->IsFullscreen() || !view_model_->UsesFrame())
+ return in_overview_ ? kOverviewShortTitleHeight : 0;
+ return in_overview_ ? kOverviewTitleHeight : kDefaultTitleHeight;
}
-} // namespace ash
+} // namespace athena
« no previous file with comments | « athena/activity/activity_frame_view.h ('k') | athena/activity/public/activity_view_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698