Commit e7007fa7 authored by Hwanseung Lee's avatar Hwanseung Lee Committed by Commit Bot

Convert enum to enum class for PaintButtonMode

Use enum class instead of enum for PaintButtonMode
enum class is more type safety.

Bug: 940736
Change-Id: If4135af54748a1f9383aba3605916a593aaba0cc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1824052
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#701467}
parent b2075eb5
...@@ -1444,7 +1444,7 @@ void MenuController::StartDrag(SubmenuView* source, ...@@ -1444,7 +1444,7 @@ void MenuController::StartDrag(SubmenuView* source,
float raster_scale = ScaleFactorForDragFromWidget(source->GetWidget()); float raster_scale = ScaleFactorForDragFromWidget(source->GetWidget());
gfx::Canvas canvas(item->size(), raster_scale, false /* opaque */); gfx::Canvas canvas(item->size(), raster_scale, false /* opaque */);
item->PaintButton(&canvas, MenuItemView::PB_FOR_DRAG); item->PaintButton(&canvas, MenuItemView::PaintButtonMode::kForDrag);
gfx::ImageSkia image(gfx::ImageSkiaRep(canvas.GetBitmap(), raster_scale)); gfx::ImageSkia image(gfx::ImageSkiaRep(canvas.GetBitmap(), raster_scale));
std::unique_ptr<OSExchangeData> data(std::make_unique<OSExchangeData>()); std::unique_ptr<OSExchangeData> data(std::make_unique<OSExchangeData>());
......
...@@ -515,7 +515,7 @@ void MenuItemView::SetIconView(ImageView* icon_view) { ...@@ -515,7 +515,7 @@ void MenuItemView::SetIconView(ImageView* icon_view) {
} }
void MenuItemView::OnPaint(gfx::Canvas* canvas) { void MenuItemView::OnPaint(gfx::Canvas* canvas) {
PaintButton(canvas, PB_NORMAL); PaintButton(canvas, PaintButtonMode::kNormal);
} }
gfx::Size MenuItemView::CalculatePreferredSize() const { gfx::Size MenuItemView::CalculatePreferredSize() const {
...@@ -971,7 +971,7 @@ void MenuItemView::AdjustBoundsForRTLUI(gfx::Rect* rect) const { ...@@ -971,7 +971,7 @@ void MenuItemView::AdjustBoundsForRTLUI(gfx::Rect* rect) const {
void MenuItemView::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) { void MenuItemView::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) {
const MenuConfig& config = MenuConfig::instance(); const MenuConfig& config = MenuConfig::instance();
bool render_selection = bool render_selection =
(mode == PB_NORMAL && IsSelected() && (mode == PaintButtonMode::kNormal && IsSelected() &&
parent_menu_item_->GetSubmenu()->GetShowSelection(this) && parent_menu_item_->GetSubmenu()->GetShowSelection(this) &&
(NonIconChildViewsCount() == 0)); (NonIconChildViewsCount() == 0));
if (forced_visual_selection_.has_value()) if (forced_visual_selection_.has_value())
...@@ -1019,7 +1019,7 @@ void MenuItemView::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) { ...@@ -1019,7 +1019,7 @@ void MenuItemView::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) {
gfx::Rect text_bounds(label_start, top_margin, width, available_height); gfx::Rect text_bounds(label_start, top_margin, width, available_height);
text_bounds.set_x(GetMirroredXForRect(text_bounds)); text_bounds.set_x(GetMirroredXForRect(text_bounds));
int flags = GetDrawStringFlags(); int flags = GetDrawStringFlags();
if (mode == PB_FOR_DRAG) if (mode == PaintButtonMode::kForDrag)
flags |= gfx::Canvas::NO_SUBPIXEL_RENDERING; flags |= gfx::Canvas::NO_SUBPIXEL_RENDERING;
canvas->DrawStringRectWithFlags(title(), style.font_list, style.foreground, canvas->DrawStringRectWithFlags(title(), style.font_list, style.foreground,
text_bounds, flags); text_bounds, flags);
......
...@@ -395,7 +395,7 @@ class VIEWS_EXPORT MenuItemView : public View { ...@@ -395,7 +395,7 @@ class VIEWS_EXPORT MenuItemView : public View {
friend class test::TestMenuItemViewNotShown; // for access to |submenu_|; friend class test::TestMenuItemViewNotShown; // for access to |submenu_|;
friend class TestMenuItemView; // For access to AddEmptyMenus(); friend class TestMenuItemView; // For access to AddEmptyMenus();
enum PaintButtonMode { PB_NORMAL, PB_FOR_DRAG }; enum class PaintButtonMode { kNormal, kForDrag };
// Calculates all sizes that we can from the OS. // Calculates all sizes that we can from the OS.
// //
...@@ -432,8 +432,8 @@ class VIEWS_EXPORT MenuItemView : public View { ...@@ -432,8 +432,8 @@ class VIEWS_EXPORT MenuItemView : public View {
// necessary. // necessary.
void AdjustBoundsForRTLUI(gfx::Rect* rect) const; void AdjustBoundsForRTLUI(gfx::Rect* rect) const;
// Actual paint implementation. If mode is PB_FOR_DRAG, portions of the menu // Actual paint implementation. If mode is kForDrag, portions of the menu are
// are not rendered. // not rendered.
void PaintButton(gfx::Canvas* canvas, PaintButtonMode mode); void PaintButton(gfx::Canvas* canvas, PaintButtonMode mode);
// Helper function for PaintButton(), draws the background for the button if // Helper function for PaintButton(), draws the background for the button if
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment