| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 ownership(NATIVE_WIDGET_OWNS_WIDGET), | 111 ownership(NATIVE_WIDGET_OWNS_WIDGET), |
| 112 mirror_origin_in_rtl(false), | 112 mirror_origin_in_rtl(false), |
| 113 shadow_type(SHADOW_TYPE_DEFAULT), | 113 shadow_type(SHADOW_TYPE_DEFAULT), |
| 114 remove_standard_frame(false), | 114 remove_standard_frame(false), |
| 115 use_system_default_icon(false), | 115 use_system_default_icon(false), |
| 116 show_state(ui::SHOW_STATE_DEFAULT), | 116 show_state(ui::SHOW_STATE_DEFAULT), |
| 117 double_buffer(false), | 117 double_buffer(false), |
| 118 parent(NULL), | 118 parent(NULL), |
| 119 native_widget(NULL), | 119 native_widget(NULL), |
| 120 desktop_window_tree_host(NULL), | 120 desktop_window_tree_host(NULL), |
| 121 top_level(false), | |
| 122 layer_type(aura::WINDOW_LAYER_TEXTURED), | 121 layer_type(aura::WINDOW_LAYER_TEXTURED), |
| 123 context(NULL), | 122 context(NULL), |
| 124 force_show_in_taskbar(false) { | 123 force_show_in_taskbar(false) { |
| 125 } | 124 } |
| 126 | 125 |
| 127 Widget::InitParams::InitParams(Type type) | 126 Widget::InitParams::InitParams(Type type) |
| 128 : type(type), | 127 : type(type), |
| 129 delegate(NULL), | 128 delegate(NULL), |
| 130 child(type == TYPE_CONTROL), | 129 child(false), |
| 131 opacity(INFER_OPACITY), | 130 opacity(INFER_OPACITY), |
| 132 accept_events(true), | 131 accept_events(true), |
| 133 activatable(ACTIVATABLE_DEFAULT), | 132 activatable(ACTIVATABLE_DEFAULT), |
| 134 keep_on_top(type == TYPE_MENU || type == TYPE_DRAG), | 133 keep_on_top(type == TYPE_MENU || type == TYPE_DRAG), |
| 135 visible_on_all_workspaces(false), | 134 visible_on_all_workspaces(false), |
| 136 ownership(NATIVE_WIDGET_OWNS_WIDGET), | 135 ownership(NATIVE_WIDGET_OWNS_WIDGET), |
| 137 mirror_origin_in_rtl(false), | 136 mirror_origin_in_rtl(false), |
| 138 shadow_type(SHADOW_TYPE_DEFAULT), | 137 shadow_type(SHADOW_TYPE_DEFAULT), |
| 139 remove_standard_frame(false), | 138 remove_standard_frame(false), |
| 140 use_system_default_icon(false), | 139 use_system_default_icon(false), |
| 141 show_state(ui::SHOW_STATE_DEFAULT), | 140 show_state(ui::SHOW_STATE_DEFAULT), |
| 142 double_buffer(false), | 141 double_buffer(false), |
| 143 parent(NULL), | 142 parent(NULL), |
| 144 native_widget(NULL), | 143 native_widget(NULL), |
| 145 desktop_window_tree_host(NULL), | 144 desktop_window_tree_host(NULL), |
| 146 top_level(false), | |
| 147 layer_type(aura::WINDOW_LAYER_TEXTURED), | 145 layer_type(aura::WINDOW_LAYER_TEXTURED), |
| 148 context(NULL), | 146 context(NULL), |
| 149 force_show_in_taskbar(false) { | 147 force_show_in_taskbar(false) { |
| 150 } | 148 } |
| 151 | 149 |
| 152 Widget::InitParams::~InitParams() { | 150 Widget::InitParams::~InitParams() { |
| 153 } | 151 } |
| 154 | 152 |
| 155 //////////////////////////////////////////////////////////////////////////////// | 153 //////////////////////////////////////////////////////////////////////////////// |
| 156 // Widget, public: | 154 // Widget, public: |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 return CreateWindowWithBounds(delegate, gfx::Rect()); | 193 return CreateWindowWithBounds(delegate, gfx::Rect()); |
| 196 } | 194 } |
| 197 | 195 |
| 198 // static | 196 // static |
| 199 Widget* Widget::CreateWindowWithBounds(WidgetDelegate* delegate, | 197 Widget* Widget::CreateWindowWithBounds(WidgetDelegate* delegate, |
| 200 const gfx::Rect& bounds) { | 198 const gfx::Rect& bounds) { |
| 201 Widget* widget = new Widget; | 199 Widget* widget = new Widget; |
| 202 Widget::InitParams params; | 200 Widget::InitParams params; |
| 203 params.bounds = bounds; | 201 params.bounds = bounds; |
| 204 params.delegate = delegate; | 202 params.delegate = delegate; |
| 205 params.top_level = true; | |
| 206 widget->Init(params); | 203 widget->Init(params); |
| 207 return widget; | 204 return widget; |
| 208 } | 205 } |
| 209 | 206 |
| 210 // static | 207 // static |
| 211 Widget* Widget::CreateWindowWithParent(WidgetDelegate* delegate, | 208 Widget* Widget::CreateWindowWithParent(WidgetDelegate* delegate, |
| 212 gfx::NativeView parent) { | 209 gfx::NativeView parent) { |
| 213 return CreateWindowWithParentAndBounds(delegate, parent, gfx::Rect()); | 210 return CreateWindowWithParentAndBounds(delegate, parent, gfx::Rect()); |
| 214 } | 211 } |
| 215 | 212 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 bool Widget::RequiresNonClientView(InitParams::Type type) { | 322 bool Widget::RequiresNonClientView(InitParams::Type type) { |
| 326 return type == InitParams::TYPE_WINDOW || | 323 return type == InitParams::TYPE_WINDOW || |
| 327 type == InitParams::TYPE_PANEL || | 324 type == InitParams::TYPE_PANEL || |
| 328 type == InitParams::TYPE_BUBBLE; | 325 type == InitParams::TYPE_BUBBLE; |
| 329 } | 326 } |
| 330 | 327 |
| 331 void Widget::Init(const InitParams& in_params) { | 328 void Widget::Init(const InitParams& in_params) { |
| 332 TRACE_EVENT0("views", "Widget::Init"); | 329 TRACE_EVENT0("views", "Widget::Init"); |
| 333 InitParams params = in_params; | 330 InitParams params = in_params; |
| 334 | 331 |
| 335 is_top_level_ = params.top_level || | 332 params.child |= (params.type == InitParams::TYPE_CONTROL); |
| 336 (!params.child && | 333 is_top_level_ = (!params.child && params.type != InitParams::TYPE_TOOLTIP); |
| 337 params.type != InitParams::TYPE_CONTROL && | |
| 338 params.type != InitParams::TYPE_TOOLTIP); | |
| 339 params.top_level = is_top_level_; | |
| 340 | 334 |
| 341 if (params.opacity == views::Widget::InitParams::INFER_OPACITY && | 335 if (params.opacity == views::Widget::InitParams::INFER_OPACITY && |
| 342 params.type != views::Widget::InitParams::TYPE_WINDOW && | 336 params.type != views::Widget::InitParams::TYPE_WINDOW && |
| 343 params.type != views::Widget::InitParams::TYPE_PANEL) | 337 params.type != views::Widget::InitParams::TYPE_PANEL) |
| 344 params.opacity = views::Widget::InitParams::OPAQUE_WINDOW; | 338 params.opacity = views::Widget::InitParams::OPAQUE_WINDOW; |
| 345 | 339 |
| 346 if (ViewsDelegate::views_delegate) | 340 if (ViewsDelegate::views_delegate) |
| 347 ViewsDelegate::views_delegate->OnBeforeWidgetInit(¶ms, this); | 341 ViewsDelegate::views_delegate->OnBeforeWidgetInit(¶ms, this); |
| 348 | 342 |
| 349 if (params.opacity == views::Widget::InitParams::INFER_OPACITY) | 343 if (params.opacity == views::Widget::InitParams::INFER_OPACITY) |
| (...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1511 | 1505 |
| 1512 //////////////////////////////////////////////////////////////////////////////// | 1506 //////////////////////////////////////////////////////////////////////////////// |
| 1513 // internal::NativeWidgetPrivate, NativeWidget implementation: | 1507 // internal::NativeWidgetPrivate, NativeWidget implementation: |
| 1514 | 1508 |
| 1515 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { | 1509 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { |
| 1516 return this; | 1510 return this; |
| 1517 } | 1511 } |
| 1518 | 1512 |
| 1519 } // namespace internal | 1513 } // namespace internal |
| 1520 } // namespace views | 1514 } // namespace views |
| OLD | NEW |