Skip to content

Commit

Permalink
[avnd] Fix enums in custom layouts, fix image format for painted text…
Browse files Browse the repository at this point in the history
…ures
  • Loading branch information
jcelerier committed Aug 14, 2024
1 parent 75b7ea8 commit ba1c996
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
2 changes: 1 addition & 1 deletion 3rdparty/avendish
25 changes: 20 additions & 5 deletions src/plugins/score-plugin-avnd/Crousti/Layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@
namespace oscr
{

template <typename T>
struct pmf_member_type;
template <typename T, typename V>
struct pmf_member_type<V T::*>
{
using type = V;
};

template <typename T>
using pmf_member_type_t = typename pmf_member_type<T>::type;

template <typename Info>
struct LayoutBuilder final : Process::LayoutBuilderBase
{
Expand All @@ -38,26 +49,30 @@ struct LayoutBuilder final : Process::LayoutBuilderBase
{
if constexpr(requires { sizeof(Item::value); })
{
oscr::from_ossia_value(inl->value(), item.value);
using avnd_port_type = pmf_member_type_t<decltype(item.model)>;
avnd_port_type p;
oscr::from_ossia_value(p, inl->value(), item.value);
if constexpr(requires { rootUi->on_control_update(); })
{
QObject::connect(
inl, &Process::ControlInlet::valueChanged, &context,
[rui = rootUi, layout = this->layout, &item](const ossia::value& v) {
oscr::from_ossia_value(v, item.value);
avnd_port_type p;
oscr::from_ossia_value(p, v, item.value);

rui->on_control_update();
layout->update();
});
});
}
else
{
QObject::connect(
inl, &Process::ControlInlet::valueChanged, &context,
[layout = this->layout, &item](const ossia::value& v) {
oscr::from_ossia_value(v, item.value);
avnd_port_type p;
oscr::from_ossia_value(p, v, item.value);
layout->update();
});
});
}
}
}
Expand Down
9 changes: 7 additions & 2 deletions src/plugins/score-plugin-avnd/Crousti/Painter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,13 @@ struct QPainterAdapter
void draw_bytes(
int x, int y, int w, int h, const unsigned char* image, int img_w, int img_h)
{
auto img = QImage(image, img_w, img_h, QImage::Format_RGB32);
painter.drawImage(QRect(x, y, w, h), img, QRect(0, 0, img_w, img_h));
auto img = QImage(image, img_w, img_h, QImage::Format_RGBA8888);
auto prev = painter.renderHints() & QPainter::SmoothPixmapTransform;
painter.setRenderHint(QPainter::SmoothPixmapTransform, false);
painter.drawImage(
QRect(x, y, w, h), img, QRect(0, 0, img_w, img_h), Qt::ImageConversionFlags{});

painter.setRenderHint(QPainter::SmoothPixmapTransform, prev);
}
};
static_assert(avnd::painter<QPainterAdapter>);
Expand Down

0 comments on commit ba1c996

Please sign in to comment.