mirror of
https://github.com/m5stack/StackChan.git
synced 2026-04-28 11:27:59 +00:00
5001b7081b
* add firmware source code
96 lines
2.4 KiB
C++
96 lines
2.4 KiB
C++
/*
|
|
* SPDX-FileCopyrightText: 2026 M5Stack Technology CO LTD
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
#pragma once
|
|
#include "../../avatar/avatar.h"
|
|
#include "../../avatar/elements/feature.h"
|
|
#include <lvgl.h>
|
|
#include <smooth_lvgl.hpp>
|
|
#include <memory>
|
|
|
|
namespace stackchan::avatar {
|
|
|
|
/**
|
|
* @brief
|
|
*
|
|
*/
|
|
class DefaultAvatar : public Avatar {
|
|
public:
|
|
lv_color_t primaryColor = lv_color_white();
|
|
lv_color_t secondaryColor = lv_color_black();
|
|
|
|
void init(lv_obj_t* parent, const lv_font_t* font = &lv_font_montserrat_16);
|
|
uitk::lvgl_cpp::Container* getPanel() const;
|
|
|
|
private:
|
|
std::unique_ptr<uitk::lvgl_cpp::Container> _pannel;
|
|
};
|
|
|
|
/**
|
|
* @brief
|
|
*
|
|
*/
|
|
class DefaultEyes : public Feature {
|
|
public:
|
|
DefaultEyes(lv_obj_t* parent, lv_color_t primaryColor, lv_color_t secondaryColor, bool isLeftEye);
|
|
~DefaultEyes();
|
|
|
|
void setPosition(const uitk::Vector2i& position) override;
|
|
void setWeight(int weight) override;
|
|
void setRotation(int rotation) override;
|
|
void setEmotion(const Emotion& emotion) override;
|
|
void setVisible(bool visible) override;
|
|
void setSize(int size) override;
|
|
|
|
private:
|
|
bool _is_left_eye = false;
|
|
int _eyelid_offset_y = 0;
|
|
|
|
std::unique_ptr<uitk::lvgl_cpp::Container> _container;
|
|
std::unique_ptr<uitk::lvgl_cpp::Container> _eye;
|
|
std::unique_ptr<uitk::lvgl_cpp::Container> _eyelid;
|
|
};
|
|
|
|
/**
|
|
* @brief
|
|
*
|
|
*/
|
|
class DefaultMouth : public Feature {
|
|
public:
|
|
DefaultMouth(lv_obj_t* parent, lv_color_t primaryColor, lv_color_t secondaryColor);
|
|
~DefaultMouth();
|
|
|
|
void setPosition(const uitk::Vector2i& position) override;
|
|
void setWeight(int weight) override;
|
|
void setRotation(int rotation) override;
|
|
void setVisible(bool visible) override;
|
|
|
|
private:
|
|
std::unique_ptr<uitk::lvgl_cpp::Container> _mouth;
|
|
};
|
|
|
|
/**
|
|
* @brief
|
|
*
|
|
*/
|
|
class DefaultSpeechBubble : public SpeechBubble {
|
|
public:
|
|
DefaultSpeechBubble(lv_obj_t* parent, lv_color_t primaryColor, lv_color_t secondaryColor, const lv_font_t* font);
|
|
~DefaultSpeechBubble();
|
|
|
|
void setSpeech(std::string_view text) override;
|
|
void clearSpeech() override;
|
|
void setVisible(bool visible) override;
|
|
void setTextFont(void* font) override;
|
|
|
|
private:
|
|
std::unique_ptr<uitk::lvgl_cpp::Container> _container;
|
|
std::unique_ptr<uitk::lvgl_cpp::Image> _arrow;
|
|
std::unique_ptr<uitk::lvgl_cpp::Container> _bubble;
|
|
std::unique_ptr<uitk::lvgl_cpp::Label> _text;
|
|
};
|
|
|
|
} // namespace stackchan::avatar
|