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

Side by Side Diff: ui/views/view.cc

Issue 2613343002: Allow a View to specify a non-default native theme (i.e. different from (Closed)
Patch Set: no "override" Created 3 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/view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. 5 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first.
6 6
7 #include "ui/views/view.h" 7 #include "ui/views/view.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 void View::SetBorder(std::unique_ptr<Border> b) { 917 void View::SetBorder(std::unique_ptr<Border> b) {
918 border_ = std::move(b); 918 border_ = std::move(b);
919 } 919 }
920 920
921 const ui::ThemeProvider* View::GetThemeProvider() const { 921 const ui::ThemeProvider* View::GetThemeProvider() const {
922 const Widget* widget = GetWidget(); 922 const Widget* widget = GetWidget();
923 return widget ? widget->GetThemeProvider() : nullptr; 923 return widget ? widget->GetThemeProvider() : nullptr;
924 } 924 }
925 925
926 const ui::NativeTheme* View::GetNativeTheme() const { 926 const ui::NativeTheme* View::GetNativeTheme() const {
927 if (native_theme_)
928 return native_theme_;
929
930 if (parent())
931 return parent()->GetNativeTheme();
932
927 const Widget* widget = GetWidget(); 933 const Widget* widget = GetWidget();
928 if (widget) 934 if (widget)
929 return widget->GetNativeTheme(); 935 return widget->GetNativeTheme();
930 936
931 return ui::NativeTheme::GetInstanceForNativeUi(); 937 return ui::NativeTheme::GetInstanceForNativeUi();
932 } 938 }
933 939
940 void View::SetNativeTheme(ui::NativeTheme* theme) {
941 ui::NativeTheme* original_native_theme = GetNativeTheme();
942 native_theme_ = theme;
943 if (native_theme_ != original_native_theme)
944 PropagateNativeThemeChanged(theme);
945 }
946
934 // RTL painting ---------------------------------------------------------------- 947 // RTL painting ----------------------------------------------------------------
935 948
936 void View::EnableCanvasFlippingForRTLUI(bool enable) { 949 void View::EnableCanvasFlippingForRTLUI(bool enable) {
937 flip_canvas_on_paint_for_rtl_ui_ = enable; 950 flip_canvas_on_paint_for_rtl_ui_ = enable;
938 } 951 }
939 952
940 // Input ----------------------------------------------------------------------- 953 // Input -----------------------------------------------------------------------
941 954
942 View* View::GetEventHandlerForPoint(const gfx::Point& point) { 955 View* View::GetEventHandlerForPoint(const gfx::Point& point) {
943 return GetEventHandlerForRect(gfx::Rect(point, gfx::Size(1, 1))); 956 return GetEventHandlerForRect(gfx::Rect(point, gfx::Size(1, 1)));
(...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after
1968 if (details.child == this) 1981 if (details.child == this)
1969 UnregisterAccelerators(true); 1982 UnregisterAccelerators(true);
1970 } 1983 }
1971 } 1984 }
1972 1985
1973 ViewHierarchyChanged(details); 1986 ViewHierarchyChanged(details);
1974 details.parent->needs_layout_ = true; 1987 details.parent->needs_layout_ = true;
1975 } 1988 }
1976 1989
1977 void View::PropagateNativeThemeChanged(const ui::NativeTheme* theme) { 1990 void View::PropagateNativeThemeChanged(const ui::NativeTheme* theme) {
1991 if (native_theme_ && native_theme_ != theme)
1992 return;
1993
1978 { 1994 {
1979 internal::ScopedChildrenLock lock(this); 1995 internal::ScopedChildrenLock lock(this);
1980 for (auto* child : children_) 1996 for (auto* child : children_)
1981 child->PropagateNativeThemeChanged(theme); 1997 child->PropagateNativeThemeChanged(theme);
1982 } 1998 }
1983 OnNativeThemeChanged(theme); 1999 OnNativeThemeChanged(theme);
1984 } 2000 }
1985 2001
1986 // Size and disposition -------------------------------------------------------- 2002 // Size and disposition --------------------------------------------------------
1987 2003
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
2530 // Message the RootView to do the drag and drop. That way if we're removed 2546 // Message the RootView to do the drag and drop. That way if we're removed
2531 // the RootView can detect it and avoid calling us back. 2547 // the RootView can detect it and avoid calling us back.
2532 gfx::Point widget_location(event.location()); 2548 gfx::Point widget_location(event.location());
2533 ConvertPointToWidget(this, &widget_location); 2549 ConvertPointToWidget(this, &widget_location);
2534 widget->RunShellDrag(this, data, widget_location, drag_operations, source); 2550 widget->RunShellDrag(this, data, widget_location, drag_operations, source);
2535 // WARNING: we may have been deleted. 2551 // WARNING: we may have been deleted.
2536 return true; 2552 return true;
2537 } 2553 }
2538 2554
2539 } // namespace views 2555 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698