| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/wm/panel_frame_view.h" | 5 #include "ash/wm/panel_frame_view.h" |
| 6 | 6 |
| 7 #include "grit/ui_resources.h" | 7 #include "grit/ui_resources.h" |
| 8 #include "third_party/skia/include/core/SkPaint.h" | 8 #include "third_party/skia/include/core/SkPaint.h" |
| 9 #include "ui/aura/cursor.h" | 9 #include "ui/aura/cursor.h" |
| 10 #include "ui/base/animation/throb_animation.h" | 10 #include "ui/base/animation/throb_animation.h" |
| 11 #include "ui/base/hit_test.h" | 11 #include "ui/base/hit_test.h" |
| 12 #include "ui/base/resource/resource_bundle.h" | 12 #include "ui/base/resource/resource_bundle.h" |
| 13 #include "ui/gfx/canvas.h" | 13 #include "ui/gfx/canvas.h" |
| 14 #include "ui/gfx/image/image.h" | 14 #include "ui/gfx/image/image.h" |
| 15 #include "ui/views/controls/button/custom_button.h" | 15 #include "ui/views/controls/button/custom_button.h" |
| 16 #include "ui/views/widget/widget.h" | 16 #include "ui/views/widget/widget.h" |
| 17 #include "ui/views/widget/widget_delegate.h" | 17 #include "ui/views/widget/widget_delegate.h" |
| 18 | 18 |
| 19 namespace ash { | 19 namespace ash { |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 |
| 22 const int kClientViewPaddingLeft = 0; | 23 const int kClientViewPaddingLeft = 0; |
| 23 const int kClientViewPaddingRight = 0; | 24 const int kClientViewPaddingRight = 0; |
| 24 const int kClientViewPaddingBottom = 0; | 25 const int kClientViewPaddingBottom = 0; |
| 26 const int kSeparatorWidth = 1; |
| 25 const SkColor kCaptionColor = SK_ColorGRAY; | 27 const SkColor kCaptionColor = SK_ColorGRAY; |
| 26 const SkColor kCaptionIconDivisorColor = SkColorSetARGB(0xFF, 0x55, 0x55, 0x55); | 28 const SkColor kCaptionIconSeparatorColor = SkColorSetRGB(0x55, 0x55, 0x55); |
| 27 } | 29 |
| 30 } // namespace |
| 28 | 31 |
| 29 // Buttons for panel control | 32 // Buttons for panel control |
| 30 class PanelControlButton : public views::CustomButton { | 33 class PanelControlButton : public views::CustomButton { |
| 31 public: | 34 public: |
| 32 PanelControlButton(views::ButtonListener* listener, | 35 PanelControlButton(views::ButtonListener* listener, |
| 33 const SkBitmap& icon) | 36 const SkBitmap& icon) |
| 34 : views::CustomButton(listener), | 37 : views::CustomButton(listener), |
| 35 icon_(icon) { | 38 icon_(icon) { |
| 36 } | 39 } |
| 37 virtual ~PanelControlButton() {} | 40 virtual ~PanelControlButton() {} |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 // Overridden from views::View: | 86 // Overridden from views::View: |
| 84 virtual gfx::Size GetPreferredSize() OVERRIDE { | 87 virtual gfx::Size GetPreferredSize() OVERRIDE { |
| 85 return gfx::Size(0, close_button_->GetPreferredSize().height()); | 88 return gfx::Size(0, close_button_->GetPreferredSize().height()); |
| 86 } | 89 } |
| 87 | 90 |
| 88 | 91 |
| 89 private: | 92 private: |
| 90 // Overridden from views::View: | 93 // Overridden from views::View: |
| 91 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { | 94 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { |
| 92 canvas->FillRect(GetLocalBounds(), kCaptionColor); | 95 canvas->FillRect(GetLocalBounds(), kCaptionColor); |
| 93 gfx::Rect close_button_bounds = close_button_->bounds(); | 96 gfx::Rect separator(close_button_->bounds()); |
| 94 canvas->DrawLine( | 97 separator.set_width(kSeparatorWidth); |
| 95 gfx::Point(close_button_bounds.x(), close_button_bounds.y()), | 98 canvas->FillRect(separator, kCaptionIconSeparatorColor); |
| 96 gfx::Point(close_button_bounds.x(), close_button_bounds.bottom()), | |
| 97 kCaptionIconDivisorColor); | |
| 98 } | 99 } |
| 99 | 100 |
| 100 virtual void Layout() OVERRIDE { | 101 virtual void Layout() OVERRIDE { |
| 101 gfx::Size close_ps = close_button_->GetPreferredSize(); | 102 gfx::Size close_ps = close_button_->GetPreferredSize(); |
| 102 close_button_->SetBoundsRect( | 103 close_button_->SetBoundsRect( |
| 103 gfx::Rect(width() - close_ps.width(), 0, | 104 gfx::Rect(width() - close_ps.width(), 0, |
| 104 close_ps.width(), close_ps.height())); | 105 close_ps.width(), close_ps.height())); |
| 105 } | 106 } |
| 106 | 107 |
| 107 // Overriden from views::ButtonListener: | 108 // Overriden from views::ButtonListener: |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 gfx::Rect PanelFrameView::GetWindowBoundsForClientBounds( | 176 gfx::Rect PanelFrameView::GetWindowBoundsForClientBounds( |
| 176 const gfx::Rect& client_bounds) const { | 177 const gfx::Rect& client_bounds) const { |
| 177 gfx::Rect window_bounds = client_bounds; | 178 gfx::Rect window_bounds = client_bounds; |
| 178 window_bounds.Inset(-kClientViewPaddingLeft, | 179 window_bounds.Inset(-kClientViewPaddingLeft, |
| 179 -CaptionHeight(), | 180 -CaptionHeight(), |
| 180 -kClientViewPaddingRight, | 181 -kClientViewPaddingRight, |
| 181 -kClientViewPaddingBottom); | 182 -kClientViewPaddingBottom); |
| 182 return window_bounds; | 183 return window_bounds; |
| 183 } | 184 } |
| 184 | 185 |
| 185 } | 186 } // namespace ash |
| OLD | NEW |