ドキュメント
BreadcrumbComponent
2 min read
BreadcrumbComponentはパンくずリストの要素を定義したコンポーネントです。BreadcrumbsListComponentで使用されています。
breadcrumb_component.hpp
#pragma once
#include <gui/components/atoms/rect/rect_component.hpp>
#include <gui/components/atoms/box/box_component.hpp>
#include <gui/components/atoms/text/text_component.hpp>
#include <gui/components/atoms/click/click_component.hpp>
#include <gui/components/atoms/hover/hover_component.hpp>
class BreadCrumbComponent : public Component
{
public:
BreadCrumbComponent(
MOD mod,
unsigned int rect_margin_x,
unsigned int rect_margin_y,
unsigned char rect_bg_color_R,
unsigned char rect_bg_color_G,
unsigned char rect_bg_color_B,
unsigned char rect_bg_color_A,
unsigned int text_c_size,
unsigned char text_color_R,
unsigned char text_color_G,
unsigned char text_color_B,
std::string text,
std::string hover_text,
std::function<void(std::string)> breadcrumb_click
);
~BreadCrumbComponent() = default;
BreadCrumbComponent(BreadCrumbComponent const&);
BreadCrumbComponent& operator=(BreadCrumbComponent const&);
unsigned int get_text_width();
void configure();
private:
std::unique_ptr<RectComponent> rect;
std::unique_ptr<BoxComponent> box;
std::unique_ptr<TextComponent> text;
std::unique_ptr<ClickComponent> click;
std::unique_ptr<HoverComponent> hover;
};
指定した位置にテキストを表示します。引数で受け取ったクリックイベントを処理します。ホバー時のテキストを表示します。
get_text_widthメソッドでBreadcrumbComponentの幅を取得します。このメソッドで取得した幅を次のBreadcrumComponentのmargin_xに指定することで横並びにパンくずリストを並べることができます。
コメントを残す