summaryrefslogtreecommitdiffstats
path: root/apps/ui/views/shell_window_frame_view.h
blob: 7fa10f546b646af4652442a44f89ab02b3dbe407 (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
// Copyright 2013 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.

#ifndef APPS_UI_VIEWS_SHELL_WINDOW_FRAME_VIEW_H_
#define APPS_UI_VIEWS_SHELL_WINDOW_FRAME_VIEW_H_

#include <string>

#include "ui/gfx/path.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/size.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/window/non_client_view.h"

namespace gfx {
class Canvas;
class Point;
}

namespace ui {
class Event;
}

namespace views {
class ImageButton;
class Widget;
}

namespace apps {

class NativeAppWindow;

// A frameless or non-Ash, non-panel NonClientFrameView for app windows.
class ShellWindowFrameView : public views::NonClientFrameView,
                             public views::ButtonListener {
 public:
  static const char kViewClassName[];

  explicit ShellWindowFrameView(NativeAppWindow* window);
  virtual ~ShellWindowFrameView();

  // Initializes this for the window |frame|. Sets the number of pixels for
  // which a click is interpreted as a resize for the inner and outer border of
  // the window and the lower-right corner resize handle.
  void Init(views::Widget* frame,
            int resize_inside_bounds_size,
            int resize_outside_bounds_size,
            int resize_outside_scale_for_touch,
            int resize_area_corner_size);

 private:
  // views::NonClientFrameView implementation.
  virtual gfx::Rect GetBoundsForClientView() const OVERRIDE;
  virtual gfx::Rect GetWindowBoundsForClientBounds(
      const gfx::Rect& client_bounds) const OVERRIDE;
  virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE;
  virtual void GetWindowMask(const gfx::Size& size,
                             gfx::Path* window_mask) OVERRIDE;
  virtual void ResetWindowControls() OVERRIDE {}
  virtual void UpdateWindowIcon() OVERRIDE {}
  virtual void UpdateWindowTitle() OVERRIDE {}

  // views::View implementation.
  virtual gfx::Size GetPreferredSize() OVERRIDE;
  virtual void Layout() OVERRIDE;
  virtual const char* GetClassName() const OVERRIDE;
  virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
  virtual gfx::Size GetMinimumSize() OVERRIDE;
  virtual gfx::Size GetMaximumSize() OVERRIDE;

  // views::ButtonListener implementation.
  virtual void ButtonPressed(views::Button* sender, const ui::Event& event)
      OVERRIDE;

  NativeAppWindow* window_;
  views::Widget* frame_;
  views::ImageButton* close_button_;
  views::ImageButton* maximize_button_;
  views::ImageButton* restore_button_;
  views::ImageButton* minimize_button_;

  // Allow resize for clicks this many pixels inside the bounds.
  int resize_inside_bounds_size_;

  // Size in pixels of the lower-right corner resize handle.
  int resize_area_corner_size_;

  DISALLOW_COPY_AND_ASSIGN(ShellWindowFrameView);
};

}  // namespace apps

#endif  // APPS_UI_VIEWS_SHELL_WINDOW_FRAME_VIEW_H_