1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "athena/main/athena_frame_view.h"
7 #include "base/strings/utf_string_conversions.h"
8 #include "third_party/skia/include/core/SkColor.h"
9 #include "ui/base/hit_test.h"
10 #include "ui/views/background.h"
11 #include "ui/views/controls/label.h"
12 #include "ui/views/view.h"
13 #include "ui/views/widget/widget.h"
14 #include "ui/views/widget/widget_delegate.h"
15 #include "ui/views/window/client_view.h"
20 // The height of the top border necessary to display the title without the icon.
21 const int kDefaultTitleHeight
= 13;
23 // The default background color for athena's frame. This is placeholder.
24 const SkColor kDefaultTitleBackground
= 0xFFcccccc;
29 const char AthenaFrameView::kViewClassName
[] = "AthenaFrameView";
31 AthenaFrameView::AthenaFrameView(views::Widget
* frame
) : frame_(frame
) {
33 views::Background::CreateSolidBackground(kDefaultTitleBackground
));
37 AthenaFrameView::~AthenaFrameView() {
40 gfx::Rect
AthenaFrameView::GetBoundsForClientView() const {
41 gfx::Rect client_bounds
= bounds();
42 client_bounds
.Inset(NonClientBorderInsets());
46 gfx::Rect
AthenaFrameView::GetWindowBoundsForClientBounds(
47 const gfx::Rect
& client_bounds
) const {
48 gfx::Rect window_bounds
= client_bounds
;
49 window_bounds
.Inset(-NonClientBorderInsets());
53 int AthenaFrameView::NonClientHitTest(const gfx::Point
& point
) {
54 if (!bounds().Contains(point
))
56 int client_hit_test
= frame_
->client_view()->NonClientHitTest(point
);
57 if (client_hit_test
!= HTNOWHERE
)
58 return client_hit_test
;
60 GetHTComponentForFrame(point
, 0, NonClientBorderThickness(), 0, 0, false);
61 return (window_hit_test
== HTNOWHERE
) ? HTCAPTION
: client_hit_test
;
64 gfx::Size
AthenaFrameView::GetPreferredSize() const {
65 gfx::Size pref
= frame_
->client_view()->GetPreferredSize();
66 gfx::Rect
bounds(0, 0, pref
.width(), pref
.height());
67 return frame_
->non_client_view()
68 ->GetWindowBoundsForClientBounds(bounds
)
72 const char* AthenaFrameView::GetClassName() const {
73 return kViewClassName
;
76 gfx::Insets
AthenaFrameView::NonClientBorderInsets() const {
77 int border_thickness
= NonClientBorderThickness();
78 return gfx::Insets(NonClientTopBorderHeight(),
84 int AthenaFrameView::NonClientBorderThickness() const {
88 int AthenaFrameView::NonClientTopBorderHeight() const {
89 return kDefaultTitleHeight
;