Skip to content

Commit

Permalink
Delete folder_*_rtl.png.
Browse files Browse the repository at this point in the history
Using a canvas flip in tree_view.cc eliminates the last use of these.

Bug: 564112
Change-Id: I18f57cb9a8cd36977d9fb90eae8f9e9cb4f525c7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1677627
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Mitsuru Oshima <oshima@chromium.org>
Reviewed-by: Michael Wasserman <msw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#673553}
  • Loading branch information
pkasting authored and Commit Bot committed Jun 29, 2019
1 parent 8e75b51 commit 94aff1a
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 24 deletions.
Binary file not shown.
Binary file not shown.
1 change: 0 additions & 1 deletion ui/resources/ui_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@
<structure type="chrome_scaled_image" name="IDR_EASY_UNLOCK_UNLOCKED_HOVER" file="common/easy_unlock_unlocked_hover.png" />
<structure type="chrome_scaled_image" name="IDR_EASY_UNLOCK_UNLOCKED_PRESSED" file="common/easy_unlock_unlocked_pressed.png" />
<structure type="chrome_scaled_image" name="IDR_FOLDER_CLOSED" file="common/folder_closed.png" />
<structure type="chrome_scaled_image" name="IDR_FOLDER_CLOSED_RTL" file="common/folder_closed_rtl.png" />
<structure type="chrome_scaled_image" name="IDR_SEND_TAB_TO_SELF_ICON_LIGHT" file="common/send_tab_to_self_light_mode_icon.png" />
<structure type="chrome_scaled_image" name="IDR_SEND_TAB_TO_SELF_ICON_DARK" file="common/send_tab_to_self_dark_mode_icon.png" />
</if>
Expand Down
52 changes: 30 additions & 22 deletions ui/views/controls/tree/tree_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_skia_operations.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/scoped_canvas.h"
#include "ui/gfx/skia_util.h"
#include "ui/native_theme/native_theme.h"
#include "ui/resources/grit/ui_resources.h"
Expand Down Expand Up @@ -58,6 +59,14 @@ static constexpr int kIndent = 20;

namespace {

void PaintRowIcon(gfx::Canvas* canvas,
const gfx::ImageSkia& icon,
int x,
const gfx::Rect& rect) {
canvas->DrawImageInt(icon, rect.x() + x,
rect.y() + (rect.height() - icon.height()) / 2);
}

bool EventIsDoubleTapOrClick(const ui::LocatedEvent& event) {
if (event.type() == ui::ET_GESTURE_TAP)
return event.AsGestureEvent()->details().tap_count() == 2;
Expand All @@ -81,14 +90,11 @@ TreeView::TreeView()
} else {
// TODO(ellyjones): if the pre-Harmony codepath goes away, merge
// closed_icon_ and open_icon_.
closed_icon_ =
*ui::ResourceBundle::GetSharedInstance()
.GetImageNamed((base::i18n::IsRTL() ? IDR_FOLDER_CLOSED_RTL
: IDR_FOLDER_CLOSED))
.ToImageSkia();
closed_icon_ = *ui::ResourceBundle::GetSharedInstance()
.GetImageNamed(IDR_FOLDER_CLOSED)
.ToImageSkia();
open_icon_ = *ui::ResourceBundle::GetSharedInstance()
.GetImageNamed((base::i18n::IsRTL() ? IDR_FOLDER_OPEN_RTL
: IDR_FOLDER_OPEN))
.GetImageNamed(IDR_FOLDER_OPEN)
.ToImageSkia();
}
text_offset_ = closed_icon_.width() + kImagePadding + kImagePadding +
Expand Down Expand Up @@ -860,22 +866,24 @@ void TreeView::PaintExpandControl(gfx::Canvas* canvas,
void TreeView::PaintNodeIcon(gfx::Canvas* canvas,
InternalNode* node,
const gfx::Rect& bounds) {
gfx::ImageSkia icon;
int icon_index = model_->GetIconIndex(node->model_node());
if (icon_index != -1)
icon = icons_[icon_index];
else if (node->is_expanded())
icon = open_icon_;
else
icon = closed_icon_;
int icon_x = kArrowRegionSize + kImagePadding +
(open_icon_.width() - icon.width()) / 2;
if (base::i18n::IsRTL())
icon_x = bounds.right() - icon_x - open_icon_.width();
else
icon_x += bounds.x();
canvas->DrawImageInt(icon, icon_x,
bounds.y() + (bounds.height() - icon.height()) / 2);
int icon_x = kArrowRegionSize + kImagePadding;
if (icon_index == -1) {
// Flip just the |bounds| region of |canvas|.
gfx::ScopedCanvas scoped_canvas(canvas);
canvas->Translate(gfx::Vector2d(bounds.x(), 0));
scoped_canvas.FlipIfRTL(bounds.width());
// Now paint the icon local to that flipped region.
PaintRowIcon(canvas, node->is_expanded() ? open_icon_ : closed_icon_,
icon_x,
gfx::Rect(0, bounds.y(), bounds.width(), bounds.height()));
} else {
const gfx::ImageSkia& icon = icons_[icon_index];
icon_x += (open_icon_.width() - icon.width()) / 2;
if (base::i18n::IsRTL())
icon_x = bounds.width() - icon_x - icon.width();
PaintRowIcon(canvas, icon, icon_x, bounds);
}
}

TreeView::InternalNode* TreeView::GetInternalNodeForModelNode(
Expand Down
Binary file not shown.
Binary file not shown.
1 change: 0 additions & 1 deletion ui/views/resources/views_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
<structure type="chrome_scaled_image" name="IDR_CONTENT_LEFT_SIDE" file="content_left_side.png" />
<structure type="chrome_scaled_image" name="IDR_CONTENT_RIGHT_SIDE" file="content_right_side.png" />
<structure type="chrome_scaled_image" name="IDR_FOLDER_OPEN" file="common/folder_open.png" />
<structure type="chrome_scaled_image" name="IDR_FOLDER_OPEN_RTL" file="common/folder_open_rtl.png" />
<structure type="chrome_scaled_image" name="IDR_FRAME" file="frame_default.png" />
<structure type="chrome_scaled_image" name="IDR_FRAME_INACTIVE" file="frame_default_inactive.png" />
<structure type="chrome_scaled_image" name="IDR_MAXIMIZE" file="maximize.png" />
Expand Down

0 comments on commit 94aff1a

Please sign in to comment.