21 bool changed =
m_total != total;
30 float newpos = position /
m_total;
32 if (newpos < 0.0F || newpos > 1.0F)
44 if (
m_total >= end && end >= start && start >= 0.0)
71 QRect keeparea = QRect();
72 QRect cutarea = QRect();
108 if (position && keeparea.isValid())
110 int offset = position->
GetArea().width() / 2;
112 int newy = position->
GetArea().top();
129 auto *leftshape =
dynamic_cast<MythUIShape *
>(cuttoleft);
130 auto *leftimage =
dynamic_cast<MythUIImage *
>(cuttoleft);
131 auto *rightshape =
dynamic_cast<MythUIShape *
>(cuttoright);
132 auto *rightimage =
dynamic_cast<MythUIImage *
>(cuttoright);
134 if (cutarea.isValid())
136 for (
const auto& region : std::as_const(
m_regions))
138 int left = lroundf(region.first * cutarea.width());
139 int right = lroundf(region.second * cutarea.width());
146 AddBar(barshape, barimage, QRect(left, cutarea.top(), right - left,
150 if (cuttoleft && (region.second < 1.0F))
151 AddMark(leftshape, leftimage, right,
true);
153 if (cuttoright && (region.first > 0.0F))
154 AddMark(rightshape, rightimage, left,
false);
162 leftshape =
dynamic_cast<MythUIShape *
>(keeptoleft);
163 leftimage =
dynamic_cast<MythUIImage *
>(keeptoleft);
164 rightshape =
dynamic_cast<MythUIShape *
>(keeptoright);
165 rightimage =
dynamic_cast<MythUIImage *
>(keeptoright);
167 if (keeparea.isValid())
171 int left = lroundf(region.first * keeparea.width());
172 int right = lroundf(region.second * keeparea.width());
179 AddBar(barshape, barimage, QRect(left, keeparea.top(), right - left,
183 if (keeptoleft && (region.second < 1.0F))
184 AddMark(leftshape, leftimage, right,
true);
186 if (keeptoright && (region.first > 0.0F))
187 AddMark(rightshape, rightimage, left,
false);
206 shape->
SetCropRect(area.left(), area.top(), area.width(), area.height());
209 image->SetCropRect(area.left(), area.top(), area.width(), area.height());
216 int start,
bool left)
223 start -= add->
GetArea().width();
231 QString name = QString(
"editbarimage_%1").arg(
m_images.size());
239 newshape->CopyFrom(shape);
240 newshape->SetVisible(
true);
251 newimage->CopyFrom(image);
252 newimage->SetVisible(
true);
267 for (
const auto& region : std::as_const(
m_regions))
271 if (region.first > 0.0F)
274 start = region.second;
280 start = region.second;
307 for (
const auto& region : std::as_const(
m_regions))
308 editbar->m_regions.append(region);
319 editbar->CopyFrom(
this);
A narrow purpose widget used to represent cut positions and regions when editing a video.
void CreateCopy(MythUIType *parent) override
Copy the state of this widget to the one given, it must be of the same type.
void AddBar(MythUIShape *shape, MythUIImage *image, QRect area)
QList< QPair< float, float > > m_invregions
void CopyFrom(MythUIType *base) override
Copy this widgets state from another.
void SetEditPosition(double position)
MythUIType * GetNew(MythUIShape *shape, MythUIImage *image)
void AddRegion(double start, double end)
MythUIEditBar(MythUIType *parent, const QString &name)
void CalcInverseRegions(void)
void AddMark(MythUIShape *shape, MythUIImage *image, int start, bool left)
void Finalize(void) override
Perform any post-xml parsing initialisation tasks.
void SetTotal(double total)
QList< MythUIType * > m_images
QList< QPair< float, float > > m_regions
Image widget, displays a single image or multiple images in sequence.
void SetCropRect(int x, int y, int width, int height)
Crop the image using the given rectangle, useful for removing unsightly edges from imported images or...
A widget for rendering primitive shapes and lines.
The base class on which all widgets and screens are based.
virtual void SetVisible(bool visible)
virtual void CopyFrom(MythUIType *base)
Copy this widgets state from another.
virtual MythRect GetArea(void) const
If the object has a minimum area defined, return it, other wise return the default area.
void SetPosition(int x, int y)
Convenience method, calls SetPosition(const MythPoint&) Override that instead to change functionality...
MythUIType * GetChild(const QString &name) const
Get a named child of this UIType.
void DeleteChild(const QString &name)
Delete a named child of this UIType.