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

Side by Side Diff: ui/views/controls/menu/menu_separator_win.cc

Issue 851853002: It is time. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Trying to reup because the last upload failed. Created 5 years, 11 months 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 unified diff | Download patch
« no previous file with comments | « ui/views/controls/menu/menu_separator_views.cc ('k') | ui/views/controls/menu/menu_types.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/views/controls/menu/menu_separator.h"
6
7 #include <windows.h>
8 #include <uxtheme.h>
9 #include <Vssym32.h>
10
11 #include "ui/gfx/canvas.h"
12 #include "ui/gfx/rect.h"
13 #include "ui/gfx/win/dpi.h"
14 #include "ui/native_theme/native_theme.h"
15 #include "ui/native_theme/native_theme_aura.h"
16 #include "ui/views/controls/menu/menu_config.h"
17 #include "ui/views/controls/menu/menu_item_view.h"
18
19 namespace views {
20
21 void MenuSeparator::OnPaint(gfx::Canvas* canvas) {
22 const MenuConfig& config = parent_menu_item_->GetMenuConfig();
23
24 if (config.native_theme == ui::NativeThemeAura::instance()) {
25 OnPaintAura(canvas);
26 return;
27 }
28
29 gfx::Rect separator_bounds = GetPaintBounds();
30 if (config.render_gutter) {
31 // If render_gutter is true, we're on Vista and need to render the
32 // gutter, then indent the separator from the gutter.
33 gfx::Rect gutter_bounds(MenuItemView::label_start() -
34 config.gutter_to_label - config.gutter_width, 0,
35 config.gutter_width, height());
36 ui::NativeTheme::ExtraParams extra;
37 config.native_theme->Paint(
38 canvas->sk_canvas(), ui::NativeTheme::kMenuPopupGutter,
39 ui::NativeTheme::kNormal, gutter_bounds, extra);
40 separator_bounds.set_x(gutter_bounds.x() + config.gutter_width);
41 }
42
43 ui::NativeTheme::ExtraParams extra;
44 extra.menu_separator.has_gutter = config.render_gutter;
45
46 // Hack to get the separator to display correctly on Windows where we may
47 // have fractional scales. We move the separator 1 pixel down to ensure that
48 // it falls within the clipping rect which is scaled up.
49 float device_scale = gfx::win::GetDeviceScaleFactor();
50 bool is_fractional_scale =
51 (device_scale - static_cast<int>(device_scale) != 0);
52 if (is_fractional_scale && separator_bounds.y() == 0)
53 separator_bounds.set_y(1);
54
55 config.native_theme->Paint(
56 canvas->sk_canvas(), ui::NativeTheme::kMenuPopupSeparator,
57 ui::NativeTheme::kNormal, separator_bounds, extra);
58 }
59
60 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/menu/menu_separator_views.cc ('k') | ui/views/controls/menu/menu_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698