Chromium Code Reviews| 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 "chrome/browser/ui/panels/panel_browser_window_gtk.h" | 5 #include "chrome/browser/ui/panels/panel_browser_window_gtk.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/browser/ui/browser_list.h" | 9 #include "chrome/browser/ui/browser_list.h" |
| 10 #include "chrome/browser/ui/browser_window.h" | 10 #include "chrome/browser/ui/browser_window.h" |
| 11 #include "chrome/browser/ui/gtk/browser_titlebar.h" | 11 #include "chrome/browser/ui/gtk/browser_titlebar.h" |
| 12 #include "chrome/browser/ui/gtk/custom_button.h" | 12 #include "chrome/browser/ui/gtk/custom_button.h" |
| 13 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 13 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
| 14 #include "chrome/browser/ui/gtk/nine_box.h" | 14 #include "chrome/browser/ui/gtk/nine_box.h" |
| 15 #include "chrome/browser/ui/panels/panel.h" | 15 #include "chrome/browser/ui/panels/panel.h" |
| 16 #include "chrome/browser/ui/panels/panel_bounds_animation.h" | 16 #include "chrome/browser/ui/panels/panel_bounds_animation.h" |
| 17 #include "chrome/browser/ui/panels/panel_browser_titlebar_gtk.h" | 17 #include "chrome/browser/ui/panels/panel_browser_titlebar_gtk.h" |
| 18 #include "chrome/browser/ui/panels/panel_constants.h" | |
| 18 #include "chrome/browser/ui/panels/panel_drag_gtk.h" | 19 #include "chrome/browser/ui/panels/panel_drag_gtk.h" |
| 19 #include "chrome/browser/ui/panels/panel_manager.h" | 20 #include "chrome/browser/ui/panels/panel_manager.h" |
| 20 #include "chrome/browser/ui/panels/panel_strip.h" | 21 #include "chrome/browser/ui/panels/panel_strip.h" |
| 21 #include "chrome/common/chrome_notification_types.h" | 22 #include "chrome/common/chrome_notification_types.h" |
| 22 #include "content/public/browser/native_web_keyboard_event.h" | 23 #include "content/public/browser/native_web_keyboard_event.h" |
| 23 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
| 24 #include "grit/theme_resources_standard.h" | 25 #include "grit/theme_resources_standard.h" |
| 25 #include "grit/ui_resources.h" | 26 #include "grit/ui_resources.h" |
| 26 #include "third_party/skia/include/core/SkShader.h" | 27 #include "ui/base/gtk/gtk_compat.h" |
| 27 #include "ui/gfx/canvas.h" | 28 #include "ui/gfx/canvas.h" |
| 28 #include "ui/gfx/image/cairo_cached_surface.h" | 29 #include "ui/gfx/image/cairo_cached_surface.h" |
| 29 #include "ui/gfx/image/image.h" | 30 #include "ui/gfx/image/image.h" |
| 30 #include "ui/gfx/skia_util.h" | |
| 31 | 31 |
| 32 using content::NativeWebKeyboardEvent; | 32 using content::NativeWebKeyboardEvent; |
| 33 using content::WebContents; | 33 using content::WebContents; |
| 34 | 34 |
| 35 namespace { | 35 namespace { |
| 36 | 36 |
| 37 // Colors used to draw titlebar and frame for drawing attention under default | 37 // Colors used to draw frame background under default theme. |
| 38 // theme. It is also used in non-default theme since attention color is not | 38 const SkColor kActiveBackgroundDefaultColor = SkColorSetRGB(0x3a, 0x3c, 0x3c); |
| 39 // defined in the theme. | 39 const SkColor kInactiveBackgroundDefaultColor = SkColorSetRGB(0x7a, 0x7c, 0x7c); |
| 40 const SkColor kAttentionBackgroundColorStart = SkColorSetRGB(0xff, 0xab, 0x57); | 40 const SkColor kAttentionBackgroundDefaultColor = |
| 41 const SkColor kAttentionBackgroundColorEnd = SkColorSetRGB(0xe6, 0x9a, 0x4e); | 41 SkColorSetRGB(0xff, 0xab, 0x57); |
| 42 const SkColor kMinimizeBackgroundDefaultColor = SkColorSetRGB(0xf5, 0xf4, 0xf0); | |
| 43 const SkColor kMinimizeBorderDefaultColor = SkColorSetRGB(0xc9, 0xc9, 0xc9); | |
| 44 | |
| 45 // Color used to draw the divider line between the titlebar and the client area. | |
| 46 const SkColor kDividerColor = SkColorSetRGB(0x5a, 0x5c, 0x5c); | |
| 42 | 47 |
| 43 // Set minimium width for window really small. | 48 // Set minimium width for window really small. |
| 44 const int kMinWindowWidth = 26; | 49 const int kMinWindowWidth = 26; |
| 45 | 50 |
| 46 gfx::Image* CreateGradientImage(SkColor start_color, SkColor end_color) { | 51 gfx::Image* CreateImageForColor(SkColor color) { |
| 47 // Though the height of titlebar, used for creating gradient, cannot be | 52 gfx::Canvas canvas(gfx::Size(1, 1), true); |
| 48 // pre-determined, we use a reasonably bigger value that is obtained from | 53 canvas.DrawColor(color); |
| 49 // the experimentation and should work for most cases. | |
| 50 const int gradient_size = 32; | |
| 51 SkShader* shader = gfx::CreateGradientShader( | |
| 52 0, gradient_size, start_color, end_color); | |
| 53 SkPaint paint; | |
| 54 paint.setStyle(SkPaint::kFill_Style); | |
| 55 paint.setAntiAlias(true); | |
| 56 paint.setShader(shader); | |
| 57 shader->unref(); | |
| 58 gfx::Canvas canvas(gfx::Size(1, gradient_size), true); | |
| 59 canvas.DrawRect(gfx::Rect(0, 0, 1, gradient_size), paint); | |
| 60 return new gfx::Image(canvas.ExtractBitmap()); | 54 return new gfx::Image(canvas.ExtractBitmap()); |
| 61 } | 55 } |
| 62 | 56 |
| 63 gfx::Image* GetAttentionBackgroundImage() { | 57 const gfx::Image* GetActiveBackgroundDefaultImage() { |
| 64 static gfx::Image* image = NULL; | 58 static gfx::Image* image = NULL; |
| 65 if (!image) { | 59 if (!image) |
| 66 image = CreateGradientImage(kAttentionBackgroundColorStart, | 60 image = CreateImageForColor(kActiveBackgroundDefaultColor); |
| 67 kAttentionBackgroundColorEnd); | |
| 68 } | |
| 69 return image; | 61 return image; |
| 70 } | 62 } |
| 71 | 63 |
| 64 const gfx::Image* GetInactiveBackgroundDefaultImage() { | |
| 65 static gfx::Image* image = NULL; | |
| 66 if (!image) | |
| 67 image = CreateImageForColor(kInactiveBackgroundDefaultColor); | |
| 68 return image; | |
| 69 } | |
| 70 | |
| 71 const gfx::Image* GetAttentionBackgroundDefaultImage() { | |
| 72 static gfx::Image* image = NULL; | |
| 73 if (!image) | |
| 74 image = CreateImageForColor(kAttentionBackgroundDefaultColor); | |
| 75 return image; | |
| 76 } | |
| 77 | |
| 78 const gfx::Image* GetMinimizeBackgroundDefaultImage() { | |
| 79 static gfx::Image* image = NULL; | |
| 80 if (!image) | |
| 81 image = CreateImageForColor(kMinimizeBackgroundDefaultColor); | |
| 82 return image; | |
| 83 } | |
| 84 | |
| 72 } // namespace | 85 } // namespace |
| 73 | 86 |
| 74 NativePanel* Panel::CreateNativePanel(Browser* browser, Panel* panel, | 87 NativePanel* Panel::CreateNativePanel(Browser* browser, Panel* panel, |
| 75 const gfx::Rect& bounds) { | 88 const gfx::Rect& bounds) { |
| 76 PanelBrowserWindowGtk* panel_browser_window_gtk = | 89 PanelBrowserWindowGtk* panel_browser_window_gtk = |
| 77 new PanelBrowserWindowGtk(browser, panel, bounds); | 90 new PanelBrowserWindowGtk(browser, panel, bounds); |
| 78 panel_browser_window_gtk->Init(); | 91 panel_browser_window_gtk->Init(); |
| 79 return panel_browser_window_gtk; | 92 return panel_browser_window_gtk; |
| 80 } | 93 } |
| 81 | 94 |
| 82 PanelBrowserWindowGtk::PanelBrowserWindowGtk(Browser* browser, | 95 PanelBrowserWindowGtk::PanelBrowserWindowGtk(Browser* browser, |
| 83 Panel* panel, | 96 Panel* panel, |
| 84 const gfx::Rect& bounds) | 97 const gfx::Rect& bounds) |
| 85 : BrowserWindowGtk(browser), | 98 : BrowserWindowGtk(browser), |
| 86 panel_(panel), | 99 panel_(panel), |
| 87 bounds_(bounds), | 100 bounds_(bounds), |
| 101 paint_state_(PAINT_AS_INACTIVE), | |
| 88 is_drawing_attention_(false) { | 102 is_drawing_attention_(false) { |
| 89 } | 103 } |
| 90 | 104 |
| 91 PanelBrowserWindowGtk::~PanelBrowserWindowGtk() { | 105 PanelBrowserWindowGtk::~PanelBrowserWindowGtk() { |
| 92 } | 106 } |
| 93 | 107 |
| 94 void PanelBrowserWindowGtk::Init() { | 108 void PanelBrowserWindowGtk::Init() { |
| 95 BrowserWindowGtk::Init(); | 109 BrowserWindowGtk::Init(); |
| 96 | 110 |
| 97 // Keep the window always on top. | 111 // Keep the window always on top. |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 109 // window edge was hit. | 123 // window edge was hit. |
| 110 g_signal_connect(titlebar_widget(), "button-release-event", | 124 g_signal_connect(titlebar_widget(), "button-release-event", |
| 111 G_CALLBACK(OnTitlebarButtonReleaseEventThunk), this); | 125 G_CALLBACK(OnTitlebarButtonReleaseEventThunk), this); |
| 112 | 126 |
| 113 registrar_.Add( | 127 registrar_.Add( |
| 114 this, | 128 this, |
| 115 chrome::NOTIFICATION_WINDOW_CLOSED, | 129 chrome::NOTIFICATION_WINDOW_CLOSED, |
| 116 content::Source<GtkWindow>(window())); | 130 content::Source<GtkWindow>(window())); |
| 117 } | 131 } |
| 118 | 132 |
| 119 bool PanelBrowserWindowGtk::ShouldDrawContentDropShadow() const { | 133 BrowserTitlebarBase* PanelBrowserWindowGtk::CreateBrowserTitlebar() { |
| 120 return !panel_->IsMinimized(); | |
| 121 } | |
| 122 | |
| 123 BrowserTitlebar* PanelBrowserWindowGtk::CreateBrowserTitlebar() { | |
| 124 return new PanelBrowserTitlebarGtk(this, window()); | 134 return new PanelBrowserTitlebarGtk(this, window()); |
| 125 } | 135 } |
| 126 | 136 |
| 127 PanelBrowserTitlebarGtk* PanelBrowserWindowGtk::GetPanelTitlebar() const { | 137 PanelBrowserTitlebarGtk* PanelBrowserWindowGtk::GetPanelTitlebar() const { |
| 128 return static_cast<PanelBrowserTitlebarGtk*>(titlebar()); | 138 return static_cast<PanelBrowserTitlebarGtk*>(titlebar()); |
| 129 } | 139 } |
| 130 | 140 |
| 131 PanelBrowserWindowGtk::PaintState PanelBrowserWindowGtk::GetPaintState() const { | 141 bool PanelBrowserWindowGtk::UsingDefaultTheme() const { |
| 132 if (is_drawing_attention_) | 142 // No theme is provided for attention painting. |
| 133 return PAINT_FOR_ATTENTION; | 143 if (paint_state_ == PAINT_FOR_ATTENTION) |
| 134 return IsActive() ? PAINT_AS_ACTIVE : PAINT_AS_INACTIVE; | 144 return true; |
| 145 | |
| 146 GtkThemeService* theme_provider = GtkThemeService::GetFrom( | |
| 147 browser()->profile()); | |
| 148 return theme_provider->UsingDefaultTheme(); | |
| 135 } | 149 } |
| 136 | 150 |
| 137 bool PanelBrowserWindowGtk::GetWindowEdge(int x, int y, GdkWindowEdge* edge) { | 151 bool PanelBrowserWindowGtk::GetWindowEdge(int x, int y, GdkWindowEdge* edge) { |
| 138 // Only detect the window edge when panels can be resized by the user. | 152 // Only detect the window edge when panels can be resized by the user. |
| 139 // This method is used by the base class to detect when the cursor has | 153 // This method is used by the base class to detect when the cursor has |
| 140 // hit the window edge in order to change the cursor to a resize cursor | 154 // hit the window edge in order to change the cursor to a resize cursor |
| 141 // and to detect when to initiate a resize drag. | 155 // and to detect when to initiate a resize drag. |
| 142 panel::Resizability resizability = panel_->CanResizeByMouse(); | 156 panel::Resizability resizability = panel_->CanResizeByMouse(); |
| 143 if (panel::NOT_RESIZABLE == resizability) | 157 if (panel::NOT_RESIZABLE == resizability) |
| 144 return false; | 158 return false; |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 164 // rounded because panels are aligned to the bottom edge of the screen. | 178 // rounded because panels are aligned to the bottom edge of the screen. |
| 165 GdkRectangle top_top_rect = { 3, 0, width - 6, 1 }; | 179 GdkRectangle top_top_rect = { 3, 0, width - 6, 1 }; |
| 166 GdkRectangle top_mid_rect = { 1, 1, width - 2, 2 }; | 180 GdkRectangle top_mid_rect = { 1, 1, width - 2, 2 }; |
| 167 GdkRectangle mid_rect = { 0, 3, width, height - 3 }; | 181 GdkRectangle mid_rect = { 0, 3, width, height - 3 }; |
| 168 GdkRegion* mask = gdk_region_rectangle(&top_top_rect); | 182 GdkRegion* mask = gdk_region_rectangle(&top_top_rect); |
| 169 gdk_region_union_with_rect(mask, &top_mid_rect); | 183 gdk_region_union_with_rect(mask, &top_mid_rect); |
| 170 gdk_region_union_with_rect(mask, &mid_rect); | 184 gdk_region_union_with_rect(mask, &mid_rect); |
| 171 return mask; | 185 return mask; |
| 172 } | 186 } |
| 173 | 187 |
| 174 void PanelBrowserWindowGtk::DrawCustomFrameBorder(GtkWidget* widget) { | 188 bool PanelBrowserWindowGtk::UseCustomFrame() const { |
| 175 static NineBox* custom_frame_border = NULL; | 189 // We always use custom frame for panels. |
| 176 if (!custom_frame_border) { | 190 return true; |
| 177 custom_frame_border = new NineBox(IDR_WINDOW_TOP_LEFT_CORNER, | 191 } |
| 178 IDR_WINDOW_TOP_CENTER, | 192 |
| 179 IDR_WINDOW_TOP_RIGHT_CORNER, | 193 void PanelBrowserWindowGtk::DrawFrame(GtkWidget* widget, |
| 180 IDR_WINDOW_LEFT_SIDE, | 194 GdkEventExpose* event) { |
| 181 0, | 195 cairo_t* cr = gdk_cairo_create(gtk_widget_get_window(widget)); |
| 182 IDR_WINDOW_RIGHT_SIDE, | 196 gdk_cairo_rectangle(cr, &event->area); |
| 183 IDR_PANEL_BOTTOM_LEFT_CORNER, | 197 cairo_clip(cr); |
| 184 IDR_WINDOW_BOTTOM_CENTER, | 198 |
| 185 IDR_PANEL_BOTTOM_RIGHT_CORNER); | 199 // Update the painting state. |
| 200 int window_height = gdk_window_get_height(gtk_widget_get_window(widget)); | |
| 201 if (is_drawing_attention_) | |
| 202 paint_state_ = PAINT_FOR_ATTENTION; | |
| 203 else if (window_height <= panel::kMinimizedPanelHeight) | |
| 204 paint_state_ = PAINT_AS_MINIMIZED; | |
| 205 else if (IsActive()) | |
| 206 paint_state_ = PAINT_AS_ACTIVE; | |
| 207 else | |
| 208 paint_state_ = PAINT_AS_INACTIVE; | |
| 209 | |
| 210 // Draw the background. | |
| 211 gfx::CairoCachedSurface* surface = GetFrameBackground()->ToCairo(); | |
| 212 surface->SetSource(cr, widget, 0, 0); | |
| 213 cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT); | |
| 214 cairo_rectangle(cr, event->area.x, event->area.y, | |
| 215 event->area.width, event->area.height); | |
| 216 cairo_fill(cr); | |
| 217 | |
| 218 // Draw the divider only if we're showing more than titlebar. | |
| 219 if (window_height > panel::kTitlebarHeight) { | |
| 220 cairo_set_source_rgb(cr, | |
| 221 SkColorGetR(kDividerColor) / 255.0, | |
| 222 SkColorGetG(kDividerColor) / 255.0, | |
| 223 SkColorGetB(kDividerColor) / 255.0); | |
| 224 cairo_rectangle(cr, 0, panel::kTitlebarHeight - 1, bounds_.width(), 1); | |
| 225 cairo_fill(cr); | |
| 186 } | 226 } |
| 187 custom_frame_border->RenderToWidget(widget); | 227 |
| 228 cairo_destroy(cr); | |
| 229 | |
| 230 // Draw the border for the minimized panel only. | |
| 231 if (paint_state_ == PAINT_AS_MINIMIZED) { | |
| 232 static NineBox* custom_frame_border = NULL; | |
| 233 if (!custom_frame_border) { | |
| 234 custom_frame_border = new NineBox(IDR_WINDOW_TOP_LEFT_CORNER, | |
|
Dmitry Titov
2012/06/04 22:19:57
Can Cairo just render a semi-rounded rect? It's a
jianli
2012/06/05 18:48:30
Done.
| |
| 235 IDR_WINDOW_TOP_CENTER, | |
| 236 IDR_WINDOW_TOP_RIGHT_CORNER, | |
| 237 IDR_WINDOW_LEFT_SIDE, | |
| 238 0, | |
| 239 IDR_WINDOW_RIGHT_SIDE, | |
| 240 IDR_PANEL_BOTTOM_LEFT_CORNER, | |
| 241 IDR_WINDOW_BOTTOM_CENTER, | |
| 242 IDR_PANEL_BOTTOM_RIGHT_CORNER); | |
| 243 } | |
| 244 custom_frame_border->RenderToWidget(widget); | |
| 245 } | |
| 188 } | 246 } |
| 189 | 247 |
| 190 void PanelBrowserWindowGtk::EnsureDragHelperCreated() { | 248 void PanelBrowserWindowGtk::EnsureDragHelperCreated() { |
| 191 if (drag_helper_.get()) | 249 if (drag_helper_.get()) |
| 192 return; | 250 return; |
| 193 | 251 |
| 194 drag_helper_.reset(new PanelDragGtk(panel_.get())); | 252 drag_helper_.reset(new PanelDragGtk(panel_.get())); |
| 195 gtk_box_pack_end(GTK_BOX(window_vbox_), drag_helper_->widget(), | 253 gtk_box_pack_end(GTK_BOX(window_vbox_), drag_helper_->widget(), |
| 196 FALSE, FALSE, 0); | 254 FALSE, FALSE, 0); |
| 197 } | 255 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 263 gtk_window_move(window_, left, top); | 321 gtk_window_move(window_, left, top); |
| 264 StartBoundsAnimation(gfx::Rect(left, top, width, height), bounds_); | 322 StartBoundsAnimation(gfx::Rect(left, top, width, height), bounds_); |
| 265 panel_->OnWindowSizeAvailable(); | 323 panel_->OnWindowSizeAvailable(); |
| 266 | 324 |
| 267 content::NotificationService::current()->Notify( | 325 content::NotificationService::current()->Notify( |
| 268 chrome::NOTIFICATION_PANEL_WINDOW_SIZE_KNOWN, | 326 chrome::NOTIFICATION_PANEL_WINDOW_SIZE_KNOWN, |
| 269 content::Source<Panel>(panel_.get()), | 327 content::Source<Panel>(panel_.get()), |
| 270 content::NotificationService::NoDetails()); | 328 content::NotificationService::NoDetails()); |
| 271 } | 329 } |
| 272 | 330 |
| 273 bool PanelBrowserWindowGtk::UseCustomFrame() const { | 331 const gfx::Image* PanelBrowserWindowGtk::GetFrameBackground() const { |
| 274 // We always use custom frame for panels. | 332 return UsingDefaultTheme() ? |
| 275 return true; | 333 GetDefaultFrameBackground() : GetThemedFrameBackground(); |
| 276 } | 334 } |
| 277 | 335 |
| 278 bool PanelBrowserWindowGtk::UsingCustomPopupFrame() const { | 336 const gfx::Image* PanelBrowserWindowGtk::GetDefaultFrameBackground() const { |
| 279 // We do not draw custom popup frame. | 337 switch (paint_state_) { |
| 280 return false; | 338 case PAINT_AS_INACTIVE: |
| 339 return GetInactiveBackgroundDefaultImage(); | |
| 340 case PAINT_AS_ACTIVE: | |
| 341 return GetActiveBackgroundDefaultImage(); | |
| 342 case PAINT_AS_MINIMIZED: | |
| 343 return GetMinimizeBackgroundDefaultImage(); | |
| 344 case PAINT_FOR_ATTENTION: | |
| 345 return GetAttentionBackgroundDefaultImage(); | |
| 346 default: | |
| 347 NOTREACHED(); | |
| 348 return GetInactiveBackgroundDefaultImage(); | |
| 349 } | |
| 281 } | 350 } |
| 282 | 351 |
| 283 void PanelBrowserWindowGtk::DrawPopupFrame(cairo_t* cr, | 352 const gfx::Image* PanelBrowserWindowGtk::GetThemedFrameBackground() const { |
| 284 GtkWidget* widget, | |
| 285 GdkEventExpose* event) { | |
| 286 NOTREACHED(); | |
| 287 } | |
| 288 | |
| 289 const gfx::Image* PanelBrowserWindowGtk::GetThemeFrameImage() const { | |
| 290 PaintState paint_state = GetPaintState(); | |
| 291 if (paint_state == PAINT_FOR_ATTENTION) | |
| 292 return GetAttentionBackgroundImage(); | |
| 293 | |
| 294 GtkThemeService* theme_provider = GtkThemeService::GetFrom( | 353 GtkThemeService* theme_provider = GtkThemeService::GetFrom( |
| 295 GetPanelBrowser()->profile()); | 354 browser()->profile()); |
| 296 if (theme_provider->UsingDefaultTheme()) { | 355 return theme_provider->GetImageNamed(paint_state_ == PAINT_AS_ACTIVE ? |
| 297 // We choose to use the window frame theme to paint panels for the default | |
| 298 // theme. This is because the default tab theme does not work well for the | |
| 299 // user to recognize active and inactive panels. | |
| 300 return theme_provider->GetImageNamed(paint_state == PAINT_AS_ACTIVE ? | |
| 301 IDR_THEME_FRAME : IDR_THEME_FRAME_INACTIVE); | |
| 302 } | |
| 303 | |
| 304 return theme_provider->GetImageNamed(paint_state == PAINT_AS_ACTIVE ? | |
| 305 IDR_THEME_TOOLBAR : IDR_THEME_TAB_BACKGROUND); | 356 IDR_THEME_TOOLBAR : IDR_THEME_TAB_BACKGROUND); |
| 306 } | 357 } |
| 307 | 358 |
| 308 void PanelBrowserWindowGtk::DrawCustomFrame(cairo_t* cr, | |
| 309 GtkWidget* widget, | |
| 310 GdkEventExpose* event) { | |
| 311 gfx::CairoCachedSurface* surface = GetThemeFrameImage()->ToCairo(); | |
| 312 | |
| 313 surface->SetSource(cr, widget, 0, 0); | |
| 314 cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT); | |
| 315 cairo_rectangle(cr, event->area.x, event->area.y, | |
| 316 event->area.width, event->area.height); | |
| 317 cairo_fill(cr); | |
| 318 } | |
| 319 | |
| 320 void PanelBrowserWindowGtk::ActiveWindowChanged(GdkWindow* active_window) { | 359 void PanelBrowserWindowGtk::ActiveWindowChanged(GdkWindow* active_window) { |
| 321 bool was_active = IsActive(); | 360 bool was_active = IsActive(); |
| 322 BrowserWindowGtk::ActiveWindowChanged(active_window); | 361 BrowserWindowGtk::ActiveWindowChanged(active_window); |
| 323 bool is_active = IsActive(); | 362 bool is_active = IsActive(); |
| 324 if (!window() || was_active == is_active) // State didn't change. | 363 if (!window() || was_active == is_active) // State didn't change. |
| 325 return; | 364 return; |
| 326 | 365 |
| 327 panel_->OnActiveStateChanged(is_active); | 366 panel_->OnActiveStateChanged(is_active); |
| 328 } | 367 } |
| 329 | 368 |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 593 virtual void ReleaseMouseButtonTitlebar( | 632 virtual void ReleaseMouseButtonTitlebar( |
| 594 panel::ClickModifier modifier) OVERRIDE; | 633 panel::ClickModifier modifier) OVERRIDE; |
| 595 virtual void DragTitlebar(const gfx::Point& mouse_location) OVERRIDE; | 634 virtual void DragTitlebar(const gfx::Point& mouse_location) OVERRIDE; |
| 596 virtual void CancelDragTitlebar() OVERRIDE; | 635 virtual void CancelDragTitlebar() OVERRIDE; |
| 597 virtual void FinishDragTitlebar() OVERRIDE; | 636 virtual void FinishDragTitlebar() OVERRIDE; |
| 598 virtual bool VerifyDrawingAttention() const OVERRIDE; | 637 virtual bool VerifyDrawingAttention() const OVERRIDE; |
| 599 virtual bool VerifyActiveState(bool is_active) OVERRIDE; | 638 virtual bool VerifyActiveState(bool is_active) OVERRIDE; |
| 600 virtual void WaitForWindowCreationToComplete() const OVERRIDE; | 639 virtual void WaitForWindowCreationToComplete() const OVERRIDE; |
| 601 virtual bool IsWindowSizeKnown() const OVERRIDE; | 640 virtual bool IsWindowSizeKnown() const OVERRIDE; |
| 602 virtual bool IsAnimatingBounds() const OVERRIDE; | 641 virtual bool IsAnimatingBounds() const OVERRIDE; |
| 603 virtual bool IsButtonVisible(TitlebarButtonType button_type) const OVERRIDE; | 642 virtual bool IsButtonVisible( |
| 643 panel::TitlebarButtonType button_type) const OVERRIDE; | |
| 604 | 644 |
| 605 PanelBrowserWindowGtk* panel_browser_window_gtk_; | 645 PanelBrowserWindowGtk* panel_browser_window_gtk_; |
| 606 }; | 646 }; |
| 607 | 647 |
| 608 // static | 648 // static |
| 609 NativePanelTesting* NativePanelTesting::Create(NativePanel* native_panel) { | 649 NativePanelTesting* NativePanelTesting::Create(NativePanel* native_panel) { |
| 610 return new NativePanelTestingGtk(static_cast<PanelBrowserWindowGtk*>( | 650 return new NativePanelTestingGtk(static_cast<PanelBrowserWindowGtk*>( |
| 611 native_panel)); | 651 native_panel)); |
| 612 } | 652 } |
| 613 | 653 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 696 | 736 |
| 697 bool NativePanelTestingGtk::IsWindowSizeKnown() const { | 737 bool NativePanelTestingGtk::IsWindowSizeKnown() const { |
| 698 return !panel_browser_window_gtk_->frame_size_.IsEmpty(); | 738 return !panel_browser_window_gtk_->frame_size_.IsEmpty(); |
| 699 } | 739 } |
| 700 | 740 |
| 701 bool NativePanelTestingGtk::IsAnimatingBounds() const { | 741 bool NativePanelTestingGtk::IsAnimatingBounds() const { |
| 702 return panel_browser_window_gtk_->IsAnimatingBounds(); | 742 return panel_browser_window_gtk_->IsAnimatingBounds(); |
| 703 } | 743 } |
| 704 | 744 |
| 705 bool NativePanelTestingGtk::IsButtonVisible( | 745 bool NativePanelTestingGtk::IsButtonVisible( |
| 706 TitlebarButtonType button_type) const { | 746 panel::TitlebarButtonType button_type) const { |
| 707 PanelBrowserTitlebarGtk* titlebar = | 747 PanelBrowserTitlebarGtk* titlebar = |
| 708 panel_browser_window_gtk_->GetPanelTitlebar(); | 748 panel_browser_window_gtk_->GetPanelTitlebar(); |
| 709 CustomDrawButton* button; | 749 CustomDrawButton* button; |
| 710 switch (button_type) { | 750 switch (button_type) { |
| 711 case CLOSE_BUTTON: | 751 case panel::CLOSE_BUTTON: |
| 712 button = titlebar->close_button(); | 752 button = titlebar->close_button(); |
| 713 break; | 753 break; |
| 714 case MINIMIZE_BUTTON: | 754 case panel::MINIMIZE_BUTTON: |
| 715 button = titlebar->minimize_button(); | 755 button = titlebar->minimize_button(); |
| 716 break; | 756 break; |
| 717 case RESTORE_BUTTON: | 757 case panel::RESTORE_BUTTON: |
| 718 button = titlebar->unminimize_button(); | 758 button = titlebar->restore_button(); |
| 719 break; | 759 break; |
| 720 default: | 760 default: |
| 721 NOTREACHED(); | 761 NOTREACHED(); |
| 722 return false; | 762 return false; |
| 723 } | 763 } |
| 724 return gtk_widget_get_visible(button->widget()); | 764 return gtk_widget_get_visible(button->widget()); |
| 725 } | 765 } |
| OLD | NEW |