Adds InputWindowElement.

This commit is contained in:
2021-08-26 14:51:50 +09:00
parent 11279acb02
commit a07c61675e
19 changed files with 385 additions and 9 deletions

View File

@@ -0,0 +1,45 @@
#pragma once
#include "common.h"
#include "HiraganaMatcher.h"
#include "iAllocator.h"
#include "iClock.h"
#include "iElementFactory.h"
#include "InputWindowElement.h"
namespace gj {
class InputWindowElementFactory : public iElementFactory {
public:
InputWindowElementFactory(InputWindowElementFactory&&) = delete;
InputWindowElementFactory(const InputWindowElementFactory&) = delete;
InputWindowElementFactory& operator=(InputWindowElementFactory&&) = delete;
InputWindowElementFactory& operator=(const InputWindowElementFactory&) = delete;
InputWindowElementFactory(iAllocator* alloc) : alloc_(alloc) {
}
UniqPtr<iElement> Create(Param&& param) override {
if (param.custom.size() != 2) return nullptr;
const std::string text = std::get<std::string>(param.custom[0]);
const std::string kana = std::get<std::string>(param.custom[1]);
InputWindowElement::Param p;
p.period = param.period;
p.driver = std::move(param.driver);
p.matcher = alloc_->MakeUniq<iInputMatcher, HiraganaMatcher>(ConvertStrToWstr(kana));
p.text = ConvertStrToWstr(text);
return alloc_->MakeUniq<iElement, InputWindowElement>(std::move(p));
}
private:
iAllocator* alloc_;
};
}