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

Unified Diff: chrome/browser/ui/views/apps/glass_app_window_frame_view.cc

Issue 213743017: Remove title and icon from chrome apps native style title bars. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nicer Created 6 years, 9 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: chrome/browser/ui/views/apps/glass_app_window_frame_view.cc
diff --git a/chrome/browser/ui/views/apps/glass_app_window_frame_view.cc b/chrome/browser/ui/views/apps/glass_app_window_frame_view.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2a61e55f9563d9b0655ed8b5d22d517d0a4af894
--- /dev/null
+++ b/chrome/browser/ui/views/apps/glass_app_window_frame_view.cc
@@ -0,0 +1,129 @@
+// 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 "chrome/browser/ui/views/apps/glass_app_window_frame_view.h"
+
+#include "apps/ui/native_app_window.h"
+#include "ui/base/hit_test.h"
+#include "ui/views/widget/widget.h"
+#include "ui/views/widget/widget_delegate.h"
+
+namespace {
+
+const int kResizeAreaCornerSize = 16;
+
+} // namespace
+
+namespace apps {
+
+const char GlassAppWindowFrameView::kViewClassName[] =
+ "browser/ui/views/extensions/GlassAppWindowFrameView";
tapted 2014/04/03 19:40:24 should this be ui/views/apps/..?
benwells 2014/04/04 06:50:43 Done.
+
+GlassAppWindowFrameView::GlassAppWindowFrameView(NativeAppWindow* window,
+ views::Widget* widget)
+ : window_(window), widget_(widget) {}
+
+GlassAppWindowFrameView::~GlassAppWindowFrameView() {}
+
+gfx::Insets GlassAppWindowFrameView::GetGlassInsets() const {
+ // If 1 is not subtraced, they are too big. There is possibly some reason
tapted 2014/04/03 19:40:24 nit: subtraced -> subtracted
benwells 2014/04/04 06:50:43 Done.
+ // for that.
+ int caption_height =
+ GetSystemMetrics(SM_CYSMICON) + GetSystemMetrics(SM_CYSIZEFRAME) - 1;
+ int frame_size = GetSystemMetrics(SM_CXSIZEFRAME) - 1;
tapted 2014/04/03 19:40:24 Can GetSystemMetrics ever fail/ return 0?
benwells 2014/04/04 06:50:43 According to MSDN if it fails it will return 0. It
tapted 2014/04/04 16:15:19 cool - wild conjecture: maybe this is the explanat
+ return gfx::Insets(
+ frame_size + caption_height, frame_size, frame_size, frame_size);
+}
+
+gfx::Rect GlassAppWindowFrameView::GetBoundsForClientView() const {
+ if (widget_->IsFullscreen())
+ return bounds();
+
+ gfx::Insets insets = GetGlassInsets();
+ return gfx::Rect(insets.left(),
+ insets.top(),
+ std::max(0, width() - insets.left() - insets.right()),
+ std::max(0, height() - insets.top() - insets.bottom()));
+}
+
+gfx::Rect GlassAppWindowFrameView::GetWindowBoundsForClientBounds(
+ const gfx::Rect& client_bounds) const {
+ gfx::Insets insets = GetGlassInsets();
+ return gfx::Rect(client_bounds.x() - insets.left(),
+ client_bounds.y() - insets.top(),
+ client_bounds.width() + insets.left() + insets.right(),
+ client_bounds.height() + insets.top() + insets.bottom());
+}
+
+int GlassAppWindowFrameView::NonClientHitTest(const gfx::Point& point) {
+ if (widget_->IsFullscreen())
+ return HTCLIENT;
tapted 2014/04/03 19:40:24 This API isn't too familiar to me, so this might b
benwells 2014/04/04 06:50:43 It should do. This function is only called if the
+
+ if (!bounds().Contains(point))
+ return HTNOWHERE;
+
+ // Check the frame first, as we allow a small area overlapping the contents
+ // to be used for resize handles.
+ bool can_ever_resize = widget_->widget_delegate()
+ ? widget_->widget_delegate()->CanResize()
+ : false;
+ // Don't allow overlapping resize handles when the window is maximized or
+ // fullscreen, as it can't be resized in those states.
+ int resize_border = GetSystemMetrics(SM_CXSIZEFRAME);
+ int frame_component =
+ GetHTComponentForFrame(point,
+ resize_border,
+ resize_border,
+ kResizeAreaCornerSize - resize_border,
+ kResizeAreaCornerSize - resize_border,
+ can_ever_resize);
+ if (frame_component != HTNOWHERE)
+ return frame_component;
+
+ int client_component = widget_->client_view()->NonClientHitTest(point);
+ if (client_component != HTNOWHERE)
+ return client_component;
+
+ // Caption is a safe default.
+ return HTCAPTION;
+}
+
+void GlassAppWindowFrameView::GetWindowMask(const gfx::Size& size,
+ gfx::Path* window_mask) {
+ // We got nothing to say about no window mask.
+}
+
+gfx::Size GlassAppWindowFrameView::GetPreferredSize() {
+ gfx::Size pref = widget_->client_view()->GetPreferredSize();
+ gfx::Rect bounds(0, 0, pref.width(), pref.height());
+ return widget_->non_client_view()
+ ->GetWindowBoundsForClientBounds(bounds)
+ .size();
+}
+
+const char* GlassAppWindowFrameView::GetClassName() const {
+ return kViewClassName;
+}
+
+gfx::Size GlassAppWindowFrameView::GetMinimumSize() {
+ gfx::Size min_size = widget_->client_view()->GetMinimumSize();
+ gfx::Rect client_bounds = GetBoundsForClientView();
+ min_size.Enlarge(0, client_bounds.y());
tapted 2014/04/03 19:40:24 why just the y? (should x always be 0?)
tapted 2014/04/04 16:15:19 there was one last question :). But I think I grok
+ return min_size;
+}
+
+gfx::Size GlassAppWindowFrameView::GetMaximumSize() {
+ gfx::Size max_size = widget_->client_view()->GetMaximumSize();
+
+ // Add to the client maximum size the height of any title bar and borders.
+ gfx::Size client_size = GetBoundsForClientView().size();
+ if (max_size.width())
+ max_size.Enlarge(width() - client_size.width(), 0);
+ if (max_size.height())
+ max_size.Enlarge(0, height() - client_size.height());
+
+ return max_size;
+}
+
+} // namespace apps

Powered by Google App Engine
This is Rietveld 408576698