WebCFace 2.9.0
Web-based Communication Framework & Dashboard-like UI
Loading...
Searching...
No Matches
ViewComponent Class Reference

Viewに表示する要素です More...

#include <webcface/component_view.h>

Public Member Functions

 ViewComponent ()
 
 ViewComponent (const std::shared_ptr< message::ViewComponentData > &msg_data, const std::weak_ptr< internal::ClientData > &data_w, const SharedString &id)
 
 ViewComponent (const ViewComponent &)
 
ViewComponentoperator= (const ViewComponent &)
 
 ViewComponent (ViewComponent &&) noexcept
 
ViewComponentoperator= (ViewComponent &&) noexcept
 
 ~ViewComponent () noexcept
 
wcfViewComponent cData () const
 
wcfViewComponentW cDataW () const
 
std::string id () const
 そのview内で一意のid
 
std::wstring idW () const
 そのview内で一意のid (wstring)
 
bool operator== (const ViewComponent &other) const
 要素の比較
 
bool operator!= (const ViewComponent &other) const
 
ViewComponentType type () const
 要素の種類
 
std::string text () const
 表示する文字列を取得
 
std::wstring textW () const
 表示する文字列を取得 (wstring)
 
template<typename Func_ = Func, bool = ::webcface::traits::assertCompleteFunc < std::enable_if_t<std::is_same_v< Func_, Func >, Func_>>()>
std::optional< Func_ > onClick () const
 クリック時に実行される関数を取得
 
template<typename Func_ = Func, bool = ::webcface::traits::assertCompleteFunc < std::enable_if_t<std::is_same_v< Func_, Func >, Func_>>()>
std::optional< Func_ > onChange () const
 inputの値の変化時に実行される関数を取得
 
template<typename Variant_ = Variant, bool = ::webcface::traits::assertCompleteVariant < std::enable_if_t<std::is_same_v< Variant_, Variant >, Variant_>>()>
std::optional< Variant_ > bind () const
 inputの現在の値を取得
 
ViewColor textColor () const
 文字色を取得
 
ViewColor bgColor () const
 背景色を取得
 
std::optional< double > min () const
 最小値を取得する。
 
std::optional< double > max () const
 最大値を取得する。
 
std::optional< double > step () const
 数値の刻み幅を取得する。
 
std::vector< ValAdaptoroption () const
 引数の選択肢を取得する。
 
int width () const
 要素の幅を取得する。
 
int height () const
 要素の高さを取得する。
 
template<typename T , bool >
std::optional< T > onChange () const
 
template<typename T , bool >
std::optional< T > onClick () const
 
template<typename T , bool >
std::optional< T > bind () const
 

Detailed Description

Viewに表示する要素です

  • ver2.0〜: get専用(ViewComponent)とset用(TemporalComponent)で分けている。
  • ver2.0〜: データはshared_ptrの中に持つ。(pimpl)
    • moveが多いしメンバ変数多いので、 make_sharedのコストはあまり気にしなくてもいい?
  • 作成時
    • components::text() など →ViewComponent
    • v << move(component)
    • vb->addVC(move(component))
    • vb->add(move(component))
    • vb->components_.push_back(move(component))
    • setSend(make_shared(move(components_)))
  • 取得時
    • getRecv()
    • vector<ViewComponent> v;
    • 1要素ずつ再構築

Constructor & Destructor Documentation

◆ ViewComponent() [1/4]

ViewComponent ( )
default

msg_dataはnullptrになり、内容にアクセスしようとするとruntime_errorを投げる

◆ ViewComponent() [2/4]

ViewComponent ( const std::shared_ptr< message::ViewComponentData > &  msg_data,
const std::weak_ptr< internal::ClientData > &  data_w,
const SharedString id 
)

◆ ViewComponent() [3/4]

ViewComponent ( const ViewComponent other)

◆ ViewComponent() [4/4]

ViewComponent ( ViewComponent &&  )
defaultnoexcept

◆ ~ViewComponent()

~ViewComponent ( )
defaultnoexcept

Member Function Documentation

◆ bgColor()

ViewColor bgColor ( ) const

背景色を取得

◆ bind() [1/2]

template<typename Variant_ = Variant, bool = ::webcface::traits::assertCompleteVariant < std::enable_if_t<std::is_same_v< Variant_, Variant >, Variant_>>()>
template std::optional< Variant > bind< Variant, true > ( ) const

inputの現在の値を取得

Since
ver1.10
  • 値の変更はonChange()に新しい値を渡して呼び出す (onChange()->runAsync(value) など)
  • ver2.0〜 戻り値をText型からVariant型に変更

◆ bind() [2/2]

template<typename T , bool >
template std::optional< Variant > bind< Variant, true > ( ) const

◆ cData()

wcfViewComponent cData ( ) const

◆ cDataW()

wcfViewComponentW cDataW ( ) const

◆ height()

int height ( ) const

要素の高さを取得する。

Since
ver2.6

◆ id()

std::string id ( ) const

そのview内で一意のid

Since
ver1.10
  • 要素が増減したり順序が変わったりしなければ、 同じ要素には常に同じidが振られる。
  • (ver2.5〜) view作成側でidを指定した場合その値が返る。

◆ idW()

std::wstring idW ( ) const

そのview内で一意のid (wstring)

Since
ver2.5
  • 要素が増減したり順序が変わったりしなければ、 同じ要素には常に同じidが振られる。
  • view作成側でidを指定した場合その値が返る。

◆ max()

std::optional< double > max ( ) const

最大値を取得する。

Since
ver1.10

◆ min()

std::optional< double > min ( ) const

最小値を取得する。

Since
ver1.10

◆ onChange() [1/2]

template<typename Func_ = Func, bool = ::webcface::traits::assertCompleteFunc < std::enable_if_t<std::is_same_v< Func_, Func >, Func_>>()>
template std::optional< Func > onChange< Func, true > ( ) const

inputの値の変化時に実行される関数を取得

Since
ver1.10

onChange()に新しい値を渡して呼び出すことで値を変更させる (onChange()->runAsync(value) など)

内部データはonClickと共通

◆ onChange() [2/2]

template<typename T , bool >
template std::optional< Func > onChange< Func, true > ( ) const

◆ onClick() [1/2]

template<typename Func_ = Func, bool = ::webcface::traits::assertCompleteFunc < std::enable_if_t<std::is_same_v< Func_, Func >, Func_>>()>
template std::optional< Func > onClick< Func, true > ( ) const

クリック時に実行される関数を取得

◆ onClick() [2/2]

template<typename T , bool >
template std::optional< Func > onClick< Func, true > ( ) const

◆ operator!=()

bool operator!= ( const ViewComponent other) const
inline
Since
ver1.11

◆ operator=() [1/2]

ViewComponent & operator= ( const ViewComponent other)

◆ operator=() [2/2]

ViewComponent & operator= ( ViewComponent &&  )
defaultnoexcept

◆ operator==()

bool operator== ( const ViewComponent other) const

要素の比較

Since
ver1.11

要素のプロパティが完全一致すればtrue

例外としてbindの中身は別のTextオブジェクトで管理されるので、 ここでは比較の対象ではない

◆ option()

std::vector< ValAdaptor > option ( ) const

引数の選択肢を取得する。

Since
ver1.10

◆ step()

std::optional< double > step ( ) const

数値の刻み幅を取得する。

Since
ver1.10

◆ text()

std::string text ( ) const

表示する文字列を取得

◆ textColor()

ViewColor textColor ( ) const

文字色を取得

◆ textW()

std::wstring textW ( ) const

表示する文字列を取得 (wstring)

Since
ver2.0

◆ type()

ViewComponentType type ( ) const

要素の種類

◆ width()

int width ( ) const

要素の幅を取得する。

Since
ver2.6

The documentation for this class was generated from the following files: