ドキュメント

View Categories

ScrollBoxComponent

2 min read

ScrollBoxComponentはBoxComponent内にScrollComponentを配置します。

CaptureComponentをMODE::OFFで追加しています。

ScrollComponentを使用する場合に使用する頻度が多いパターンを構成しました。

ScrollComponent以下に外部から構成できるようにattachをprotectedに変更し、attach_innerを追加しました。

ScrollBoxComponent.hpp

class ScrollBoxComponent : public Component
{
public:
  ScrollBoxComponent
  (
    MOD mod,
    unsigned int box_width,
    unsigned int box_height,
    spa::gui::box::POS pos,
    unsigned int scroll_width,
    unsigned int scroll_height,
    bool scrollable_x,
    bool scrollable_y,
    unsigned int scroll_amount,
    int scroll_min_x,
    int scroll_max_x,
    int scroll_min_y,
    int scroll_max_y,
    unsigned char scroll_bg_layer_bg_color_R,
    unsigned char scroll_bg_layer_bg_color_G,
    unsigned char scroll_bg_layer_bg_color_B,
    unsigned char scroll_bg_layer_bg_color_A );

  ~ScrollBoxComponent() = default;

  ScrollBoxComponent(ScrollBoxComponent const& other);
  ScrollBoxComponent& operator=(ScrollBoxComponent const& other);

  void attach_inner(ComponentPlugin* component)
  {
    scroll->attach((*component)());
  }

  void attach_inner(DOM* dom)
  {
    scroll->attach(dom);
  }

  void configure();

protected:
  // 通常のattachは使用不可
  using Component::attach;

private:
  std::unique_ptr<CaptureComponent> capture;
  std::unique_ptr<BoxComponent> box;
  std::unique_ptr<ScrollBgLayerComponent> scroll_bg_layer;
  std::unique_ptr<ScrollComponent> scroll;
};

次のように構成することで新しいキャプチャをScrollComponentでスクロールできます。

void configure()
{
  scrollbox->attach_inner(capture.get());
  capture->attach(...);
}


コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です