19 QIcon* VuoInputEditorAnchor::renderIconWithLineSegments(
const float* points,
const unsigned int length)
30 for(
int i = 0; i < length; i += 4)
32 path.moveTo(points[i+0], points[i+1]);
33 path.lineTo(points[i+2], points[i+3]);
36 p.strokePath(path, QPen(Qt::black, 1));
40 QIcon* VuoInputEditorAnchor::iconForAnchorIndex(
const int anchor)
42 const float left_top[8] = { 1.f, 1.f, 1.f, 15.f, 1.f, 1.f, 15.f, 1.f };
43 const float center_top[4] = { 1.f, 1.f, 15.f, 1.f };
44 const float right_top[8] = { 1.f, 1.f, 15.f, 1.f, 15.f, 1.f, 15.f, 15.f};
46 const float left_center[4] = { 1.f, 1.f, 1.f, 15.f };
47 const float center_center[8] = { 8.f, 1.f, 8.f, 15.f, 1.f, 8.f, 15.f, 8.f };
48 const float right_center[4] = { 15.f, 1.f, 15.f, 15.f };
50 const float left_bottom[8] = { 1.f, 15.f, 1.f, 1.f, 1.f, 15.f, 15.f, 15.f };
51 const float center_bottom[4] = { 1.f, 15.f, 15.f, 15.f };
52 const float right_bottom[8] = { 1.f, 15.f, 15.f, 15.f, 15.f, 15.f, 15.f, 1.f };
58 return renderIconWithLineSegments( left_top, 8 );
62 return renderIconWithLineSegments( center_top, 4 );
66 return renderIconWithLineSegments( right_top, 8 );
70 return renderIconWithLineSegments( left_center, 4 );
74 return renderIconWithLineSegments( center_center, 8 );
78 return renderIconWithLineSegments( right_center, 4 );
82 return renderIconWithLineSegments( left_bottom, 8 );
85 return renderIconWithLineSegments( center_bottom, 8 );
89 return renderIconWithLineSegments( right_bottom, 8 );
92 return renderIconWithLineSegments( left_top, 8 );
104 int VuoInputEditorAnchor::VuoAnchorToIndex(
const VuoAnchor anchor)
118 int curIndex = VuoAnchorToIndex(curAnchor);
121 QGridLayout* layout =
new QGridLayout;
122 layout->setContentsMargins(4, 4, 12, 4);
123 layout->setSpacing(0);
125 QSettings* settings =
new QSettings();
126 bool isDark = settings->value(
"darkInterface").toBool();
132 signalMapper =
new QSignalMapper(
this);
134 for(
int r = 0; r < 3; r++)
136 for(
int c = 0; c < 3; c++)
138 int index = r * 3 + c;
140 QIcon* icon = iconForAnchorIndex(index);
141 matrix[index] =
new QPushButton(*icon,
"");
143 matrix[index]->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
144 matrix[index]->setCheckable(
true);
145 matrix[index]->setChecked(
false);
146 matrix[index]->setAutoExclusive(
true);
147 matrix[index]->setFocusPolicy(Qt::NoFocus);
148 matrix[index]->setDown(
false);
149 matrix[index]->setFlat(
true);
150 matrix[index]->setContentsMargins(0,0,0,0);
151 matrix[index]->setMaximumWidth(24);
152 matrix[index]->setMaximumHeight(24);
153 matrix[index]->setMinimumWidth(24);
154 matrix[index]->setMinimumHeight(24);
156 matrix[index]->setStyleSheet(
"QPushButton:checked { background:#8B8C8C; border:none; outline:none; }" );
158 matrix[index]->setStyleSheet(
"QPushButton:checked { background:#909090; border:none; outline:none; }" );
159 connect(matrix[index], &QPushButton::released, signalMapper,
static_cast<void (QSignalMapper::*)()
>(&QSignalMapper::map));
160 signalMapper->setMapping(matrix[index], index) ;
161 layout->addWidget(matrix[index], r, c);
165 matrix[curIndex]->setChecked(
true);
167 connect(signalMapper,
static_cast<void (QSignalMapper::*)(
int)
>(&QSignalMapper::mapped),
this, &VuoInputEditorAnchor::onSetAnchor);
169 dialog.setFocusPolicy(Qt::NoFocus);
170 dialog.setLayout(layout);
173 void VuoInputEditorAnchor::onSetAnchor(
int anchor)
175 matrix[anchor]->setChecked(
true);