mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 18:21:42 -05:00
104 lines
2.7 KiB
C
104 lines
2.7 KiB
C
![]() |
/*
|
||
|
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.
|
||
|
|
||
|
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
|
||
|
Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||
|
*/
|
||
|
#pragma once
|
||
|
|
||
|
#include "layout.h"
|
||
|
#include "structs.h"
|
||
|
#include "gui/text.h"
|
||
|
|
||
|
namespace InlineBots {
|
||
|
class Result;
|
||
|
|
||
|
namespace Layout {
|
||
|
|
||
|
class PaintContext : public PaintContextBase {
|
||
|
public:
|
||
|
PaintContext(uint64 ms, bool selecting, bool paused, bool lastRow)
|
||
|
: PaintContextBase(ms, selecting)
|
||
|
, paused(paused)
|
||
|
, lastRow(lastRow) {
|
||
|
}
|
||
|
bool paused, lastRow;
|
||
|
};
|
||
|
|
||
|
// this type used as a flag, we dynamic_cast<> to it
|
||
|
class SendClickHandler : public ClickHandler {
|
||
|
public:
|
||
|
void onClick(Qt::MouseButton) const override {
|
||
|
}
|
||
|
};
|
||
|
|
||
|
class ItemBase : public LayoutItemBase {
|
||
|
public:
|
||
|
|
||
|
ItemBase(Result *result) : _result(result) {
|
||
|
}
|
||
|
ItemBase(DocumentData *doc) : _doc(doc) {
|
||
|
}
|
||
|
// Not used anywhere currently.
|
||
|
//ItemBase(PhotoData *photo) : _photo(photo) {
|
||
|
//}
|
||
|
|
||
|
virtual void paint(Painter &p, const QRect &clip, uint32 selection, const PaintContext *context) const = 0;
|
||
|
|
||
|
virtual void setPosition(int32 position);
|
||
|
int32 position() const;
|
||
|
|
||
|
virtual bool isFullLine() const {
|
||
|
return true;
|
||
|
}
|
||
|
virtual bool hasRightSkip() const {
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
Result *getResult() const;
|
||
|
DocumentData *getDocument() const;
|
||
|
PhotoData *getPhoto() const;
|
||
|
|
||
|
virtual void preload() const;
|
||
|
|
||
|
void update();
|
||
|
|
||
|
// ClickHandlerHost interface
|
||
|
void clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) override {
|
||
|
update();
|
||
|
}
|
||
|
void clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) override {
|
||
|
update();
|
||
|
}
|
||
|
|
||
|
static UniquePointer<ItemBase> createLayout(Result *result, bool forceThumb);
|
||
|
static UniquePointer<ItemBase> createLayoutGif(DocumentData *document);
|
||
|
|
||
|
protected:
|
||
|
Result *_result = nullptr;
|
||
|
DocumentData *_doc = nullptr;
|
||
|
PhotoData *_photo = nullptr;
|
||
|
|
||
|
ClickHandlerPtr _send = ClickHandlerPtr{ new SendClickHandler() };
|
||
|
|
||
|
int _position = 0; // < 0 means removed from layout
|
||
|
|
||
|
};
|
||
|
|
||
|
} // namespace Layout
|
||
|
} // namespace InlineBots
|