ドキュメント
Form[IN]Component
7 min read
Form[IN]Componentはコンポーネントをフォーム形式で表示するコンポーネントです。以下のコンポーネントが標準で用意してあります。
- FormItemComponent
- FormCheckBoxComponent
- FormSliderComponent
- FormTextComponent
form_item_component.hpp
class FormItemComponent : public Component
{
public:
FormItemComponent
(
MOD mod,
unsigned int form_width,
unsigned int form_height,
unsigned char form_bg_color_R,
unsigned char form_bg_color_G,
unsigned char form_bg_color_B,
unsigned char form_bg_color_A,
spa::gui::box::POS pos,
std::string form_title,
unsigned int title_c_size,
unsigned char title_text_color_R,
unsigned char title_text_color_G,
unsigned char title_text_color_B,
unsigned int item_height,
FcComponent Component
);
~FormItemComponent() = default;
FormItemComponent(FormItemComponent const&);
FormItemComponent& operator=(FormItemComponent const&);
void configure();
private:
std::unique_ptr<BoxComponent> form;
std::unique_ptr<BoxComponent> title_box;
std::unique_ptr<BoxComponent> input_box;
std::unique_ptr<BoxTextComponent> title;
FcComponent component;
};
フォームの幅、高さ、背景色、タイトル、タイトルの文字サイズ、タイトルの色を指定します。フォームの幅、高さ-タイトル文字サイズのinput_boxにcomponentをattachします。引数として渡したcomponentは他のコンポーネントでattachしないようにしてください。
from_checkbox_component.hpp
class FormCheckboxComponent : public Component
{
private:
class CheckEvent;
public:
FormCheckboxComponent
(
MOD mod,
unsigned int form_width,
unsigned int form_height,
unsigned char form_bg_color_R,
unsigned char form_bg_color_G,
unsigned char form_bg_color_B,
unsigned char form_bg_color_A,
spa::gui::box::POS pos,
std::string form_title,
unsigned int title_c_size,
unsigned char title_text_color_R,
unsigned char title_text_color_G,
unsigned char title_text_color_B,
bool check,
unsigned int checkbox_height,
unsigned char checkbox_color_R,
unsigned char checkbox_color_G,
unsigned char checkbox_color_B,
std::function<void(bool)> form_event
);
~FormCheckboxComponent() = default;
FormCheckboxComponent(FormCheckboxComponent const&);
FormCheckboxComponent& operator=(FormCheckboxComponent const&);
bool get();
void configure();
private:
std::unique_ptr<BoxComponent> form;
std::unique_ptr<BoxComponent> title_box;
std::unique_ptr<BoxComponent> check_box;
std::unique_ptr<BoxTextComponent> title;
std::unique_ptr<ClickItemComponent> check_on;
std::unique_ptr<ClickItemComponent> check_off;
std::shared_ptr<bool> check;
};
追加でチェックボックスの色とチェックのイベント関数を指定します。
ペンディング:captureメソッド追加
form_slider_component.hpp
class FormSliderComponent : public Component
{
public:
FormSliderComponent
(
MOD mod,
unsigned int form_width,
unsigned int form_height,
unsigned char form_bg_color_R,
unsigned char form_bg_color_G,
unsigned char form_bg_color_B,
unsigned char form_bg_color_A,
spa::gui::box::POS pos,
std::string form_title,
unsigned int title_c_size,
unsigned char title_text_color_R,
unsigned char title_text_color_G,
unsigned char title_text_color_B,
unsigned int slider_min,
unsigned int slider_max,
unsigned int slider_value,
unsigned int slider_size,
unsigned char slider_color_R,
unsigned char slider_color_G,
unsigned char slider_color_B,
unsigned char slider_color_A,
std::function<void(unsigned int)> form_event
);
~FormSliderComponent() = default;
FormSliderComponent(FormSliderComponent const&);
FormSliderComponent& operator=(FormSliderComponent const&);
spa::gui::Slider<>* get();
void configure();
private:
std::unique_ptr<BoxComponent> form;
std::unique_ptr<BoxComponent> title_box;
std::unique_ptr<BoxComponent> slider_box;
std::unique_ptr<BoxTextComponent> title;
std::unique_ptr<BoxSliderComponent> slider;
std::string form_title;
};
追加でスライダー引数とスライダードラッグのイベント関数を指定します。
form_text_component.hpp
class FormTextComponent : public Component
{
public:
FormTextComponent
(
MOD mod,
unsigned int form_width,
unsigned int form_height,
unsigned char form_bg_color_R,
unsigned char form_bg_color_G,
unsigned char form_bg_color_B,
unsigned char form_bg_color_A,
spa::gui::box::POS pos,
std::string form_title,
unsigned int title_c_size,
unsigned char title_text_color_R,
unsigned char title_text_color_G,
unsigned char title_text_color_B,
unsigned char text_box_color_R,
unsigned char text_box_color_G,
unsigned char text_box_color_B,
unsigned char text_box_color_A,
unsigned int text_c_size,
unsigned char text_color_R,
unsigned char text_color_G,
unsigned char text_color_B
);
~FormTextComponent() = default;
FormTextComponent(FormTextComponent const&);
FormTextComponent& operator=(FormTextComponent const&);
spa::gui::Text<>* get();
void mask();
void configure();
private:
std::unique_ptr<BoxComponent> form;
std::unique_ptr<BoxComponent> title_box;
std::unique_ptr<BoxComponent> input_box;
std::unique_ptr<BoxTextComponent> title;
std::unique_ptr<BoxTextComponent> input;
};
追加でテキストの引数を指定します。
コメントを残す