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

Unified Diff: athena/activity/activity_frame_view.cc

Issue 375143002: Use Widget frame and WidgetDelegate in ActvityWidget (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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/activity_view_manager_impl.cc » ('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
new file mode 100644
index 0000000000000000000000000000000000000000..0b0e64fa35d7c2b986f1e34ca43808925ff223c0
--- /dev/null
+++ b/athena/activity/activity_frame_view.cc
@@ -0,0 +1,101 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "athena/activity/activity_frame_view.h"
+
+#include <algorithm>
+#include <vector>
+
+#include "athena/activity/public/activity_view_model.h"
+#include "ui/views/background.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"
+
+namespace athena {
+
+////////////////////////////////////////////////////////////////////////////////
+// FrameViewAthena, public:
+
+// 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);
+ const gfx::FontList& font_list = title_->font_list();
+ title_->SetFontList(font_list.Derive(1, gfx::Font::BOLD));
+ title_->SetEnabledColor(SK_ColorBLACK);
+ AddChildView(title_);
+}
+
+ActivityFrameView::~ActivityFrameView() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// ActivityFrameView, views::NonClientFrameView overrides:
+
+gfx::Rect ActivityFrameView::GetBoundsForClientView() const {
+ gfx::Rect client_bounds = bounds();
+ client_bounds.Inset(0, NonClientTopBorderHeight(), 0, 0);
+ return client_bounds;
+}
+
+gfx::Rect ActivityFrameView::GetWindowBoundsForClientBounds(
+ const gfx::Rect& client_bounds) const {
+ gfx::Rect window_bounds = client_bounds;
+ window_bounds.Inset(0, -NonClientTopBorderHeight(), 0, 0);
+ return window_bounds;
+}
+
+int ActivityFrameView::NonClientHitTest(const gfx::Point& point) {
+ return 0;
+}
+
+void ActivityFrameView::GetWindowMask(const gfx::Size& size,
+ gfx::Path* window_mask) {
+}
+
+void ActivityFrameView::ResetWindowControls() {
+}
+
+void ActivityFrameView::UpdateWindowIcon() {
+}
+
+void ActivityFrameView::UpdateWindowTitle() {
+ SkColor bgcolor = view_model_->GetRepresentativeColor();
+ title_->set_background(views::Background::CreateSolidBackground(bgcolor));
+ title_->SetBackgroundColor(bgcolor);
+ title_->SetText(frame_->widget_delegate()->GetWindowTitle());
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// 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());
+ return frame_->non_client_view()
+ ->GetWindowBoundsForClientBounds(bounds)
+ .size();
+}
+
+const char* ActivityFrameView::GetClassName() const {
+ return kViewClassName;
+}
+
+void ActivityFrameView::Layout() {
+ title_->SetBounds(0, 0, width(), NonClientTopBorderHeight());
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// ActivityFrameView, private:
+
+int ActivityFrameView::NonClientTopBorderHeight() const {
+ return frame_->IsFullscreen() ? 0 : title_->GetPreferredSize().height();
+}
+
+} // namespace ash
« no previous file with comments | « athena/activity/activity_frame_view.h ('k') | athena/activity/activity_view_manager_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698