Files
MARTe_IO_Components/Client/NativeUI-Qt/src/layout_picker.h
T
2026-05-27 15:46:50 +02:00

36 lines
870 B
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#pragma once
#include <QToolButton>
#include <functional>
/**
* A toolbar button that opens a small popup grid of layout preview buttons.
* Each cell draws a schematic of the grid it represents.
*
* The user clicks a cell → the popup closes → callback fires with the layout index.
*/
class LayoutPicker : public QToolButton {
Q_OBJECT
public:
explicit LayoutPicker(QWidget* parent = nullptr);
/** 0-based index matching the Layout enum order:
* 0=1×1 1=1×2 2=1×3 3=1×4 4=2×1 5=2×2 6=3×1 7=4×1 */
void setCurrentLayout(int idx);
int currentLayout() const { return current_; }
signals:
void layoutSelected(int idx);
private:
void openPopup();
int current_ = 0;
struct LayoutDef {
const char* label; // e.g. "1×2"
int rows, cols;
};
static const LayoutDef kLayouts[8];
};