Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #include "ui/views/widget/widget.h" | 5 #include "ui/views/widget/widget.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 DISALLOW_COPY_AND_ASSIGN(DefaultWidgetDelegate); | 105 DISALLOW_COPY_AND_ASSIGN(DefaultWidgetDelegate); |
| 106 }; | 106 }; |
| 107 | 107 |
| 108 //////////////////////////////////////////////////////////////////////////////// | 108 //////////////////////////////////////////////////////////////////////////////// |
| 109 // Widget, InitParams: | 109 // Widget, InitParams: |
| 110 | 110 |
| 111 Widget::InitParams::InitParams() | 111 Widget::InitParams::InitParams() |
| 112 : type(TYPE_WINDOW), | 112 : type(TYPE_WINDOW), |
| 113 delegate(NULL), | 113 delegate(NULL), |
| 114 child(false), | 114 child(false), |
| 115 opacity((ViewsDelegate::views_delegate && | 115 opacity(INFER_OPACITY), |
| 116 ViewsDelegate::views_delegate->UseTransparentWindows()) ? | |
| 117 TRANSLUCENT_WINDOW : INFER_OPACITY), | |
| 118 accept_events(true), | 116 accept_events(true), |
| 119 can_activate(true), | 117 can_activate(true), |
| 120 keep_on_top(false), | 118 keep_on_top(false), |
| 121 ownership(NATIVE_WIDGET_OWNS_WIDGET), | 119 ownership(NATIVE_WIDGET_OWNS_WIDGET), |
| 122 mirror_origin_in_rtl(false), | 120 mirror_origin_in_rtl(false), |
| 123 has_dropshadow(false), | 121 has_dropshadow(false), |
| 124 remove_standard_frame(false), | 122 remove_standard_frame(false), |
| 125 use_system_default_icon(false), | 123 use_system_default_icon(false), |
| 126 show_state(ui::SHOW_STATE_DEFAULT), | 124 show_state(ui::SHOW_STATE_DEFAULT), |
| 127 double_buffer(false), | 125 double_buffer(false), |
| 128 parent(NULL), | 126 parent(NULL), |
| 129 native_widget(NULL), | 127 native_widget(NULL), |
| 130 desktop_root_window_host(NULL), | 128 desktop_root_window_host(NULL), |
| 131 top_level(false), | 129 top_level(false), |
| 132 layer_type(ui::LAYER_TEXTURED), | 130 layer_type(ui::LAYER_TEXTURED), |
| 133 context(NULL) { | 131 context(NULL) { |
| 134 } | 132 } |
| 135 | 133 |
| 136 Widget::InitParams::InitParams(Type type) | 134 Widget::InitParams::InitParams(Type type) |
| 137 : type(type), | 135 : type(type), |
| 138 delegate(NULL), | 136 delegate(NULL), |
| 139 child(type == TYPE_CONTROL), | 137 child(type == TYPE_CONTROL), |
| 140 opacity(((type == TYPE_WINDOW || type == TYPE_PANEL) && | 138 opacity(INFER_OPACITY), |
| 141 ViewsDelegate::views_delegate && | |
| 142 ViewsDelegate::views_delegate->UseTransparentWindows()) ? | |
| 143 TRANSLUCENT_WINDOW : INFER_OPACITY), | |
| 144 accept_events(true), | 139 accept_events(true), |
| 145 can_activate(type != TYPE_POPUP && type != TYPE_MENU && | 140 can_activate(type != TYPE_POPUP && type != TYPE_MENU && |
| 146 type != TYPE_DRAG), | 141 type != TYPE_DRAG), |
| 147 keep_on_top(type == TYPE_MENU || type == TYPE_DRAG), | 142 keep_on_top(type == TYPE_MENU || type == TYPE_DRAG), |
| 148 ownership(NATIVE_WIDGET_OWNS_WIDGET), | 143 ownership(NATIVE_WIDGET_OWNS_WIDGET), |
| 149 mirror_origin_in_rtl(false), | 144 mirror_origin_in_rtl(false), |
| 150 has_dropshadow(false), | 145 has_dropshadow(false), |
| 151 remove_standard_frame(false), | 146 remove_standard_frame(false), |
| 152 use_system_default_icon(false), | 147 use_system_default_icon(false), |
| 153 show_state(ui::SHOW_STATE_DEFAULT), | 148 show_state(ui::SHOW_STATE_DEFAULT), |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 342 | 337 |
| 343 void Widget::Init(const InitParams& in_params) { | 338 void Widget::Init(const InitParams& in_params) { |
| 344 TRACE_EVENT0("views", "Widget::Init"); | 339 TRACE_EVENT0("views", "Widget::Init"); |
| 345 InitParams params = in_params; | 340 InitParams params = in_params; |
| 346 | 341 |
| 347 is_top_level_ = params.top_level || | 342 is_top_level_ = params.top_level || |
| 348 (!params.child && | 343 (!params.child && |
| 349 params.type != InitParams::TYPE_CONTROL && | 344 params.type != InitParams::TYPE_CONTROL && |
| 350 params.type != InitParams::TYPE_TOOLTIP); | 345 params.type != InitParams::TYPE_TOOLTIP); |
| 351 params.top_level = is_top_level_; | 346 params.top_level = is_top_level_; |
| 347 | |
| 352 if (params.opacity == InitParams::INFER_OPACITY) { | 348 if (params.opacity == InitParams::INFER_OPACITY) { |
| 353 #if defined(OS_WIN) && defined(USE_AURA) | 349 if (ViewsDelegate::views_delegate && |
| 354 // By default, make all top-level windows but the main window transparent | 350 ViewsDelegate::views_delegate->UseTransparentWindows(¶ms)) |
| 355 // initially so that they can be made to fade in. | |
| 356 if (is_top_level_ && params.type != InitParams::TYPE_WINDOW) | |
| 357 params.opacity = InitParams::TRANSLUCENT_WINDOW; | 351 params.opacity = InitParams::TRANSLUCENT_WINDOW; |
| 358 else | 352 else |
| 359 params.opacity = InitParams::OPAQUE_WINDOW; | 353 params.opacity = InitParams::OPAQUE_WINDOW; |
| 360 #else | |
| 361 params.opacity = InitParams::OPAQUE_WINDOW; | |
| 362 #endif | |
| 363 } | 354 } |
| 364 | 355 |
| 365 if (ViewsDelegate::views_delegate) | 356 if (ViewsDelegate::views_delegate) |
| 366 ViewsDelegate::views_delegate->OnBeforeWidgetInit(¶ms, this); | 357 ViewsDelegate::views_delegate->OnBeforeWidgetInit(¶ms, this); |
|
sky
2013/12/12 21:07:23
Sorry, I just remembered this function. Can all th
| |
| 367 | 358 |
| 368 widget_delegate_ = params.delegate ? | 359 widget_delegate_ = params.delegate ? |
| 369 params.delegate : new DefaultWidgetDelegate(this, params); | 360 params.delegate : new DefaultWidgetDelegate(this, params); |
| 370 ownership_ = params.ownership; | 361 ownership_ = params.ownership; |
| 371 native_widget_ = CreateNativeWidget(params.native_widget, this)-> | 362 native_widget_ = CreateNativeWidget(params.native_widget, this)-> |
| 372 AsNativeWidgetPrivate(); | 363 AsNativeWidgetPrivate(); |
| 373 root_view_.reset(CreateRootView()); | 364 root_view_.reset(CreateRootView()); |
| 374 default_theme_provider_.reset(new ui::DefaultThemeProvider); | 365 default_theme_provider_.reset(new ui::DefaultThemeProvider); |
| 375 if (params.type == InitParams::TYPE_MENU) { | 366 if (params.type == InitParams::TYPE_MENU) { |
| 376 is_mouse_button_pressed_ = | 367 is_mouse_button_pressed_ = |
| (...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1429 | 1420 |
| 1430 //////////////////////////////////////////////////////////////////////////////// | 1421 //////////////////////////////////////////////////////////////////////////////// |
| 1431 // internal::NativeWidgetPrivate, NativeWidget implementation: | 1422 // internal::NativeWidgetPrivate, NativeWidget implementation: |
| 1432 | 1423 |
| 1433 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { | 1424 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { |
| 1434 return this; | 1425 return this; |
| 1435 } | 1426 } |
| 1436 | 1427 |
| 1437 } // namespace internal | 1428 } // namespace internal |
| 1438 } // namespace views | 1429 } // namespace views |
| OLD | NEW |