Shinya Kitaoka 810553
#pragma once
Shinya Kitaoka 810553
Toshihiro Shimizu 890ddd
#ifndef PLUGIN_UI_PAGE_INTERFACE
Toshihiro Shimizu 890ddd
#define PLUGIN_UI_PAGE_INTERFACE
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "toonz_hostif.h"
Toshihiro Shimizu 890ddd
#include "tfx.h"
Toshihiro Shimizu 890ddd
#include "plugin_param_interface.h"
Toshihiro Shimizu 890ddd
#include "plugin_param_view_interface.h"
Toshihiro Shimizu 890ddd
#include "pluginhost.h"
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
/* 公開ヘッダからは引っ込められた都合上ここで宣言(内部ではまだ使っているので) */
Toshihiro Shimizu 890ddd
typedef void *toonz_ui_page_handle_t;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/* あるエフェクトのパラメータ画面 */
Shinya Kitaoka 120a6e
class UIPage {
Shinya Kitaoka 120a6e
  class Group {
Shinya Kitaoka 120a6e
    std::string name_;
Shinya Kitaoka 120a6e
    std::vector<std::pair<std::string, *="" paramview="">> params_;</std::pair<std::string,>
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  public:
Shinya Kitaoka 120a6e
    Group(const std::string &name) : name_(name) {}
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    Group(const Group &group) : name_(group.name_), params_(group.params_) {}
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    inline const std::string &name() const { return name_; }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    inline void add_param(const std::string ¶m, ParamView *components) {
Shinya Kitaoka 120a6e
      params_.push_back(std::make_pair(param, components));
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    inline ParamsPage *build(RasterFxPluginHost *fx, ParamsPage *page) {
Shinya Kitaoka 120a6e
      page->beginGroup(name_.c_str());
Shinya Kitaoka 120a6e
      for (std::size_t i = 0, size = params_.size(); i < size; i++) {
Shinya Kitaoka 120a6e
        params_[i].second->build(fx, page, params_[i].first.c_str());
Shinya Kitaoka 120a6e
      }
Shinya Kitaoka 120a6e
      page->endGroup();
Shinya Kitaoka 120a6e
      return page;
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
  };
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  std::string name_;
Shinya Kitaoka 120a6e
  std::vector<group *=""> groups_;</group>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  inline UIPage(const char *name) : name_(name) {}
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  inline ~UIPage() {
Shinya Kitaoka 120a6e
    for (std::size_t i = 0, size = groups_.size(); i < size; ++i) {
Shinya Kitaoka 120a6e
      delete groups_[i];
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    groups_.clear();
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  inline int begin_group(const char *name) {
Shinya Kitaoka 120a6e
    groups_.push_back(NULL);
Shinya Kitaoka 120a6e
    groups_.back() = new Group(name);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    return TOONZ_OK;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  inline int end_group(const char *name) {
Shinya Kitaoka 120a6e
    if (groups_.back()->name() != name) {
Shinya Kitaoka 120a6e
      return TOONZ_ERROR_NOT_FOUND;
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    return TOONZ_OK;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  int bind_param(Param *param, ParamView *pt) {
Shinya Kitaoka 120a6e
    if (groups_.empty()) {
Shinya Kitaoka 120a6e
      return TOONZ_ERROR_PREREQUISITE;
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    groups_.back()->add_param(param->name(), pt);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    return TOONZ_OK;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void build(RasterFxPluginHost *fx, ParamsPageSet *pages) const {
Shinya Kitaoka 120a6e
    ParamsPage *page = pages->createParamsPage();
Shinya Kitaoka 120a6e
    for (std::size_t i = 0, size = groups_.size(); i < size; ++i) {
Shinya Kitaoka 120a6e
      groups_[i]->build(fx, page);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    pages->addParamsPage(page, name_.c_str());
Shinya Kitaoka 120a6e
    page->setPageSpace();
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  UIPage *clone(TFx *fx) const {
Shinya Kitaoka 120a6e
    UIPage *page = new UIPage(name_.c_str());
Shinya Kitaoka 120a6e
    for (std::size_t i = 0, size = groups_.size(); i < size; ++i) {
Shinya Kitaoka 120a6e
      page->groups_.push_back(new Group(*groups_[i]));
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    return page;
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
int begin_group(toonz_ui_page_handle_t page, const char *name);
Toshihiro Shimizu 890ddd
int end_group(toonz_ui_page_handle_t page, const char *name);
Shinya Kitaoka 120a6e
int bind_param(toonz_ui_page_handle_t page, toonz_param_handle_t param,
Shinya Kitaoka 120a6e
               toonz_param_view_handle_t traits);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif