Jamba C++ API  4.3.0
ParamImageView.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 pongasoft
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations under
14  * the License.
15  *
16  * @author Yan Pujante
17  */
18 #pragma once
19 
20 #include "CustomControlView.h"
21 
23 
44 {
45 public:
46  explicit ParamImageView(const CRect &iSize) : CustomDiscreteControlView(iSize) { CView::setMouseEnabled(false); }
47 
48  // draw => does the actual drawing job
49  void draw(CDrawContext *iContext) override;
50 
65  BitmapPtr getImage() const { return fImage; }
66 
68  void setImage(BitmapPtr iImage) { fImage = iImage; }
69 
71  bool getInverse() const { return fInverse; }
72 
74  void setInverse(bool iInverse) { fInverse = iInverse; }
75 
80  int32 getFrames() const;
81 
82  // registerParameters
83  void registerParameters() override;
84 
86  bool sizeToFit() override;
87 
88 protected:
89  BitmapSPtr fImage{nullptr};
90  bool fInverse{false};
91 
92 public:
93  class Creator : public CustomViewCreator<ParamImageView, CustomDiscreteControlView>
94  {
95  public:
96  explicit Creator(char const *iViewName = nullptr, char const *iDisplayName = nullptr) :
97  CustomViewCreator(iViewName, iDisplayName)
98  {
101  }
102  };
103 };
104 
105 }
void setImage(BitmapPtr iImage)
attribute image
Definition: ParamImageView.h:68
Inherit from this class to provide the factory for a custom view.
Definition: CustomViewCreator.h:1312
bool fInverse
Definition: ParamImageView.h:90
BitmapPtr getImage() const
The image to use.
Definition: ParamImageView.h:65
bool getInverse() const
Inverses the frames (last frame is first frame, etc...)
Definition: ParamImageView.h:71
BitmapSPtr fImage
Definition: ParamImageView.h:89
SharedPointer< CBitmap > BitmapSPtr
Definition: Types.h:50
void draw(CDrawContext *iContext) override
Definition: ParamImageView.cpp:26
void setInverse(bool iInverse)
Attribute inverse
Definition: ParamImageView.h:74
ParamImageView(const CRect &iSize)
Definition: ParamImageView.h:46
This view renders a param value as an image (the ParamDisplayView view renders a param value as a str...
Definition: ParamImageView.h:43
void registerBooleanAttribute(std::string const &iName, typename BooleanAttribute::Getter iGetter, typename BooleanAttribute::Setter iSetter)
Registers a boolean attribute with the given name and getter/setter.
Definition: CustomViewCreator.h:1099
Definition: CustomController.h:24
bool sizeToFit() override
Use the image and number of frames to size the view appropriately.
Definition: ParamImageView.cpp:70
void registerParameters() override
Registers the optional parameter using getControlTag() as its id.
Definition: ParamImageView.cpp:45
Specialization of TCustomControlView for discrete values.
Definition: CustomControlView.h:152
int32 getFrames() const
Returns the number of frames the image has (which is defined by the [number of steps + 1] the underly...
Definition: ParamImageView.cpp:57
Creator(char const *iViewName=nullptr, char const *iDisplayName=nullptr)
Definition: ParamImageView.h:96
CBitmap * BitmapPtr
Definition: Types.h:49
void registerBitmapAttribute(std::string const &iName, typename BitmapAttribute::Getter iGetter, typename BitmapAttribute::Setter iSetter)
Registers a bitmap attribute with the given name and getter/setter.
Definition: CustomViewCreator.h:971