mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +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 "ui/cached_round_corners.h"
|
||||
namespace Editor {
|
||||
|
||||
PhotoEditorControls::PhotoEditorControls(
|
||||
not_null<Ui::RpWidget*> parent)
|
||||
class HorizontalContainer final : public Ui::RpWidget {
|
||||
public:
|
||||
HorizontalContainer(not_null<Ui::RpWidget*> parent);
|
||||
|
||||
void updateChildrenPosition();
|
||||
|
||||
};
|
||||
|
||||
HorizontalContainer::HorizontalContainer(not_null<Ui::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
|
||||
|
|
|
@ -11,12 +11,18 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
namespace Editor {
|
||||
|
||||
class HorizontalContainer;
|
||||
|
||||
class PhotoEditorControls final : public Ui::RpWidget {
|
||||
public:
|
||||
PhotoEditorControls(not_null<Ui::RpWidget*> parent);
|
||||
PhotoEditorControls(
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
bool doneControls = true);
|
||||
|
||||
private:
|
||||
|
||||
const base::unique_qptr<HorizontalContainer> _buttonsContainer;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Editor
|
||||
|
|
Loading…
Add table
Reference in a new issue