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

Unified Diff: components/mus/example/wm/non_client_frame_view_impl.cc

Issue 1419793006: Makes windowmanager draw non-client area (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add include Created 5 years, 1 month 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: components/mus/example/wm/non_client_frame_view_impl.cc
diff --git a/components/mus/example/wm/non_client_frame_view_impl.cc b/components/mus/example/wm/non_client_frame_view_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7ca7a2231265a71fc18ff1480ace1a1cf1868e2f
--- /dev/null
+++ b/components/mus/example/wm/non_client_frame_view_impl.cc
@@ -0,0 +1,58 @@
+// Copyright 2015 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 "components/mus/example/wm/non_client_frame_view_impl.h"
+
+#include "components/mus/public/cpp/window.h"
+#include "ui/compositor/paint_recorder.h"
+#include "ui/gfx/canvas.h"
+
+NonClientFrameViewImpl::NonClientFrameViewImpl(mus::Window* window)
+ : window_(window) {
+ window_->AddObserver(this);
+}
+
+NonClientFrameViewImpl::~NonClientFrameViewImpl() {
+ if (window_)
+ window_->RemoveObserver(this);
+}
+
+gfx::Rect NonClientFrameViewImpl::GetBoundsForClientView() const {
+ gfx::Rect result(GetLocalBounds());
+ result.Inset(window_->client_area());
+ return result;
+}
+
+void NonClientFrameViewImpl::OnPaint(gfx::Canvas* canvas) {
+ canvas->Save();
+ CustomFrameView::OnPaint(canvas);
+ canvas->Restore();
+
+ // The client app draws the client area. Make ours totally transparent so
+ // we only see the client apps client area.
+ canvas->FillRect(GetBoundsForClientView(), SK_ColorBLACK,
+ SkXfermode::kSrc_Mode);
+}
+
+void NonClientFrameViewImpl::PaintChildren(const ui::PaintContext& context) {
+ CustomFrameView::PaintChildren(context);
+
+ // The client app draws the client area. Make ours totally transparent so
+ // we only see the client apps client area.
+ ui::PaintRecorder recorder(context, size(), &paint_cache_);
+ recorder.canvas()->FillRect(GetBoundsForClientView(), SK_ColorBLACK,
+ SkXfermode::kSrc_Mode);
+}
+
+void NonClientFrameViewImpl::OnWindowClientAreaChanged(
+ mus::Window* window,
+ const gfx::Insets& old_client_area) {
+ Layout();
+ SchedulePaint();
+}
+
+void NonClientFrameViewImpl::OnWindowDestroyed(mus::Window* window) {
+ window_->RemoveObserver(this);
+ window_ = nullptr;
+}
« no previous file with comments | « components/mus/example/wm/non_client_frame_view_impl.h ('k') | components/mus/example/wm/window_manager_application.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698