Added ability to set vertical origin to Ui::PopupMenu.
This commit is contained in:
parent
d98c3d539b
commit
bf65a06735
2 changed files with 21 additions and 6 deletions
|
|
@ -601,6 +601,10 @@ void PopupMenu::setForcedOrigin(PanelAnimation::Origin origin) {
|
|||
_forcedOrigin = origin;
|
||||
}
|
||||
|
||||
void PopupMenu::setForcedVerticalOrigin(VerticalOrigin origin) {
|
||||
_forcedVerticalOrigin = origin;
|
||||
}
|
||||
|
||||
void PopupMenu::showAnimated(PanelAnimation::Origin origin) {
|
||||
setOrigin(origin);
|
||||
showStarted();
|
||||
|
|
@ -760,15 +764,19 @@ void PopupMenu::showMenu(const QPoint &p, PopupMenu *parent, TriggeredSource sou
|
|||
const auto forceLeft = _forcedOrigin
|
||||
&& (*_forcedOrigin == Origin::TopLeft
|
||||
|| *_forcedOrigin == Origin::BottomLeft);
|
||||
const auto forceTop = _forcedOrigin
|
||||
&& (*_forcedOrigin == Origin::TopLeft
|
||||
|| *_forcedOrigin == Origin::TopRight);
|
||||
const auto forceTop = (_forcedVerticalOrigin
|
||||
&& (*_forcedVerticalOrigin == VerticalOrigin::Top))
|
||||
|| (_forcedOrigin
|
||||
&& (*_forcedOrigin == Origin::TopLeft
|
||||
|| *_forcedOrigin == Origin::TopRight));
|
||||
const auto forceRight = _forcedOrigin
|
||||
&& (*_forcedOrigin == Origin::TopRight
|
||||
|| *_forcedOrigin == Origin::BottomRight);
|
||||
const auto forceBottom = _forcedOrigin
|
||||
&& (*_forcedOrigin == Origin::BottomLeft
|
||||
|| *_forcedOrigin == Origin::BottomRight);
|
||||
const auto forceBottom = (_forcedVerticalOrigin
|
||||
&& (*_forcedVerticalOrigin == VerticalOrigin::Bottom))
|
||||
|| (_forcedOrigin
|
||||
&& (*_forcedOrigin == Origin::BottomLeft
|
||||
|| *_forcedOrigin == Origin::BottomRight));
|
||||
auto w = p - QPoint(0, _padding.top());
|
||||
auto r = screen->availableGeometry();
|
||||
_useTransparency = Platform::TranslucentWindowsSupported(p);
|
||||
|
|
|
|||
|
|
@ -21,6 +21,11 @@ class ScrollArea;
|
|||
|
||||
class PopupMenu : public RpWidget {
|
||||
public:
|
||||
enum class VerticalOrigin {
|
||||
Top,
|
||||
Bottom,
|
||||
};
|
||||
|
||||
PopupMenu(QWidget *parent, const style::PopupMenu &st = st::defaultPopupMenu);
|
||||
PopupMenu(QWidget *parent, QMenu *menu, const style::PopupMenu &st = st::defaultPopupMenu);
|
||||
|
||||
|
|
@ -53,6 +58,7 @@ public:
|
|||
void popup(const QPoint &p);
|
||||
void hideMenu(bool fast = false);
|
||||
void setForcedOrigin(PanelAnimation::Origin origin);
|
||||
void setForcedVerticalOrigin(VerticalOrigin origin);
|
||||
|
||||
void setDestroyedCallback(Fn<void()> callback) {
|
||||
_destroyedCallback = std::move(callback);
|
||||
|
|
@ -143,6 +149,7 @@ private:
|
|||
|
||||
QPointer<PopupMenu> _activeSubmenu;
|
||||
|
||||
std::optional<VerticalOrigin> _forcedVerticalOrigin;
|
||||
PanelAnimation::Origin _origin = PanelAnimation::Origin::TopLeft;
|
||||
std::optional<PanelAnimation::Origin> _forcedOrigin;
|
||||
std::unique_ptr<PanelAnimation> _showAnimation;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue