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

Unified Diff: ash/wm/panel_frame_view.cc

Issue 11363250: Allow Chrome apps to create Ash Panels (apps v2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Multi-icon support Created 8 years, 1 month 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: ash/wm/panel_frame_view.cc
diff --git a/ash/wm/panel_frame_view.cc b/ash/wm/panel_frame_view.cc
index 4ca949944e04c1fb4ed5d3dd96cadbc16d6ae131..820a91395741f89b90509ef1d5a3d2a35de20532 100644
--- a/ash/wm/panel_frame_view.cc
+++ b/ash/wm/panel_frame_view.cc
@@ -2,8 +2,9 @@
// 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 "ash/wm/frame_painter.h"
#include "grit/ash_resources.h"
#include "grit/ui_strings.h" // Accessibility names
#include "third_party/skia/include/core/SkPaint.h"
@@ -22,8 +23,24 @@
namespace ash {
-PanelFrameView::PanelFrameView(views::Widget* frame)
- : frame_painter_(new FramePainter) {
+PanelFrameView::PanelFrameView(views::Widget* frame, FrameType frame_type) {
+ if (frame_type != FRAME_NONE)
+ InitFramePainter(frame);
+}
+
+PanelFrameView::~PanelFrameView() {
+}
+
+gfx::Insets PanelFrameView::GetFrameInsets() const {
+ if (!frame_painter_.get())
+ return gfx::Insets();
+ int title_height = close_button_->bounds().bottom();
+ return gfx::Insets(0, 0, title_height, 0);
sky 2012/11/20 02:05:05 Seems like this should call into FramePainter sinc
stevenjb 2012/11/20 21:20:58 Done.
+}
+
+void PanelFrameView::InitFramePainter(views::Widget* frame) {
+ frame_painter_.reset(new FramePainter);
+
close_button_ = new views::ImageButton(this);
close_button_->SetAccessibleName(
l10n_util::GetStringUTF16(IDS_APP_ACCNAME_CLOSE));
@@ -38,10 +55,9 @@ PanelFrameView::PanelFrameView(views::Widget* frame)
FramePainter::SIZE_BUTTON_MINIMIZES);
}
-PanelFrameView::~PanelFrameView() {
-}
-
void PanelFrameView::Layout() {
+ if (!frame_painter_.get())
+ return;
frame_painter_->LayoutHeader(this, true);
}
@@ -62,10 +78,14 @@ void PanelFrameView::GetWindowMask(const gfx::Size&, gfx::Path*) {
}
int PanelFrameView::NonClientHitTest(const gfx::Point& point) {
+ if (!frame_painter_.get())
+ return HTNOWHERE;
return frame_painter_->NonClientHitTest(this, point);
}
void PanelFrameView::OnPaint(gfx::Canvas* canvas) {
+ if (!frame_painter_.get())
+ return;
bool paint_as_active = ShouldPaintAsActive();
int theme_image_id = paint_as_active ? IDR_AURA_WINDOW_HEADER_BASE_ACTIVE :
IDR_AURA_WINDOW_HEADER_BASE_INACTIVE;
@@ -79,6 +99,8 @@ void PanelFrameView::OnPaint(gfx::Canvas* canvas) {
}
gfx::Rect PanelFrameView::GetBoundsForClientView() const {
+ if (!frame_painter_.get())
+ return bounds();
return frame_painter_->GetBoundsForClientView(
close_button_->bounds().bottom(),
bounds());
@@ -86,6 +108,8 @@ gfx::Rect PanelFrameView::GetBoundsForClientView() const {
gfx::Rect PanelFrameView::GetWindowBoundsForClientBounds(
const gfx::Rect& client_bounds) const {
+ if (!frame_painter_.get())
+ return client_bounds;
return frame_painter_->GetWindowBoundsForClientBounds(
close_button_->bounds().bottom(), client_bounds);
}
@@ -94,6 +118,8 @@ void PanelFrameView::ButtonPressed(views::Button* sender,
const ui::Event& event) {
if (sender == close_button_)
GetWidget()->Close();
+ if (sender == minimize_button_)
+ GetWidget()->Minimize();
}
} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698