ValueDisplay.hpp
1 #pragma once
2 #include <Process/Process.hpp>
3 
4 #include <Effect/EffectLayer.hpp>
5 #include <Effect/EffectLayout.hpp>
6 
7 #include <score/model/Skin.hpp>
8 
9 #include <ossia/network/value/format_value.hpp>
10 
11 #include <QPainter>
12 
13 #include <halp/controls.hpp>
14 #include <halp/meta.hpp>
15 namespace Ui::ValueDisplay
16 {
17 struct Node
18 {
19  halp_meta(name, "Value display")
20  halp_meta(c_name, "Display")
21  halp_meta(category, "Monitoring")
22  halp_meta(author, "ossia score")
23  halp_meta(manual_url, "")
24  halp_meta(description, "Visualize an input value")
25  halp_meta(uuid, "3f4a41f2-fa39-420f-ab0f-0af6b8409edb")
26  halp_flag(fully_custom_item);
27  struct
28  {
29  struct : halp::val_port<"in", ossia::value>
30  {
31  enum widget
32  {
33  control
34  };
35  } port;
36  } inputs;
37 
39  {
40  public:
41  ossia::value m_value;
42 
43  Layer(
44  const Process::ProcessModel& process, const Process::Context& doc,
45  QGraphicsItem* parent)
46  : Process::EffectLayerView{parent}
47  {
48  setAcceptedMouseButtons({});
49 
50  const Process::PortFactoryList& portFactory
52 
53  auto inl = static_cast<Process::ControlInlet*>(process.inlets().front());
54 
55  auto fact = portFactory.get(inl->concreteKey());
56  auto port = fact->makePortItem(*inl, doc, this, this);
57  port->setPos(0, 5);
58 
59  connect(
60  inl, &Process::ControlInlet::executionValueChanged, this,
61  [this](const ossia::value& v) {
62  m_value = v;
63  update();
64  });
65  }
66 
67  void reset()
68  {
69  m_value = ossia::value{};
70  update();
71  }
72 
73  void paint_impl(QPainter* p) const override
74  {
75  if(!m_value.valid())
76  return;
77 
78  p->setRenderHint(QPainter::Antialiasing, true);
79  p->setPen(score::Skin::instance().Light.main.pen1_solid_flat_miter);
80 
81  p->drawText(boundingRect(), QString::fromStdString(fmt::format("{}", m_value)));
82 
83  p->setRenderHint(QPainter::Antialiasing, false);
84  }
85  };
86 };
87 }
Definition: Port.hpp:203
Definition: EffectLayer.hpp:16
Definition: PortFactory.hpp:74
The Process class.
Definition: score-lib-process/Process/Process.hpp:61
Definition: ProcessContext.hpp:12
Definition: ValueDisplay.hpp:39
Definition: ValueDisplay.hpp:18
const T & interfaces() const
Access to a specific interface list.
Definition: ApplicationContext.hpp:67