| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "chrome/browser/android/vr_shell/ui_elements/system_indicator.h" | 5 #include "chrome/browser/android/vr_shell/ui_elements/system_indicator.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "chrome/browser/android/vr_shell/textures/system_indicator_texture.h" | 8 #include "chrome/browser/android/vr_shell/textures/system_indicator_texture.h" |
| 9 | 9 |
| 10 namespace vr_shell { | 10 namespace vr_shell { |
| 11 | 11 |
| 12 SystemIndicator::SystemIndicator(int preferred_width, | 12 SystemIndicator::SystemIndicator(int id, |
| 13 int preferred_width, |
| 13 float height_meters, | 14 float height_meters, |
| 14 const gfx::VectorIcon& icon, | 15 const gfx::VectorIcon& icon, |
| 15 int string_id) | 16 int string_id) |
| 16 : TexturedElement(preferred_width), height_meters_(height_meters) { | 17 : TexturedElement(id, preferred_width), height_meters_(height_meters) { |
| 17 if (string_id != 0) { | 18 if (string_id != 0) { |
| 18 texture_ = base::MakeUnique<SystemIndicatorTexture>(icon, string_id); | 19 texture_ = base::MakeUnique<SystemIndicatorTexture>(icon, string_id); |
| 19 } else { | 20 } else { |
| 20 texture_ = base::MakeUnique<SystemIndicatorTexture>(icon); | 21 texture_ = base::MakeUnique<SystemIndicatorTexture>(icon); |
| 21 } | 22 } |
| 22 } | 23 } |
| 23 | 24 |
| 24 void SystemIndicator::UpdateElementSize() { | 25 void SystemIndicator::UpdateElementSize() { |
| 25 gfx::SizeF drawn_size = GetTexture()->GetDrawnSize(); | 26 gfx::SizeF drawn_size = GetTexture()->GetDrawnSize(); |
| 26 float width = height_meters_ * drawn_size.width() / drawn_size.height(); | 27 float width = height_meters_ * drawn_size.width() / drawn_size.height(); |
| 27 set_size({width, height_meters_, 1}); | 28 set_size({width, height_meters_, 1}); |
| 28 } | 29 } |
| 29 | 30 |
| 30 SystemIndicator::~SystemIndicator() = default; | 31 SystemIndicator::~SystemIndicator() = default; |
| 31 | 32 |
| 32 UiTexture* SystemIndicator::GetTexture() const { | 33 UiTexture* SystemIndicator::GetTexture() const { |
| 33 return texture_.get(); | 34 return texture_.get(); |
| 34 } | 35 } |
| 35 | 36 |
| 36 } // namespace vr_shell | 37 } // namespace vr_shell |
| OLD | NEW |