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 GRAPHIC_LITE_UI_ABSTRACT_SCROLL_BAR_H 17 #define GRAPHIC_LITE_UI_ABSTRACT_SCROLL_BAR_H 18 19 #include "gfx_utils/rect.h" 20 #include "gfx_utils/style.h" 21 #include "gfx_utils/graphic_buffer.h" 22 23 namespace OHOS { 24 class UIAbstractScrollBar : public HeapBase { 25 public: 26 UIAbstractScrollBar(); 27 ~UIAbstractScrollBar()28 virtual ~UIAbstractScrollBar() {} 29 SetPosition(int16_t x,int16_t y,int16_t width,int16_t height)30 virtual void SetPosition(int16_t x, int16_t y, int16_t width, int16_t height) {} 31 OnDraw(BufferInfo & gfxDstBuffer,const Rect & invalidatedArea,uint8_t backgroundOpa)32 virtual void OnDraw(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea, uint8_t backgroundOpa) {} 33 SetScrollBarSide(uint8_t side)34 virtual void SetScrollBarSide(uint8_t side) {} 35 SetScrollProgress(float scrollProgress)36 void SetScrollProgress(float scrollProgress) 37 { 38 scrollProgress_ = scrollProgress; 39 } 40 SetForegroundProportion(float foregroundPropotion)41 void SetForegroundProportion(float foregroundPropotion) 42 { 43 if ((foregroundPropotion < 0) || (foregroundPropotion > 1.0f)) { 44 return; 45 } 46 foregroundProportion_ = foregroundPropotion; 47 } 48 SetOpacity(uint8_t opacity)49 void SetOpacity(uint8_t opacity) 50 { 51 opacity_ = opacity; 52 } 53 GetOpacity()54 uint8_t GetOpacity() 55 { 56 return opacity_; 57 } 58 59 protected: 60 uint8_t opacity_ = OPA_OPAQUE; 61 float scrollProgress_ = 0; 62 float foregroundProportion_ = 0; 63 Style* backgroundStyle_ = nullptr; 64 Style* foregroundStyle_ = nullptr; 65 }; 66 } // namespace OHOS 67 #endif // GRAPHIC_LITE_UI_ABSTRACT_SCROLL_BAR_H 68