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

Unified Diff: ui/views/view.cc

Issue 12257016: (Not ready for review!) Toolbar and views high dpi support. Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Cleaned up more useless diffs. Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/drag_utils.cc ('k') | ui/views/widget/aero_tooltip_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/view.cc
diff --git a/ui/views/view.cc b/ui/views/view.cc
index a38ccb71afdc69bb0bbad15d554cf04de2d8b947..2afb5622b3cbfa86937c66a575c2cf61de6b4927 100644
--- a/ui/views/view.cc
+++ b/ui/views/view.cc
@@ -20,6 +20,7 @@
#include "ui/base/accessibility/accessibility_types.h"
#include "ui/base/dragdrop/drag_drop_types.h"
#include "ui/base/ui_base_switches.h"
+#include "ui/base/win/dpi.h"
#include "ui/compositor/compositor.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_animator.h"
@@ -665,6 +666,11 @@ void View::ConvertPointToScreen(const View* src, gfx::Point* p) {
if (widget) {
ConvertPointToWidget(src, p);
*p += widget->GetClientAreaBoundsInScreen().OffsetFromOrigin();
+#if defined(ENABLE_HIDPI)
+ static float dpi_scale = ui::GetDPIScale();
+ p->set_x(p->x()*dpi_scale);
+ p->set_y(p->y()*dpi_scale);
+#endif
}
}
@@ -676,6 +682,11 @@ void View::ConvertPointFromScreen(const View* dst, gfx::Point* p) {
const views::Widget* widget = dst->GetWidget();
if (!widget)
return;
+#if defined(ENABLE_HIDPI)
+ static float dpi_scale = ui::GetDPIScale();
+ p->set_x(p->x()/dpi_scale);
+ p->set_y(p->y()/dpi_scale);
+#endif
*p -= widget->GetClientAreaBoundsInScreen().OffsetFromOrigin();
views::View::ConvertPointFromWidget(dst, p);
}
@@ -735,6 +746,9 @@ void View::Paint(gfx::Canvas* canvas) {
// Non-empty clip, translate the graphics such that 0,0 corresponds to
// where this view is located (related to its parent).
+ static float scale = ui::GetDPIScale();
+ //canvas->Scale(scale,scale);
+ //canvas->Scale(1.0,1.0);
canvas->Translate(GetMirroredPosition().OffsetFromOrigin());
canvas->Transform(GetTransform());
@@ -764,6 +778,11 @@ bool View::get_use_acceleration_when_possible() {
}
// Input -----------------------------------------------------------------------
+void ScalePoint(gfx::Point* point) {
+ static float os_scale = ui::GetDPIScale();
+ point->set_x( point->x() / os_scale);
+ point->set_y( point->y() / os_scale);
+}
View* View::GetEventHandlerForPoint(const gfx::Point& point) {
// Walk the child Views recursively looking for the View that most
@@ -775,7 +794,9 @@ View* View::GetEventHandlerForPoint(const gfx::Point& point) {
gfx::Point point_in_child_coords(point);
ConvertPointToTarget(this, child, &point_in_child_coords);
- if (child->HitTestPoint(point_in_child_coords))
+ gfx::Point point_in_real_coords(point_in_child_coords);
+ ScalePoint(&point_in_real_coords);
+ if (child->HitTestPoint(point_in_real_coords))
return child->GetEventHandlerForPoint(point_in_child_coords);
}
return this;
« no previous file with comments | « ui/views/drag_utils.cc ('k') | ui/views/widget/aero_tooltip_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698