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_; |
352 if (params.opacity == InitParams::INFER_OPACITY) { | |
353 #if defined(OS_WIN) && defined(USE_AURA) | |
354 // By default, make all top-level windows but the main window transparent | |
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; | |
358 else | |
359 params.opacity = InitParams::OPAQUE_WINDOW; | |
360 #else | |
361 params.opacity = InitParams::OPAQUE_WINDOW; | |
362 #endif | |
363 } | |
364 | 347 |
365 if (ViewsDelegate::views_delegate) | 348 if (ViewsDelegate::views_delegate) |
366 ViewsDelegate::views_delegate->OnBeforeWidgetInit(¶ms, this); | 349 ViewsDelegate::views_delegate->OnBeforeWidgetInit(¶ms, this); |
367 | 350 |
sky
2013/12/12 23:58:14
On 367 handle the case of opacity still being INFE
Shrikant Kelkar
2013/12/17 07:06:21
Done.
Shrikant Kelkar
2013/12/17 07:06:21
Done.
Shrikant Kelkar
2013/12/17 07:06:21
Done.
| |
368 widget_delegate_ = params.delegate ? | 351 widget_delegate_ = params.delegate ? |
369 params.delegate : new DefaultWidgetDelegate(this, params); | 352 params.delegate : new DefaultWidgetDelegate(this, params); |
370 ownership_ = params.ownership; | 353 ownership_ = params.ownership; |
371 native_widget_ = CreateNativeWidget(params.native_widget, this)-> | 354 native_widget_ = CreateNativeWidget(params.native_widget, this)-> |
372 AsNativeWidgetPrivate(); | 355 AsNativeWidgetPrivate(); |
373 root_view_.reset(CreateRootView()); | 356 root_view_.reset(CreateRootView()); |
374 default_theme_provider_.reset(new ui::DefaultThemeProvider); | 357 default_theme_provider_.reset(new ui::DefaultThemeProvider); |
375 if (params.type == InitParams::TYPE_MENU) { | 358 if (params.type == InitParams::TYPE_MENU) { |
376 is_mouse_button_pressed_ = | 359 is_mouse_button_pressed_ = |
377 internal::NativeWidgetPrivate::IsMouseButtonDown(); | 360 internal::NativeWidgetPrivate::IsMouseButtonDown(); |
(...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1429 | 1412 |
1430 //////////////////////////////////////////////////////////////////////////////// | 1413 //////////////////////////////////////////////////////////////////////////////// |
1431 // internal::NativeWidgetPrivate, NativeWidget implementation: | 1414 // internal::NativeWidgetPrivate, NativeWidget implementation: |
1432 | 1415 |
1433 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { | 1416 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { |
1434 return this; | 1417 return this; |
1435 } | 1418 } |
1436 | 1419 |
1437 } // namespace internal | 1420 } // namespace internal |
1438 } // namespace views | 1421 } // namespace views |
OLD | NEW |