OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/libgtkui/native_theme_gtk3.h" | 5 #include "chrome/browser/ui/libgtkui/native_theme_gtk3.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include "chrome/browser/ui/libgtkui/chrome_gtk_frame.h" | 9 #include "chrome/browser/ui/libgtkui/chrome_gtk_frame.h" |
10 #include "chrome/browser/ui/libgtkui/chrome_gtk_menu_subclasses.h" | 10 #include "chrome/browser/ui/libgtkui/chrome_gtk_menu_subclasses.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, size.width())); | 32 cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, size.width())); |
33 cairo_t* cr = cairo_create(surface); | 33 cairo_t* cr = cairo_create(surface); |
34 | 34 |
35 RenderBackground(size, cr, context); | 35 RenderBackground(size, cr, context); |
36 gtk_render_frame(context, cr, 0, 0, size.width(), size.height()); | 36 gtk_render_frame(context, cr, 0, 0, size.width(), size.height()); |
37 cairo_destroy(cr); | 37 cairo_destroy(cr); |
38 cairo_surface_destroy(surface); | 38 cairo_surface_destroy(surface); |
39 return bitmap; | 39 return bitmap; |
40 } | 40 } |
41 | 41 |
42 void PaintWidget(SkCanvas* canvas, | 42 void PaintWidget(cc::PaintCanvas* canvas, |
43 const gfx::Rect& rect, | 43 const gfx::Rect& rect, |
44 GtkStyleContext* context) { | 44 GtkStyleContext* context) { |
45 canvas->drawBitmap(GetWidgetBitmap(rect.size(), context), rect.x(), rect.y()); | 45 canvas->drawBitmap(GetWidgetBitmap(rect.size(), context), rect.x(), rect.y()); |
46 } | 46 } |
47 | 47 |
48 GtkStateFlags StateToStateFlags(NativeThemeGtk3::State state) { | 48 GtkStateFlags StateToStateFlags(NativeThemeGtk3::State state) { |
49 switch (state) { | 49 switch (state) { |
50 case NativeThemeGtk3::kDisabled: | 50 case NativeThemeGtk3::kDisabled: |
51 return GTK_STATE_FLAG_INSENSITIVE; | 51 return GTK_STATE_FLAG_INSENSITIVE; |
52 case NativeThemeGtk3::kHovered: | 52 case NativeThemeGtk3::kHovered: |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 SkColor NativeThemeGtk3::GetSystemColor(ColorId color_id) const { | 358 SkColor NativeThemeGtk3::GetSystemColor(ColorId color_id) const { |
359 if (color_cache_[color_id]) | 359 if (color_cache_[color_id]) |
360 return color_cache_[color_id].value(); | 360 return color_cache_[color_id].value(); |
361 | 361 |
362 SkColor color = SkColorFromColorId(color_id); | 362 SkColor color = SkColorFromColorId(color_id); |
363 color_cache_[color_id] = color; | 363 color_cache_[color_id] = color; |
364 return color; | 364 return color; |
365 } | 365 } |
366 | 366 |
367 void NativeThemeGtk3::PaintMenuPopupBackground( | 367 void NativeThemeGtk3::PaintMenuPopupBackground( |
368 SkCanvas* canvas, | 368 cc::PaintCanvas* canvas, |
369 const gfx::Size& size, | 369 const gfx::Size& size, |
370 const MenuBackgroundExtraParams& menu_background) const { | 370 const MenuBackgroundExtraParams& menu_background) const { |
371 PaintWidget(canvas, gfx::Rect(size), GetStyleContextFromCss("GtkMenu#menu")); | 371 PaintWidget(canvas, gfx::Rect(size), GetStyleContextFromCss("GtkMenu#menu")); |
372 } | 372 } |
373 | 373 |
374 void NativeThemeGtk3::PaintMenuItemBackground( | 374 void NativeThemeGtk3::PaintMenuItemBackground( |
375 SkCanvas* canvas, | 375 cc::PaintCanvas* canvas, |
376 State state, | 376 State state, |
377 const gfx::Rect& rect, | 377 const gfx::Rect& rect, |
378 const MenuItemExtraParams& menu_item) const { | 378 const MenuItemExtraParams& menu_item) const { |
379 auto context = GetStyleContextFromCss("GtkMenu#menu GtkMenuItem#menuitem"); | 379 auto context = GetStyleContextFromCss("GtkMenu#menu GtkMenuItem#menuitem"); |
380 gtk_style_context_set_state(context, StateToStateFlags(state)); | 380 gtk_style_context_set_state(context, StateToStateFlags(state)); |
381 PaintWidget(canvas, rect, context); | 381 PaintWidget(canvas, rect, context); |
382 } | 382 } |
383 | 383 |
384 void NativeThemeGtk3::PaintFrameTopArea( | 384 void NativeThemeGtk3::PaintFrameTopArea( |
385 SkCanvas* canvas, | 385 cc::PaintCanvas* canvas, |
386 State state, | 386 State state, |
387 const gfx::Rect& rect, | 387 const gfx::Rect& rect, |
388 const FrameTopAreaExtraParams& frame_top_area) const { | 388 const FrameTopAreaExtraParams& frame_top_area) const { |
389 auto context = GetStyleContextFromCss(frame_top_area.use_custom_frame | 389 auto context = GetStyleContextFromCss(frame_top_area.use_custom_frame |
390 ? "#headerbar.header-bar.titlebar" | 390 ? "#headerbar.header-bar.titlebar" |
391 : "GtkMenuBar#menubar"); | 391 : "GtkMenuBar#menubar"); |
392 RemoveBorders(context); | 392 RemoveBorders(context); |
393 gtk_style_context_set_state(context, | 393 gtk_style_context_set_state(context, |
394 frame_top_area.is_active | 394 frame_top_area.is_active |
395 ? GTK_STATE_FLAG_NORMAL | 395 ? GTK_STATE_FLAG_NORMAL |
396 : GTK_STATE_FLAG_BACKDROP); | 396 : GTK_STATE_FLAG_BACKDROP); |
397 | 397 |
398 SkBitmap bitmap = GetWidgetBitmap(rect.size(), context); | 398 SkBitmap bitmap = GetWidgetBitmap(rect.size(), context); |
399 | 399 |
400 if (frame_top_area.incognito) { | 400 if (frame_top_area.incognito) { |
401 bitmap = SkBitmapOperations::CreateHSLShiftedBitmap( | 401 bitmap = SkBitmapOperations::CreateHSLShiftedBitmap( |
402 bitmap, kDefaultTintFrameIncognito); | 402 bitmap, kDefaultTintFrameIncognito); |
403 } | 403 } |
404 | 404 |
405 canvas->drawBitmap(bitmap, rect.x(), rect.y()); | 405 canvas->drawBitmap(bitmap, rect.x(), rect.y()); |
406 } | 406 } |
407 | 407 |
408 } // namespace libgtkui | 408 } // namespace libgtkui |
OLD | NEW |