mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-08-08 12:43:52 +00:00
Gray formula placeholder, re-roll sample on clear
This commit is contained in:
@@ -1669,23 +1669,31 @@ void EditMathBox(
|
||||
host->resize(cardWidth, desiredHeight);
|
||||
}, host->lifetime());
|
||||
preview->setSource(startSource);
|
||||
const auto interacted = box->lifetime().make_state<bool>(false);
|
||||
if (startSource.isEmpty()) {
|
||||
const auto applyRandomSample = [=] {
|
||||
const auto &sample = kFormulaSamples[
|
||||
base::RandomIndex(int(kFormulaSamples.size()))];
|
||||
source->setPlaceholder(rpl::single(sample));
|
||||
preview->setColor(st::windowSubTextFg);
|
||||
preview->setSource(sample);
|
||||
};
|
||||
const auto wasEmpty = box->lifetime().make_state<bool>(
|
||||
startSource.isEmpty());
|
||||
if (startSource.isEmpty()) {
|
||||
applyRandomSample();
|
||||
}
|
||||
source->changes(
|
||||
) | rpl::on_next([=] {
|
||||
if (!*interacted) {
|
||||
*interacted = true;
|
||||
const auto text = source->getLastText();
|
||||
if (text.isEmpty()) {
|
||||
if (!*wasEmpty) {
|
||||
*wasEmpty = true;
|
||||
applyRandomSample();
|
||||
}
|
||||
} else {
|
||||
*wasEmpty = false;
|
||||
preview->setColor(st::ivFormulaPreviewFg);
|
||||
source->setPlaceholder(
|
||||
tr::lng_formatting_math_source_placeholder());
|
||||
preview->setSource(text);
|
||||
}
|
||||
preview->setSource(source->getLastText());
|
||||
}, source->lifetime());
|
||||
|
||||
box->setTitle(editingExisting
|
||||
|
||||
@@ -577,9 +577,13 @@ ivFormulaPreviewRadius: 8px;
|
||||
ivFormulaPreviewBg: windowBgOver;
|
||||
ivFormulaPreviewFg: windowFg;
|
||||
ivFormulaSourceField: InputField(defaultInputField) {
|
||||
textMargins: margins(0px, 6px, 0px, 4px);
|
||||
placeholderFg: placeholderFg;
|
||||
placeholderFgActive: placeholderFgActive;
|
||||
placeholderScale: 0.;
|
||||
placeholderFont: normalFont;
|
||||
placeholderShift: -50px;
|
||||
heightMin: 33px;
|
||||
}
|
||||
defaultMarkdownTable: MarkdownTable {
|
||||
cellPadding: margins(8px, 10px, 8px, 10px);
|
||||
|
||||
Reference in New Issue
Block a user