Jamba  3.0.2
CustomViewCreator.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 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 <vstgui4/vstgui/uidescription/iviewcreator.h>
21 #include <vstgui4/vstgui/uidescription/uiviewcreator.h>
22 #include <vstgui4/vstgui/uidescription/uiviewfactory.h>
23 #include <vstgui4/vstgui/uidescription/uiattributes.h>
24 #include <vstgui4/vstgui/uidescription/detail/uiviewcreatorattributes.h>
25 #include <vstgui4/vstgui/lib/crect.h>
26 #include <vstgui4/vstgui/lib/ccolor.h>
27 #include <vstgui4/vstgui/lib/cbitmap.h>
28 #include <map>
29 #include <memory>
30 #include <pongasoft/logging/logging.h>
34 
35 namespace pongasoft {
36 namespace VST {
37 namespace GUI {
38 namespace Views {
39 
40 using namespace VSTGUI;
41 
46 {
47 public:
48  // Constructor
49  explicit ViewAttribute(std::string iName) :
50  fName(std::move(iName))
51  {}
52 
56  virtual IViewCreator::AttrType getType() = 0;
57 
62  std::string getName() const
63  {
64  return fName;
65  }
66 
73  virtual bool apply(CView *iView, const UIAttributes &iAttributes, const IUIDescription *iDescription) = 0;
74 
81  virtual bool getAttributeValue(CView *iView, const IUIDescription *iDescription, std::string &oStringValue) const = 0;
82 
83 private:
84  std::string fName;
85 };
86 
91 template<typename TView>
92 inline TView *createCustomView(CRect const &iSize) { return new TView(iSize); }
93 
120 template<typename TView>
121 class TCustomViewCreator : public ViewCreatorAdapter
122 {
123 private:
129  template<typename T, typename TGetter, typename TSetter>
130  class TAttribute : public ViewAttribute
131  {
132  public:
133  using Getter = TGetter;
134  using Setter = TSetter;
135 
136  // Constructor
137  TAttribute(std::string const &iName, Getter iGetter, Setter iSetter) :
138  ViewAttribute(iName), fGetter{iGetter}, fSetter{iSetter} { }
139 
140  // getType
141  IViewCreator::AttrType getType() override
142  {
143  return IViewCreator::kUnknownType;
144  }
145 
150  virtual bool fromString(IUIDescription const *iDescription, std::string const &iAttributeValue, T &oValue) const
151  {
152  return false;
153  }
154 
159  virtual bool toString(IUIDescription const *iDescription, T const &iValue, std::string &oStringValue) const
160  {
161  return false;
162  }
163 
164  // apply => set a color to the view
165  bool apply(CView *iView, const UIAttributes &iAttributes, const IUIDescription *iDescription) override
166  {
167  auto *tv = dynamic_cast<TView *>(iView);
168  if(tv != nullptr)
169  {
170  auto attributeValue = iAttributes.getAttributeValue(getName());
171  if(attributeValue)
172  {
173  T value;
174  if(fromString(iDescription, *attributeValue, value))
175  {
176  (tv->*fSetter)(value);
177  return true;
178  }
179  }
180  }
181  return false;
182  }
183 
184  // getAttributeValue => get a color from the view
185  bool getAttributeValue(CView *iView, const IUIDescription *iDescription, std::string &oStringValue) const override
186  {
187  auto *tv = dynamic_cast<TView *>(iView);
188  if(tv != nullptr)
189  {
190  auto value = (tv->*fGetter)();
191  return toString(iDescription, value, oStringValue);
192  }
193  return false;
194  }
195 
196  private:
199  };
200 
204  template<typename T>
205  using ByValAttribute = TAttribute<T, T (TView::*)() const, void (TView::*)(T)>;
206 
210  template<typename T>
211  using ByRefAttribute = TAttribute<T, T const &(TView::*)() const, void (TView::*)(T const &)>;
212 
217  class TagAttribute : public ByValAttribute<int32_t>
218  {
219  public:
220  TagAttribute(std::string const &iName,
221  typename ByValAttribute<int32_t>::Getter iGetter,
222  typename ByValAttribute<int32_t>::Setter iSetter) :
223  ByValAttribute<int32_t>(iName, iGetter, iSetter) {}
224 
225  // getType
226  IViewCreator::AttrType getType() override
227  {
228  return IViewCreator::kTagType;
229  }
230 
231  // fromString
232  bool fromString(IUIDescription const *iDescription, std::string const &iAttributeValue, int32_t &oValue) const override
233  {
234  if(iAttributeValue.length() != 0)
235  {
236  auto tag = iDescription->getTagForName(iAttributeValue.c_str());
237  if(tag == -1)
238  {
239  char *endPtr = nullptr;
240  tag = (int32_t) strtol(iAttributeValue.c_str(), &endPtr, 10);
241  if(endPtr == iAttributeValue.c_str())
242  {
243  return false;
244  }
245  }
246  oValue = tag;
247  return true;
248  }
249  return false;
250  }
251 
252  // toString
253  bool toString(IUIDescription const *iDescription, const int32_t &iValue, std::string &oStringValue) const override
254  {
255  if(iValue != -1)
256  {
257  UTF8StringPtr controlTag = iDescription->lookupControlTagName(iValue);
258  if(controlTag)
259  {
260  oStringValue = controlTag;
261  return true;
262  }
263  }
264 
265  return false;
266  }
267  };
268 
273  template<typename TInt>
274  class IntegerAttribute : public ByValAttribute<TInt>
275  {
276  public:
279 
280  // Constructor
281  IntegerAttribute(std::string const &iName, Getter iGetter, Setter iSetter) :
282  ByValAttribute<TInt>(iName, iGetter, iSetter) {}
283 
284  // getType
285  IViewCreator::AttrType getType() override
286  {
287  return IViewCreator::kIntegerType;
288  }
289 
290  // fromString
291  bool fromString(IUIDescription const *iDescription, std::string const &iAttributeValue, TInt &oValue) const override
292  {
293  char *endPtr = nullptr;
294  auto value = static_cast<TInt>(strtol(iAttributeValue.c_str(), &endPtr, 10));
295  if(endPtr == iAttributeValue.c_str())
296  {
297  DLOG_F(WARNING, "could not convert <%s> to an integer", iAttributeValue.c_str());
298  return false;
299  }
300  oValue = value;
301  return true;
302  }
303 
304  // toString
305  bool toString(IUIDescription const *iDescription, const TInt &iValue, std::string &oStringValue) const override
306  {
307  std::stringstream str;
308  str << iValue;
309  oStringValue = str.str();
310  return true;
311  }
312  };
313 
318  template<typename TFloat>
319  class FloatAttribute : public ByValAttribute<TFloat>
320  {
321  public:
324 
325  // Constructor
326  FloatAttribute(std::string const &iName, Getter iGetter, Setter iSetter) :
327  ByValAttribute<TFloat>(iName, iGetter, iSetter) {}
328 
329  // getType
330  IViewCreator::AttrType getType() override
331  {
332  return IViewCreator::kFloatType;
333  }
334 
335  // fromString
336  bool fromString(IUIDescription const *iDescription, std::string const &iAttributeValue, TFloat &oValue) const override
337  {
338  TFloat value;
339  if(Utils::stringToFloat<TFloat>(iAttributeValue, value))
340  {
341  oValue = value;
342  return true;
343  }
344  DLOG_F(WARNING, "could not convert <%s> to a float", iAttributeValue.c_str());
345  return false;
346  }
347 
348  // toString
349  bool toString(IUIDescription const *iDescription, const TFloat &iValue, std::string &oStringValue) const override
350  {
351  std::stringstream str;
352  str << iValue;
353  oStringValue = str.str();
354  return true;
355  }
356  };
357 
362  class ColorAttribute : public ByRefAttribute<CColor>
363  {
364  public:
365 
366  // Constructor
367  ColorAttribute(std::string const &iName,
368  typename ByRefAttribute<CColor>::Getter iGetter,
369  typename ByRefAttribute<CColor>::Setter iSetter) :
370  ByRefAttribute<CColor>(iName, iGetter, iSetter) {}
371 
372  // getType
373  IViewCreator::AttrType getType() override
374  {
375  return IViewCreator::kColorType;
376  }
377 
378  // fromString
379  bool fromString(IUIDescription const *iDescription, std::string const &iAttributeValue, CColor &oValue) const override
380  {
381  CColor color;
382  if(UIViewCreator::stringToColor(&iAttributeValue, color, iDescription))
383  {
384  oValue = color;
385  return true;
386  }
387  return false;
388  }
389 
390  // toString
391  bool toString(IUIDescription const *iDescription, const CColor &iValue, std::string &oStringValue) const override
392  {
393  return UIViewCreator::colorToString(iValue, oStringValue, iDescription);
394  }
395  };
396 
401  class GradientAttribute : public ByValAttribute<GradientPtr>
402  {
403  public:
404 
405  // Constructor
406  GradientAttribute(std::string const &iName,
407  typename ByValAttribute<GradientPtr>::Getter iGetter,
408  typename ByValAttribute<GradientPtr>::Setter iSetter) :
409  ByValAttribute<GradientPtr>(iName, iGetter, iSetter) {}
410 
411  // getType
412  IViewCreator::AttrType getType() override
413  {
414  return IViewCreator::kGradientType;
415  }
416 
417  // fromString
418  bool fromString(IUIDescription const *iDescription, std::string const &iAttributeValue, GradientPtr &oValue) const override
419  {
420  auto gradient = iDescription->getGradient(iAttributeValue.c_str());
421  if(gradient)
422  {
423  oValue = gradient;
424  return true;
425  }
426  return false;
427  }
428 
429  // toString
430  bool toString(IUIDescription const *iDescription, GradientPtr const &iValue, std::string &oStringValue) const override
431  {
432  if(iValue)
433  {
434  auto name = iDescription->lookupGradientName(iValue);
435  if(name)
436  {
437  oStringValue = name;
438  return true;
439  }
440 
441  }
442  return false;
443  }
444  };
445 
450  class BooleanAttribute : public ByValAttribute<bool>
451  {
452  public:
453  // Constructor
454  BooleanAttribute(std::string const &iName,
455  typename ByValAttribute<bool>::Getter iGetter,
456  typename ByValAttribute<bool>::Setter iSetter) :
457  ByValAttribute<bool>(iName, iGetter, iSetter) {}
458 
459  // getType
460  IViewCreator::AttrType getType() override
461  {
462  return IViewCreator::kBooleanType;
463  }
464 
465  // fromString
466  bool fromString(IUIDescription const *iDescription, std::string const &iAttributeValue, bool &oValue) const override
467  {
468  if(iAttributeValue == "true")
469  {
470  oValue = true;
471  return true;
472  }
473 
474  if(iAttributeValue == "false")
475  {
476  oValue = false;
477  return true;
478  }
479 
480  return false;
481  }
482 
483  // toString
484  bool toString(IUIDescription const *iDescription, const bool &iValue, std::string &oStringValue) const override
485  {
486  oStringValue = iValue ? "true" : "false";
487  return true;
488  }
489  };
490 
495  class BitmapAttribute : public ByValAttribute<BitmapPtr>
496  {
497  public:
498  // Constructor
499  BitmapAttribute(std::string const &iName,
500  typename ByValAttribute<BitmapPtr>::Getter iGetter,
501  typename ByValAttribute<BitmapPtr>::Setter iSetter) :
502  ByValAttribute<BitmapPtr>(iName, iGetter, iSetter) {}
503 
504  // getType
505  IViewCreator::AttrType getType() override
506  {
507  return IViewCreator::kBitmapType;
508  }
509 
510  // fromString
511  bool fromString(IUIDescription const *iDescription, std::string const &iAttributeValue, BitmapPtr &oValue) const override
512  {
513  BitmapPtr bitmap;
514  if(UIViewCreator::stringToBitmap(&iAttributeValue, bitmap, iDescription))
515  {
516  oValue = bitmap;
517  return true;
518  }
519  return false;
520  }
521 
522  // toString
523  bool toString(IUIDescription const *iDescription, BitmapPtr const &iValue, std::string &oStringValue) const override
524  {
525  if(iValue)
526  return UIViewCreator::bitmapToString(iValue, oStringValue, iDescription);
527  else
528  return false;
529  }
530  };
531 
536  class FontAttribute : public ByValAttribute<FontPtr>
537  {
538  public:
539  // Constructor
540  FontAttribute(std::string const &iName,
541  typename ByValAttribute<FontPtr>::Getter iGetter,
542  typename ByValAttribute<FontPtr>::Setter iSetter) :
543  ByValAttribute<FontPtr>(iName, iGetter, iSetter) {}
544 
545  // getType
546  IViewCreator::AttrType getType() override
547  {
548  return IViewCreator::kFontType;
549  }
550 
551  // fromString
552  bool fromString(IUIDescription const *iDescription, std::string const &iAttributeValue, FontPtr &oValue) const override
553  {
554  auto font = iDescription->getFont(iAttributeValue.c_str());
555  if(font)
556  {
557  oValue = font;
558  return true;
559  }
560  return false;
561  }
562 
563  // toString
564  bool toString(IUIDescription const *iDescription, FontPtr const &iValue, std::string &oStringValue) const override
565  {
566  if(iValue)
567  {
568  auto fontName = iDescription->lookupFontName(iValue);
569  if(fontName)
570  {
571  oStringValue = fontName;
572  return true;
573  }
574  }
575  return false;
576  }
577  };
578 
583  class MarginAttribute : public ByRefAttribute<Margin>
584  {
585  public:
586  MarginAttribute(std::string const &iName,
587  typename ByRefAttribute<Margin>::Getter iGetter,
588  typename ByRefAttribute<Margin>::Setter iSetter) :
589  ByRefAttribute<Margin>(iName, iGetter, iSetter) {}
590 
591  // fromString
592  bool fromString(IUIDescription const *iDescription, std::string const &iAttributeValue, Margin &oValue) const override
593  {
594  auto parts = Utils::splitFloats<CCoord>(iAttributeValue, ',');
595 
596  if(parts.empty())
597  return false;
598 
599  // look for nan in the array
600  if(std::find_if(parts.cbegin(), parts.cend(), [] (auto f) {return std::isnan(f);}) != parts.cend())
601  return false;
602 
603  if(parts.size() == 1)
604  {
605  oValue = Margin{parts[0]};
606  }
607  else
608  {
609  if(parts.size() < 4)
610  return false;
611 
612  oValue = Margin{parts[0], parts[1], parts[2], parts[3]};
613  }
614 
615  return true;
616  }
617 
618  // toString
619  bool toString(IUIDescription const *iDescription, const Margin &iValue, std::string &oStringValue) const override
620  {
621  std::stringstream str;
622  if(iValue.fTop == iValue.fRight && iValue.fTop == iValue.fBottom && iValue.fTop == iValue.fLeft)
623  str << iValue.fTop;
624  else
625  {
626  str << iValue.fTop;
627  str << ",";
628  str << iValue.fRight;
629  str << ",";
630  str << iValue.fBottom;
631  str << ",";
632  str << iValue.fLeft;
633  }
634  oStringValue = str.str();
635  return true;
636  }
637  };
638 
643  class RangeAttribute : public ByRefAttribute<Range>
644  {
645  public:
646  RangeAttribute(std::string const &iName,
647  typename ByRefAttribute<Range>::Getter iGetter,
648  typename ByRefAttribute<Range>::Setter iSetter) :
649  ByRefAttribute<Range>(iName, iGetter, iSetter) {}
650 
651  // fromString
652  bool fromString(IUIDescription const *iDescription, std::string const &iAttributeValue, Range &oValue) const override
653  {
654  auto parts = Utils::splitFloats<CCoord>(iAttributeValue, ',');
655 
656  if(parts.empty())
657  return false;
658 
659  // look for nan in the array
660  if(std::find_if(parts.cbegin(), parts.cend(), [] (auto f) {return std::isnan(f);}) != parts.cend())
661  return false;
662 
663  if(parts.size() == 1)
664  oValue = Range{parts[0]};
665  else
666  oValue = Range{parts[0], parts[1]};
667 
668  return true;
669  }
670 
671  // toString
672  bool toString(IUIDescription const *iDescription, const Range &iValue, std::string &oStringValue) const override
673  {
674  std::stringstream str;
675  if(iValue.fFrom == iValue.fTo)
676  str << iValue.fFrom;
677  else
678  {
679  str << iValue.fFrom;
680  str << ",";
681  str << iValue.fTo;
682  }
683  oStringValue = str.str();
684  return true;
685  }
686  };
687 
688 public:
689  // Constructor
690  explicit TCustomViewCreator(char const *iViewName = nullptr,
691  char const *iDisplayName = nullptr,
692  char const *iBaseViewName = VSTGUI::UIViewCreator::kCView) :
693  fViewName{iViewName},
694  fDisplayName{iDisplayName},
695  fBaseViewName{iBaseViewName},
696  fAttributes{}
697  {
698  // this allows for inheritance!
699  if(iViewName != nullptr && iDisplayName != nullptr)
700  VSTGUI::UIViewFactory::registerViewCreator(*this);
701  }
702 
703  // Destructor
705  {
706  // we simply clear the map since it holds shared pointers which will be discarded when they are no longer
707  // held by another object
708  fAttributes.clear();
709  }
710 
711  // getViewName
712  IdStringPtr getViewName() const override
713  {
714  return fViewName;
715  }
716 
717  // getDisplayName
718  UTF8StringPtr getDisplayName() const override
719  {
720  return fDisplayName;
721  }
722 
723  // getBaseViewName
724  IdStringPtr getBaseViewName() const override
725  {
726  return fBaseViewName;
727  }
728 
732  template<typename XView>
734  {
735  for(auto attribute : iOther.fAttributes)
736  {
737  registerAttribute(attribute.second);
738  }
739 
740  if(std::string(fBaseViewName) == std::string(VSTGUI::UIViewCreator::kCView))
741  fBaseViewName = iOther.fBaseViewName;
742  }
743 
747  void registerColorAttribute(std::string const &iName,
748  typename ColorAttribute::Getter iGetter,
749  typename ColorAttribute::Setter iSetter)
750  {
751  registerAttribute<ColorAttribute>(iName, iGetter, iSetter);
752  }
753 
757  void registerGradientAttribute(std::string const &iName,
758  typename GradientAttribute::Getter iGetter,
759  typename GradientAttribute::Setter iSetter)
760  {
761  registerAttribute<GradientAttribute>(iName, iGetter, iSetter);
762  }
763 
767  void registerBitmapAttribute(std::string const &iName,
768  typename BitmapAttribute::Getter iGetter,
769  typename BitmapAttribute::Setter iSetter)
770  {
771  registerAttribute<BitmapAttribute>(iName, iGetter, iSetter);
772  }
773 
777  void registerFontAttribute(std::string const &iName,
778  typename FontAttribute::Getter iGetter,
779  typename FontAttribute::Setter iSetter)
780  {
781  registerAttribute<FontAttribute>(iName, iGetter, iSetter);
782  }
783 
787  void registerMarginAttribute(std::string const &iName,
788  typename MarginAttribute::Getter iGetter,
789  typename MarginAttribute::Setter iSetter)
790  {
791  registerAttribute<MarginAttribute>(iName, iGetter, iSetter);
792  }
793 
797  void registerRangeAttribute(std::string const &iName,
798  typename RangeAttribute::Getter iGetter,
799  typename RangeAttribute::Setter iSetter)
800  {
801  registerAttribute<RangeAttribute>(iName, iGetter, iSetter);
802  }
803 
807  void registerTagAttribute(std::string const &iName,
808  typename TagAttribute::Getter iGetter,
809  typename TagAttribute::Setter iSetter)
810  {
811  registerAttribute<TagAttribute>(iName, iGetter, iSetter);
812  }
813 
817  template<typename TInt>
818  void registerIntegerAttribute(std::string const &iName,
819  typename IntegerAttribute<TInt>::Getter iGetter,
820  typename IntegerAttribute<TInt>::Setter iSetter)
821  {
822  registerAttribute<IntegerAttribute<TInt>>(iName, iGetter, iSetter);
823  }
824 
828  void registerIntAttribute(std::string const &iName,
829  typename IntegerAttribute<int32_t>::Getter iGetter,
830  typename IntegerAttribute<int32_t>::Setter iSetter)
831  {
832  registerIntegerAttribute<int32_t>(iName, iGetter, iSetter);
833  }
834 
838  void registerFloatAttribute(std::string const &iName,
839  typename FloatAttribute<float>::Getter iGetter,
840  typename FloatAttribute<float>::Setter iSetter)
841  {
842  registerAttribute<FloatAttribute<float>>(iName, iGetter, iSetter);
843  }
844 
848  void registerDoubleAttribute(std::string const &iName,
849  typename FloatAttribute<double>::Getter iGetter,
850  typename FloatAttribute<double>::Setter iSetter)
851  {
852  registerAttribute<FloatAttribute<double>>(iName, iGetter, iSetter);
853  }
854 
858  void registerBooleanAttribute(std::string const &iName,
859  typename BooleanAttribute::Getter iGetter,
860  typename BooleanAttribute::Setter iSetter)
861  {
862  registerAttribute<BooleanAttribute>(iName, iGetter, iSetter);
863  }
864 
868  CView *create(const UIAttributes &attributes, const IUIDescription *description) const override
869  {
870 #ifdef JAMBA_DEBUG_LOGGING
871  DLOG_F(INFO, "CustomViewCreator<%s>::create()", getViewName());
872 #endif
873 
874  return createCustomView<TView>(CRect(0, 0, 0, 0));
875  }
876 
881  bool apply(CView *view, const UIAttributes &attributes, const IUIDescription *description) const override
882  {
883  auto *tv = dynamic_cast<TView *>(view);
884 
885  if(tv == nullptr)
886  return false;
887 
888  for(auto attribute : fAttributes)
889  {
890  attribute.second->apply(tv, attributes, description);
891  }
892 
893  return true;
894  }
895 
896  // getAttributeNames
897  bool getAttributeNames(std::list<std::string> &attributeNames) const override
898  {
899  for(auto attribute : fAttributes)
900  {
901  attributeNames.emplace_back(attribute.first);
902  }
903  return true;
904  }
905 
906  // getAttributeType
907  AttrType getAttributeType(const std::string &attributeName) const override
908  {
909  auto iter = fAttributes.find(attributeName);
910  if(iter != fAttributes.cend())
911  {
912  return iter->second->getType();
913  }
914  return kUnknownType;
915  }
916 
920  bool getAttributeValue(CView *iView,
921  const std::string &iAttributeName,
922  std::string &oStringValue,
923  const IUIDescription *iDescription) const override
924  {
925  auto *cdv = dynamic_cast<TView *>(iView);
926 
927  if(cdv == nullptr)
928  return false;
929 
930  auto iter = fAttributes.find(iAttributeName);
931  if(iter != fAttributes.cend())
932  {
933  return iter->second->getAttributeValue(cdv, iDescription, oStringValue);
934  }
935 
936  return false;
937  }
938 
939 private:
940 
941  // somehow this is required...
942  template<typename XView>
943  friend class TCustomViewCreator;
944 
948  void registerAttribute(std::shared_ptr<ViewAttribute> iAttribute)
949  {
950  // making sure there are no duplicates (cannot use loguru here!)
951  assert(fAttributes.find(iAttribute->getName()) == fAttributes.cend());
952  fAttributes[iAttribute->getName()] = iAttribute;
953  }
954 
958  template<typename TViewAttribute>
959  void registerAttribute(std::string const &iName,
960  typename TViewAttribute::Getter iGetter,
961  typename TViewAttribute::Setter iSetter)
962  {
963  std::shared_ptr<ViewAttribute> cva;
964  cva.reset(new TViewAttribute(iName, iGetter, iSetter));
965  registerAttribute(cva);
966  }
967 
968 
969  char const *fViewName;
970  char const *fDisplayName;
971  char const *fBaseViewName;
972 
973  // use a map of shared pointers so that they can easily be copied (see registerAttributes)
974  std::map<std::string, std::shared_ptr<ViewAttribute>> fAttributes;
975 };
976 
980 template<typename TView, typename TBaseView>
982 {
983 public:
984  explicit CustomViewCreator(char const *iViewName = nullptr,
985  char const *iDisplayName = nullptr,
986  char const *iBaseViewName = VSTGUI::UIViewCreator::kCView) :
987  TCustomViewCreator<TView>(iViewName, iDisplayName, iBaseViewName)
988  {
989  TCustomViewCreator<TView>::registerAttributes(typename TBaseView::Creator());
990  }
991 };
992 
993 }
994 }
995 }
996 }
TSetter Setter
Definition: CustomViewCreator.h:134
void registerAttribute(std::string const &iName, typename TViewAttribute::Getter iGetter, typename TViewAttribute::Setter iSetter)
Definition: CustomViewCreator.h:959
Definition: CustomViewCreator.h:981
void registerFloatAttribute(std::string const &iName, typename FloatAttribute< float >::Getter iGetter, typename FloatAttribute< float >::Setter iSetter)
Definition: CustomViewCreator.h:838
T fTo
Definition: Lerp.h:312
bool toString(IUIDescription const *iDescription, const CColor &iValue, std::string &oStringValue) const override
Definition: CustomViewCreator.h:391
IntegerAttribute(std::string const &iName, Getter iGetter, Setter iSetter)
Definition: CustomViewCreator.h:281
virtual bool fromString(IUIDescription const *iDescription, std::string const &iAttributeValue, T &oValue) const
Definition: CustomViewCreator.h:150
IdStringPtr getBaseViewName() const override
Definition: CustomViewCreator.h:724
bool fromString(IUIDescription const *iDescription, std::string const &iAttributeValue, GradientPtr &oValue) const override
Definition: CustomViewCreator.h:418
void registerIntegerAttribute(std::string const &iName, typename IntegerAttribute< TInt >::Getter iGetter, typename IntegerAttribute< TInt >::Setter iSetter)
Definition: CustomViewCreator.h:818
bool apply(CView *view, const UIAttributes &attributes, const IUIDescription *description) const override
Definition: CustomViewCreator.h:881
void registerTagAttribute(std::string const &iName, typename TagAttribute::Getter iGetter, typename TagAttribute::Setter iSetter)
Definition: CustomViewCreator.h:807
void registerBooleanAttribute(std::string const &iName, typename BooleanAttribute::Getter iGetter, typename BooleanAttribute::Setter iSetter)
Definition: CustomViewCreator.h:858
Definition: Clock.h:22
bool getAttributeNames(std::list< std::string > &attributeNames) const override
Definition: CustomViewCreator.h:897
IViewCreator::AttrType getType() override
Definition: CustomViewCreator.h:330
CBitmap * BitmapPtr
Definition: Types.h:35
IViewCreator::AttrType getType() override
Definition: CustomViewCreator.h:285
bool toString(IUIDescription const *iDescription, const Range &iValue, std::string &oStringValue) const override
Definition: CustomViewCreator.h:672
bool getAttributeValue(CView *iView, const IUIDescription *iDescription, std::string &oStringValue) const override
Definition: CustomViewCreator.h:185
void registerBitmapAttribute(std::string const &iName, typename BitmapAttribute::Getter iGetter, typename BitmapAttribute::Setter iSetter)
Definition: CustomViewCreator.h:767
bool fromString(IUIDescription const *iDescription, std::string const &iAttributeValue, Range &oValue) const override
Definition: CustomViewCreator.h:652
void registerGradientAttribute(std::string const &iName, typename GradientAttribute::Getter iGetter, typename GradientAttribute::Setter iSetter)
Definition: CustomViewCreator.h:757
CustomViewCreator(char const *iViewName=nullptr, char const *iDisplayName=nullptr, char const *iBaseViewName=VSTGUI::UIViewCreator::kCView)
Definition: CustomViewCreator.h:984
bool toString(IUIDescription const *iDescription, const int32_t &iValue, std::string &oStringValue) const override
Definition: CustomViewCreator.h:253
bool toString(IUIDescription const *iDescription, const bool &iValue, std::string &oStringValue) const override
Definition: CustomViewCreator.h:484
bool fromString(IUIDescription const *iDescription, std::string const &iAttributeValue, CColor &oValue) const override
Definition: CustomViewCreator.h:379
ViewAttribute(std::string iName)
Definition: CustomViewCreator.h:49
bool toString(IUIDescription const *iDescription, const TInt &iValue, std::string &oStringValue) const override
Definition: CustomViewCreator.h:305
bool fromString(IUIDescription const *iDescription, std::string const &iAttributeValue, FontPtr &oValue) const override
Definition: CustomViewCreator.h:552
IViewCreator::AttrType getType() override
Definition: CustomViewCreator.h:373
FloatAttribute(std::string const &iName, Getter iGetter, Setter iSetter)
Definition: CustomViewCreator.h:326
TView * createCustomView(CRect const &iSize)
Definition: CustomViewCreator.h:92
TAttribute< T, T const &(CustomView ::*)() const, void(CustomView ::*)(T const &)> ByRefAttribute
Definition: CustomViewCreator.h:211
bool fromString(IUIDescription const *iDescription, std::string const &iAttributeValue, int32_t &oValue) const override
Definition: CustomViewCreator.h:232
virtual bool toString(IUIDescription const *iDescription, T const &iValue, std::string &oStringValue) const
Definition: CustomViewCreator.h:159
CView * create(const UIAttributes &attributes, const IUIDescription *description) const override
Definition: CustomViewCreator.h:868
MarginAttribute(std::string const &iName, typename ByRefAttribute< Margin >::Getter iGetter, typename ByRefAttribute< Margin >::Setter iSetter)
Definition: CustomViewCreator.h:586
TCustomViewCreator(char const *iViewName=nullptr, char const *iDisplayName=nullptr, char const *iBaseViewName=VSTGUI::UIViewCreator::kCView)
Definition: CustomViewCreator.h:690
std::string getName() const
Definition: CustomViewCreator.h:62
IViewCreator::AttrType getType() override
Definition: CustomViewCreator.h:546
char const * fBaseViewName
Definition: CustomViewCreator.h:971
void registerAttribute(std::shared_ptr< ViewAttribute > iAttribute)
Definition: CustomViewCreator.h:948
bool toString(IUIDescription const *iDescription, const Margin &iValue, std::string &oStringValue) const override
Definition: CustomViewCreator.h:619
IdStringPtr getViewName() const override
Definition: CustomViewCreator.h:712
Definition: LookAndFeel.h:32
GradientAttribute(std::string const &iName, typename ByValAttribute< GradientPtr >::Getter iGetter, typename ByValAttribute< GradientPtr >::Setter iSetter)
Definition: CustomViewCreator.h:406
TAttribute< T, T(CustomView ::*)() const, void(CustomView ::*)(T)> ByValAttribute
Definition: CustomViewCreator.h:205
std::string fName
Definition: CustomViewCreator.h:84
bool fromString(IUIDescription const *iDescription, std::string const &iAttributeValue, TFloat &oValue) const override
Definition: CustomViewCreator.h:336
char const * fDisplayName
Definition: CustomViewCreator.h:970
CCoord fLeft
Definition: LookAndFeel.h:61
void registerRangeAttribute(std::string const &iName, typename RangeAttribute::Getter iGetter, typename RangeAttribute::Setter iSetter)
Definition: CustomViewCreator.h:797
ColorAttribute(std::string const &iName, typename ByRefAttribute< CColor >::Getter iGetter, typename ByRefAttribute< CColor >::Setter iSetter)
Definition: CustomViewCreator.h:367
void registerFontAttribute(std::string const &iName, typename FontAttribute::Getter iGetter, typename FontAttribute::Setter iSetter)
Definition: CustomViewCreator.h:777
IViewCreator::AttrType getType() override
Definition: CustomViewCreator.h:141
bool fromString(IUIDescription const *iDescription, std::string const &iAttributeValue, BitmapPtr &oValue) const override
Definition: CustomViewCreator.h:511
bool toString(IUIDescription const *iDescription, const TFloat &iValue, std::string &oStringValue) const override
Definition: CustomViewCreator.h:349
IViewCreator::AttrType getType() override
Definition: CustomViewCreator.h:226
bool toString(IUIDescription const *iDescription, GradientPtr const &iValue, std::string &oStringValue) const override
Definition: CustomViewCreator.h:430
BitmapAttribute(std::string const &iName, typename ByValAttribute< BitmapPtr >::Getter iGetter, typename ByValAttribute< BitmapPtr >::Setter iSetter)
Definition: CustomViewCreator.h:499
void registerMarginAttribute(std::string const &iName, typename MarginAttribute::Getter iGetter, typename MarginAttribute::Setter iSetter)
Definition: CustomViewCreator.h:787
bool fromString(IUIDescription const *iDescription, std::string const &iAttributeValue, TInt &oValue) const override
Definition: CustomViewCreator.h:291
bool fromString(IUIDescription const *iDescription, std::string const &iAttributeValue, Margin &oValue) const override
Definition: CustomViewCreator.h:592
std::map< std::string, std::shared_ptr< ViewAttribute > > fAttributes
Definition: CustomViewCreator.h:974
bool getAttributeValue(CView *iView, const std::string &iAttributeName, std::string &oStringValue, const IUIDescription *iDescription) const override
Definition: CustomViewCreator.h:920
IViewCreator::AttrType getType() override
Definition: CustomViewCreator.h:460
FontAttribute(std::string const &iName, typename ByValAttribute< FontPtr >::Getter iGetter, typename ByValAttribute< FontPtr >::Setter iSetter)
Definition: CustomViewCreator.h:540
T fFrom
Definition: Lerp.h:311
bool fromString(IUIDescription const *iDescription, std::string const &iAttributeValue, bool &oValue) const override
Definition: CustomViewCreator.h:466
void registerIntAttribute(std::string const &iName, typename IntegerAttribute< int32_t >::Getter iGetter, typename IntegerAttribute< int32_t >::Setter iSetter)
Definition: CustomViewCreator.h:828
RangeAttribute(std::string const &iName, typename ByRefAttribute< Range >::Getter iGetter, typename ByRefAttribute< Range >::Setter iSetter)
Definition: CustomViewCreator.h:646
bool apply(CView *iView, const UIAttributes &iAttributes, const IUIDescription *iDescription) override
Definition: CustomViewCreator.h:165
void registerAttributes(TCustomViewCreator< XView > const &iOther)
Definition: CustomViewCreator.h:733
TAttribute(std::string const &iName, Getter iGetter, Setter iSetter)
Definition: CustomViewCreator.h:137
BooleanAttribute(std::string const &iName, typename ByValAttribute< bool >::Getter iGetter, typename ByValAttribute< bool >::Setter iSetter)
Definition: CustomViewCreator.h:454
CCoord fTop
Definition: LookAndFeel.h:58
IViewCreator::AttrType getType() override
Definition: CustomViewCreator.h:412
UTF8StringPtr getDisplayName() const override
Definition: CustomViewCreator.h:718
char const * fViewName
Definition: CustomViewCreator.h:969
IViewCreator::AttrType getType() override
Definition: CustomViewCreator.h:505
~TCustomViewCreator() override
Definition: CustomViewCreator.h:704
bool toString(IUIDescription const *iDescription, BitmapPtr const &iValue, std::string &oStringValue) const override
Definition: CustomViewCreator.h:523
CCoord fRight
Definition: LookAndFeel.h:59
Definition: CustomViewCreator.h:121
void registerColorAttribute(std::string const &iName, typename ColorAttribute::Getter iGetter, typename ColorAttribute::Setter iSetter)
Definition: CustomViewCreator.h:747
void registerDoubleAttribute(std::string const &iName, typename FloatAttribute< double >::Getter iGetter, typename FloatAttribute< double >::Setter iSetter)
Definition: CustomViewCreator.h:848
AttrType getAttributeType(const std::string &attributeName) const override
Definition: CustomViewCreator.h:907
TGetter Getter
Definition: CustomViewCreator.h:133
bool toString(IUIDescription const *iDescription, FontPtr const &iValue, std::string &oStringValue) const override
Definition: CustomViewCreator.h:564
CFontDesc * FontPtr
Definition: Types.h:39
Getter fGetter
Definition: CustomViewCreator.h:197
Definition: CustomViewCreator.h:45
CCoord fBottom
Definition: LookAndFeel.h:60
Setter fSetter
Definition: CustomViewCreator.h:198
TagAttribute(std::string const &iName, typename ByValAttribute< int32_t >::Getter iGetter, typename ByValAttribute< int32_t >::Setter iSetter)
Definition: CustomViewCreator.h:220
CGradient * GradientPtr
Definition: Types.h:43