Skip to content

Commit

Permalink
Update default tooltip colors.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Jul 24, 2023
1 parent ad852f0 commit bd1e8f7
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 4 deletions.
6 changes: 3 additions & 3 deletions ui/colors.palette
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,8 @@ youtubePlayIconBg: #e83131c8; // youtube play icon background (when a link to a
youtubePlayIconFg: windowFgActive; // youtube play icon arrow (when a link to a youtube video with a webpage preview is sent)
videoPlayIconBg: #0000007f; // other video play icon background (like when a link to a vimeo video with a webpage preview is sent)
videoPlayIconFg: #ffffff; // other video play icon arrow (like when a link to a vimeo video with a webpage preview is sent)
toastBg: #000000b2; // toast notification background (like when you click on your t.me link when editing your username)
toastFg: windowFgActive; // toast notification text (like when you click on your t.me link when editing your username)
toastBg: #2c3033e5; // toast notification background (like when you click on your t.me link when editing your username)
toastFg: #ffffff; // toast notification text (like when you click on your t.me link when editing your username)

historyToDownBg: windowBg; // arrow button background (to scroll to the end of the viewed chat)
historyToDownBgOver: windowBgOver; // arrow button background with mouse over
Expand Down Expand Up @@ -518,7 +518,7 @@ mediaviewControlBg: #0000003c; // controls background (like next photo / previou
mediaviewControlFg: #ffffff; // controls icon (like next photo / previous photo)
mediaviewCaptionBg: #11111180; // caption text background (when viewing photo with caption)
mediaviewCaptionFg: mediaviewControlFg; // caption text
mediaviewTextLinkFg: #91d9ff; // caption text link
mediaviewTextLinkFg: #4db8ff; // caption text link
mediaviewSaveMsgBg: toastBg; // save to file toast message background in Media Viewer
mediaviewSaveMsgFg: toastFg; // save to file toast message text

Expand Down
2 changes: 1 addition & 1 deletion ui/toast/toast_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void Widget::paintEvent(QPaintEvent *e) {
}
_roundRect.paint(p, rect());
if (_dark) {
_roundRect.paint(p, rect());
//_roundRect.paint(p, rect());
}

if (!_st->icon.empty()) {
Expand Down
38 changes: 38 additions & 0 deletions ui/widgets/tooltip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "ui/ui_utility.h"
#include "ui/painter.h"
#include "ui/platform/ui_platform_utility.h"
#include "ui/widgets/labels.h"
#include "base/invoke_queued.h"
#include "base/platform/base_platform_info.h"
#include "styles/style_widgets.h"
Expand Down Expand Up @@ -410,4 +411,41 @@ void ImportantTooltip::paintEvent(QPaintEvent *e) {
}
}

object_ptr<FlatLabel> MakeNiceTooltipLabel(
QWidget *parent,
rpl::producer<TextWithEntities> &&text,
int maxWidth,
const style::FlatLabel &st,
const style::PopupMenu &stMenu) {
Expects(st.minWidth > 0);
Expects(st.minWidth < maxWidth);

auto result = object_ptr<FlatLabel>(
parent,
rpl::duplicate(text),
st,
stMenu);
const auto raw = result.data();
std::move(text) | rpl::start_with_next([=, &st] {
raw->resizeToNaturalWidth(maxWidth);
if (raw->naturalWidth() <= maxWidth) {
return;
}
const auto desired = raw->heightNoMargins();
auto from = st.minWidth;
auto till = maxWidth;
while (till - from > 1) {
const auto middle = (from + till) / 2;
raw->resizeToWidth(middle);
if (raw->heightNoMargins() > desired) {
from = middle;
} else {
till = middle;
}
}
raw->resizeToWidth(till);
}, raw->lifetime());
return result;
}

} // namespace Ui
16 changes: 16 additions & 0 deletions ui/widgets/tooltip.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,19 @@
namespace style {
struct Tooltip;
struct ImportantTooltip;
struct FlatLabel;
struct PopupMenu;
} // namespace style

namespace st {
extern const style::FlatLabel &defaultFlatLabel;
extern const style::PopupMenu &defaultPopupMenu;
} // namespace st

namespace Ui {

class FlatLabel;

class AbstractTooltipShower {
public:
virtual QString tooltipText() const = 0;
Expand Down Expand Up @@ -113,4 +122,11 @@ class ImportantTooltip : public RpWidget {

};

[[nodiscard]] object_ptr<FlatLabel> MakeNiceTooltipLabel(
QWidget *parent,
rpl::producer<TextWithEntities> &&text,
int maxWidth,
const style::FlatLabel &st = st::defaultFlatLabel,
const style::PopupMenu &stMenu = st::defaultPopupMenu);

} // namespace Ui

0 comments on commit bd1e8f7

Please sign in to comment.