mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added HorizontalContainer for buttons to PhotoEditorControls.
This commit is contained in:
parent
f7fa36ca1d
commit
d8921c7cf5
2 changed files with 49 additions and 3 deletions
|
@ -7,11 +7,51 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "editor/photo_editor_controls.h"
|
#include "editor/photo_editor_controls.h"
|
||||||
|
|
||||||
|
#include "ui/cached_round_corners.h"
|
||||||
namespace Editor {
|
namespace Editor {
|
||||||
|
|
||||||
PhotoEditorControls::PhotoEditorControls(
|
class HorizontalContainer final : public Ui::RpWidget {
|
||||||
not_null<Ui::RpWidget*> parent)
|
public:
|
||||||
|
HorizontalContainer(not_null<Ui::RpWidget*> parent);
|
||||||
|
|
||||||
|
void updateChildrenPosition();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
HorizontalContainer::HorizontalContainer(not_null<Ui::RpWidget*> parent)
|
||||||
: RpWidget(parent) {
|
: RpWidget(parent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HorizontalContainer::updateChildrenPosition() {
|
||||||
|
auto left = 0;
|
||||||
|
auto height = 0;
|
||||||
|
for (auto child : RpWidget::children()) {
|
||||||
|
if (child->isWidgetType()) {
|
||||||
|
const auto widget = static_cast<QWidget*>(child);
|
||||||
|
widget->move(left, 0);
|
||||||
|
left += widget->width();
|
||||||
|
height = std::max(height, widget->height());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resize(left, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
PhotoEditorControls::PhotoEditorControls(
|
||||||
|
not_null<Ui::RpWidget*> parent,
|
||||||
|
bool doneControls)
|
||||||
|
: RpWidget(parent)
|
||||||
|
, _buttonsContainer(base::make_unique_q<HorizontalContainer>(this)) {
|
||||||
|
|
||||||
|
_buttonsContainer->updateChildrenPosition();
|
||||||
|
|
||||||
|
sizeValue(
|
||||||
|
) | rpl::start_with_next([=](const QSize &size) {
|
||||||
|
|
||||||
|
_buttonsContainer->moveToLeft(
|
||||||
|
(size.width() - _buttonsContainer->width()) / 2,
|
||||||
|
0);
|
||||||
|
|
||||||
|
}, lifetime());
|
||||||
|
|
||||||
|
}
|
||||||
} // namespace Editor
|
} // namespace Editor
|
||||||
|
|
|
@ -11,12 +11,18 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
namespace Editor {
|
namespace Editor {
|
||||||
|
|
||||||
|
class HorizontalContainer;
|
||||||
|
|
||||||
class PhotoEditorControls final : public Ui::RpWidget {
|
class PhotoEditorControls final : public Ui::RpWidget {
|
||||||
public:
|
public:
|
||||||
PhotoEditorControls(not_null<Ui::RpWidget*> parent);
|
PhotoEditorControls(
|
||||||
|
not_null<Ui::RpWidget*> parent,
|
||||||
|
bool doneControls = true);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
const base::unique_qptr<HorizontalContainer> _buttonsContainer;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Editor
|
} // namespace Editor
|
||||||
|
|
Loading…
Add table
Reference in a new issue