tdesktop/Telegram/SourceFiles/boxes/abstractbox.h

115 lines
2.7 KiB
C
Raw Normal View History

/*
This file is part of Telegram Desktop,
the official desktop version of Telegram messaging app, see https://telegram.org
Telegram Desktop is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
It is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
2015-10-03 13:16:42 +00:00
In addition, as a special exception, the copyright holders give permission
to link the code of portions of this program with the OpenSSL library.
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
2016-02-08 10:56:18 +00:00
Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
*/
#pragma once
#include "layerwidget.h"
#include "ui/widgets/shadow.h"
2016-10-31 12:29:26 +00:00
namespace Ui {
class IconButton;
class GradientShadow;
2016-10-31 12:29:26 +00:00
} // namespace Ui
class AbstractBox : public LayerWidget, protected base::Subscriber {
Q_OBJECT
public:
AbstractBox(int w = 0);
void parentResized() override;
void showDone() override {
showAll();
}
2015-10-11 08:37:24 +00:00
void setBlockTitle(bool block);
2015-10-11 08:37:24 +00:00
void raiseShadow();
public slots:
void onClose();
protected:
void keyPressEvent(QKeyEvent *e) override;
void resizeEvent(QResizeEvent *e) override;
void paintEvent(QPaintEvent *e) override;
void prepare();
bool paint(QPainter &p);
int titleHeight() const;
2015-10-11 08:37:24 +00:00
void paintTitle(Painter &p, const QString &title, const QString &additional = QString());
void setMaxHeight(int32 maxHeight);
void resizeMaxHeight(int32 newWidth, int32 maxHeight);
virtual void closePressed() {
}
virtual void showAll() {
}
private:
int _maxHeight = 0;
int countHeight() const;
bool _closed = false;
2015-10-11 08:37:24 +00:00
bool _blockTitle = false;
ChildWidget<Ui::IconButton> _blockClose = { nullptr };
ChildWidget<Ui::GradientShadow> _blockShadow = { nullptr };
2015-10-11 08:37:24 +00:00
};
class ScrollableBoxShadow : public Ui::PlainShadow {
2015-10-11 08:37:24 +00:00
public:
ScrollableBoxShadow(QWidget *parent);
};
class ScrollableBox : public AbstractBox {
public:
ScrollableBox(const style::flatScroll &scroll, int w = 0);
protected:
void init(TWidget *inner, int bottomSkip = -1, int topSkip = -1);
void setScrollSkips(int bottomSkip = -1, int topSkip = -1);
void resizeEvent(QResizeEvent *e) override;
ScrollArea *scrollArea() {
return _scroll;
}
private:
void updateScrollGeometry();
ChildWidget<ScrollArea> _scroll;
int _topSkip, _bottomSkip;
};
class ItemListBox : public ScrollableBox {
public:
ItemListBox(const style::flatScroll &scroll, int32 w = 0);
2015-10-11 08:37:24 +00:00
};
2015-10-11 08:37:24 +00:00
enum CreatingGroupType {
CreatingGroupNone,
CreatingGroupGroup,
CreatingGroupChannel,
2015-10-03 10:09:09 +00:00
};