ドキュメント
Check[IN]Component
2 min read
Check[IN]Componentはbool変数を制御するコンポーネントです。以下のコンポーネントが標準で用意してあります。
- CheckBoxComponent
check_box_component.hpp
class CheckBoxComponent : public Component
{
private:
class CheckEvent;
public:
CheckBoxComponent
(
MOD mod,
unsigned int width,
unsigned int height,
unsigned char box_bg_color_R,
unsigned char box_bg_color_G,
unsigned char box_bg_color_B,
unsigned char box_bg_color_A,
spa::gui::box::POS pos,
unsigned char check_box_bg_color_R,
unsigned char check_box_bg_color_G,
unsigned char check_box_bg_color_B,
bool check,
std::function<void(bool)> check_event
);
~CheckBoxComponent() = default;
CheckBoxComponent(CheckBoxComponent const&);
CheckBoxComponent& operator=(CheckBoxComponent const&);
bool get();
void configure();
void capture();
private:
std::unique_ptr<BoxComponent> box;
std::unique_ptr<ClickItemComponent> click;
std::unique_ptr<BoxImageComponent> mark;
std::shared_ptr<bool> check;
bool captured_check;
};
box、markの引数とチェック時の関数を指定します。captured_checkはcheckが変更した場合に、recaptureを実行してキャプチャー画像を上書きしています。
check_box_component.cpp
void CheckBoxComponent::configure()
{
attach(box.get());
box->attach(click.get());
if (*check)
box->attach(mark.get());
capture();
}
void CheckBoxComponent::capture()
{
if (captured_check != *check)
{
box->recapture();
captured_check = *check;
}
}
captureメソッドを定義して最適化に必要なメソッドを切り出しています。
コメントを残す