#pragma once #include "Book.hpp" #include #include #include #include #include #include /** * @brief Compact widget that renders a single Book cover and title. * * BookTile is used by @ref BookShelf's GridView factory; it presents the * cover art (texture if already loaded, otherwise lazy load from disk) and * a caption, and forwards click gestures via @ref signalActivated(). */ class BookTile : public Gtk::Box { public: BookTile(const Book& book, int coverSize = 128); void setBook(const Book& book); // for updates const Book& getBook() const noexcept { return m_book; } void setSelected(bool selected); /// Emitted when the tile is clicked (single click). sigc::signal& signalActivated() { return m_signalActivated; } private: void rebuild(); void onActivated(); Book m_book; int m_coverSize = 128; Gtk::Overlay m_overlay; Gtk::Picture m_cover; Gtk::Label m_title; Glib::RefPtr m_click; Glib::RefPtr m_hover; bool m_selected = false; sigc::signal m_signalActivated; };