1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_CAMERA_CAMERA_THEME_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_CAMERA_CAMERA_THEME_H 18 19 #include "base/geometry/size.h" 20 #include "core/components/common/properties/color.h" 21 #include "core/components/common/properties/edge.h" 22 #include "core/components/common/properties/text_style.h" 23 #include "core/components/theme/theme.h" 24 #include "core/components/theme/theme_constants.h" 25 #include "core/components/theme/theme_constants_defines.h" 26 27 namespace OHOS::Ace { 28 29 /* 30 * CameraTheme defines color and styles of Camera. CameraTheme should be built 31 * using CameraTheme::Builder. 32 */ 33 class CameraTheme : public virtual Theme { 34 DECLARE_ACE_TYPE(CameraTheme, Theme); 35 36 public: 37 class Builder { 38 public: 39 Builder() = default; 40 ~Builder() = default; 41 Build(const RefPtr<ThemeConstants> & themeConstants)42 RefPtr<CameraTheme> Build(const RefPtr<ThemeConstants>& themeConstants) const 43 { 44 RefPtr<CameraTheme> theme = AceType::Claim(new CameraTheme()); 45 if (!themeConstants) { 46 return theme; 47 } 48 theme->bufferSize_ = Size(themeConstants->GetDimension(THEME_CAMERA_BUFFER_WIDTH).Value(), 49 themeConstants->GetDimension(THEME_CAMERA_BUFFER_HEIGHT).Value()); 50 #if defined(PREVIEW) 51 theme->errorTextStyle_.SetFontSize(themeConstants->GetDimension(THEME_VIDEO_TEXT_FONTSIZE)); 52 theme->errorTextStyle_.SetTextColor(themeConstants->GetColor(THEME_VIDEO_ERROR_TEXT_COLOR)); 53 #endif 54 return theme; 55 } 56 }; 57 58 ~CameraTheme() override = default; 59 GetBufferSize()60 const Size& GetBufferSize() const 61 { 62 return bufferSize_; 63 } 64 65 #if defined(PREVIEW) GetErrorTextStyle()66 const TextStyle& GetErrorTextStyle() const 67 { 68 return errorTextStyle_; 69 } 70 #endif 71 72 protected: 73 CameraTheme() = default; 74 75 private: 76 Size bufferSize_; 77 78 #if defined(PREVIEW) 79 TextStyle errorTextStyle_; 80 #endif 81 }; 82 83 } // namespace OHOS::Ace 84 85 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_CAMERA_CAMERA_THEME_H 86