summaryrefslogtreecommitdiffstats
path: root/ash/wm/panel_frame_view.cc
blob: e0d93e2fac23172fcec1587aeeafdb207833ed34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// Copyright (c) 2012 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 "ash/wm/frame_painter.h"
#include "ash/wm/panel_frame_view.h"
#include "grit/ui_resources.h"
#include "grit/ui_strings.h"  // Accessibility names
#include "third_party/skia/include/core/SkPaint.h"
#include "ui/base/animation/throb_animation.h"
#include "ui/base/cursor/cursor.h"
#include "ui/base/hit_test.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/font.h"
#include "ui/gfx/image/image.h"
#include "ui/views/controls/button/image_button.h"
#include "ui/views/widget/native_widget_aura.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"

namespace ash {

PanelFrameView::PanelFrameView(views::Widget* frame)
    : frame_painter_(new FramePainter) {
  close_button_ = new views::ImageButton(this);
  close_button_->SetAccessibleName(
      l10n_util::GetStringUTF16(IDS_APP_ACCNAME_CLOSE));
  AddChildView(close_button_);

  minimize_button_ = new views::ImageButton(this);
  minimize_button_->SetAccessibleName(
      l10n_util::GetStringUTF16(IDS_APP_ACCNAME_MINIMIZE));
  AddChildView(minimize_button_);

  frame_painter_->Init(frame, NULL, minimize_button_, close_button_,
                       FramePainter::SIZE_BUTTON_MINIMIZES);
}

PanelFrameView::~PanelFrameView() {
}

void PanelFrameView::Layout() {
  frame_painter_->LayoutHeader(this, true);
}

void PanelFrameView::ResetWindowControls() {
  NOTIMPLEMENTED();
}

void PanelFrameView::UpdateWindowIcon() {
  NOTIMPLEMENTED();
}

void PanelFrameView::GetWindowMask(const gfx::Size&, gfx::Path*) {
  // Nothing.
}

int PanelFrameView::NonClientHitTest(const gfx::Point& point) {
  return frame_painter_->NonClientHitTest(this, point);
}

void PanelFrameView::OnPaint(gfx::Canvas* canvas) {
  bool paint_as_active = ShouldPaintAsActive();
  int theme_image_id = paint_as_active ? IDR_AURA_WINDOW_HEADER_BASE_ACTIVE :
      IDR_AURA_WINDOW_HEADER_BASE_INACTIVE;
  frame_painter_->PaintHeader(
      this,
      canvas,
      paint_as_active ? FramePainter::ACTIVE : FramePainter::INACTIVE,
      theme_image_id,
      NULL);
  frame_painter_->PaintHeaderContentSeparator(this, canvas);
}

gfx::Rect PanelFrameView::GetBoundsForClientView() const {
  return frame_painter_->GetBoundsForClientView(
      close_button_->bounds().bottom(),
      bounds());
}

gfx::Rect PanelFrameView::GetWindowBoundsForClientBounds(
    const gfx::Rect& client_bounds) const {
  return frame_painter_->GetWindowBoundsForClientBounds(
      close_button_->bounds().bottom(), client_bounds);
}

void PanelFrameView::ButtonPressed(views::Button* sender,
                                   const views::Event& event) {
  if (sender == close_button_)
    GetWidget()->Close();
}

}  // namespace ash