paceholder / nodeeditor

Qt Node Editor. Dataflow programming framework
BSD 3-Clause "New" or "Revised" License
2.92k stars 795 forks source link

Add scale up and scale down range (#3) #337

Closed zmoth closed 1 year ago

zmoth commented 1 year ago
zmoth commented 1 year ago

hi @paceholder , do you think it is necessary to design struct ScaleRange in this way?

struct ScaleRange
{
  ScaleRange(double minimum = 0, double maximum = 0);

  double minimum, maximum = 0;

  void operator=(ScaleRange const& r);

  void sort();
};

GraphicsView::ScaleRange::
ScaleRange(double minimum, double maximum)
    :minimum(minimum), maximum(maximum)
{
  sort();
}

void
GraphicsView::ScaleRange::
operator=(ScaleRange const& r)
{
  minimum = r.minimum;
  maximum = r.maximum;
  sort();
}

void
GraphicsView::ScaleRange::
sort()
{
  minimum = minimum < 0 ? 0 : minimum;
  maximum = maximum < 0 ? 0 : maximum;
  if (minimum > maximum)
  {
    double tmp = minimum;
    minimum = maximum;
    maximum = tmp;
  }
}
paceholder commented 1 year ago

I manually merged your code with small fixes:

Thanks for the contribution

zmoth commented 1 year ago

I manually merged your code with small fixes:

  • code styling
  • removed multiple merge commits
  • made a single squashed commit, rebased it onto the lates master

Thanks for the contribution

Thank you for your help. I will learn from your code and improve myself.

I hope to have .clang-format as soon as possible