mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Moved out color editor to td_ui.
This commit is contained in:
parent
e3334f7a87
commit
9390450049
7 changed files with 16 additions and 16 deletions
|
@ -243,8 +243,6 @@ PRIVATE
|
||||||
boxes/download_path_box.h
|
boxes/download_path_box.h
|
||||||
boxes/edit_caption_box.cpp
|
boxes/edit_caption_box.cpp
|
||||||
boxes/edit_caption_box.h
|
boxes/edit_caption_box.h
|
||||||
boxes/edit_color_box.cpp
|
|
||||||
boxes/edit_color_box.h
|
|
||||||
boxes/edit_privacy_box.cpp
|
boxes/edit_privacy_box.cpp
|
||||||
boxes/edit_privacy_box.h
|
boxes/edit_privacy_box.h
|
||||||
boxes/gift_premium_box.cpp
|
boxes/gift_premium_box.cpp
|
||||||
|
|
|
@ -18,11 +18,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "boxes/background_preview_box.h"
|
#include "boxes/background_preview_box.h"
|
||||||
#include "boxes/download_path_box.h"
|
#include "boxes/download_path_box.h"
|
||||||
#include "boxes/local_storage_box.h"
|
#include "boxes/local_storage_box.h"
|
||||||
#include "boxes/edit_color_box.h"
|
|
||||||
#include "ui/wrap/vertical_layout.h"
|
#include "ui/wrap/vertical_layout.h"
|
||||||
#include "ui/wrap/slide_wrap.h"
|
#include "ui/wrap/slide_wrap.h"
|
||||||
#include "ui/widgets/input_fields.h"
|
#include "ui/widgets/input_fields.h"
|
||||||
#include "ui/widgets/checkbox.h"
|
#include "ui/widgets/checkbox.h"
|
||||||
|
#include "ui/widgets/color_editor.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/widgets/labels.h"
|
#include "ui/widgets/labels.h"
|
||||||
#include "ui/chat/attach/attach_extensions.h"
|
#include "ui/chat/attach/attach_extensions.h"
|
||||||
|
|
|
@ -5,7 +5,7 @@ the official desktop application for the Telegram messaging service.
|
||||||
For license and copyright information please follow this link:
|
For license and copyright information please follow this link:
|
||||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "boxes/edit_color_box.h"
|
#include "ui/widgets/color_editor.h"
|
||||||
|
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "ui/widgets/shadow.h"
|
#include "ui/widgets/shadow.h"
|
||||||
|
@ -69,8 +69,8 @@ QCursor ColorEditor::Picker::generateCursor() {
|
||||||
auto diameter = style::ConvertScale(16);
|
auto diameter = style::ConvertScale(16);
|
||||||
auto line = style::ConvertScale(1);
|
auto line = style::ConvertScale(1);
|
||||||
auto size = ((diameter + 2 * line) >= 32) ? 64 : 32;
|
auto size = ((diameter + 2 * line) >= 32) ? 64 : 32;
|
||||||
auto cursor = QImage(QSize(size, size) * cIntRetinaFactor(), QImage::Format_ARGB32_Premultiplied);
|
auto cursor = QImage(QSize(size, size) * style::DevicePixelRatio(), QImage::Format_ARGB32_Premultiplied);
|
||||||
cursor.setDevicePixelRatio(cRetinaFactor());
|
cursor.setDevicePixelRatio(style::DevicePixelRatio());
|
||||||
cursor.fill(Qt::transparent);
|
cursor.fill(Qt::transparent);
|
||||||
{
|
{
|
||||||
auto p = QPainter(&cursor);
|
auto p = QPainter(&cursor);
|
||||||
|
@ -97,7 +97,7 @@ ColorEditor::Picker::Picker(QWidget *parent, Mode mode, QColor color)
|
||||||
auto size = QSize(st::colorPickerSize, st::colorPickerSize);
|
auto size = QSize(st::colorPickerSize, st::colorPickerSize);
|
||||||
resize(size);
|
resize(size);
|
||||||
|
|
||||||
_palette = QImage(size * cIntRetinaFactor(), QImage::Format_ARGB32_Premultiplied);
|
_palette = QImage(size * style::DevicePixelRatio(), QImage::Format_ARGB32_Premultiplied);
|
||||||
|
|
||||||
setFromColor(color);
|
setFromColor(color);
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@ void ColorEditor::Picker::preparePalette() {
|
||||||
} else {
|
} else {
|
||||||
preparePaletteHSL();
|
preparePaletteHSL();
|
||||||
}
|
}
|
||||||
_palette.setDevicePixelRatio(cRetinaFactor());
|
_palette.setDevicePixelRatio(style::DevicePixelRatio());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorEditor::Picker::preparePaletteRGBA() {
|
void ColorEditor::Picker::preparePaletteRGBA() {
|
||||||
|
@ -400,9 +400,9 @@ void ColorEditor::Slider::mouseReleaseEvent(QMouseEvent *e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorEditor::Slider::generatePixmap() {
|
void ColorEditor::Slider::generatePixmap() {
|
||||||
auto size = (isHorizontal() ? width() : height()) * cIntRetinaFactor();
|
auto size = (isHorizontal() ? width() : height()) * style::DevicePixelRatio();
|
||||||
auto image = QImage(size, cIntRetinaFactor(), QImage::Format_ARGB32_Premultiplied);
|
auto image = QImage(size, style::DevicePixelRatio(), QImage::Format_ARGB32_Premultiplied);
|
||||||
image.setDevicePixelRatio(cRetinaFactor());
|
image.setDevicePixelRatio(style::DevicePixelRatio());
|
||||||
auto ints = reinterpret_cast<uint32*>(image.bits());
|
auto ints = reinterpret_cast<uint32*>(image.bits());
|
||||||
auto intsPerLine = image.bytesPerLine() / sizeof(uint32);
|
auto intsPerLine = image.bytesPerLine() / sizeof(uint32);
|
||||||
auto intsPerLineAdded = intsPerLine - size;
|
auto intsPerLineAdded = intsPerLine - size;
|
||||||
|
@ -415,7 +415,7 @@ void ColorEditor::Slider::generatePixmap() {
|
||||||
for (auto x = 0; x != size; ++x) {
|
for (auto x = 0; x != size; ++x) {
|
||||||
const auto color = QColor::fromHsv(x * 360 / size, 255, 255);
|
const auto color = QColor::fromHsv(x * 360 / size, 255, 255);
|
||||||
const auto value = anim::getPremultiplied(color.toRgb());
|
const auto value = anim::getPremultiplied(color.toRgb());
|
||||||
for (auto y = 0; y != cIntRetinaFactor(); ++y) {
|
for (auto y = 0; y != style::DevicePixelRatio(); ++y) {
|
||||||
ints[y * intsPerLine] = value;
|
ints[y * intsPerLine] = value;
|
||||||
}
|
}
|
||||||
++ints;
|
++ints;
|
||||||
|
@ -427,7 +427,7 @@ void ColorEditor::Slider::generatePixmap() {
|
||||||
} else if (_type == Type::Opacity) {
|
} else if (_type == Type::Opacity) {
|
||||||
auto color = anim::shifted(QColor(255, 255, 255, 255));
|
auto color = anim::shifted(QColor(255, 255, 255, 255));
|
||||||
auto transparent = anim::shifted(QColor(255, 255, 255, 0));
|
auto transparent = anim::shifted(QColor(255, 255, 255, 0));
|
||||||
for (auto y = 0; y != cIntRetinaFactor(); ++y) {
|
for (auto y = 0; y != style::DevicePixelRatio(); ++y) {
|
||||||
auto x_accumulated = 0;
|
auto x_accumulated = 0;
|
||||||
for (auto x = 0; x != size; ++x, x_accumulated += part) {
|
for (auto x = 0; x != size; ++x, x_accumulated += part) {
|
||||||
auto x_ratio = x_accumulated >> (LargeBit - 8);
|
auto x_ratio = x_accumulated >> (LargeBit - 8);
|
||||||
|
@ -451,7 +451,7 @@ void ColorEditor::Slider::generatePixmap() {
|
||||||
_color.hslSaturation(),
|
_color.hslSaturation(),
|
||||||
_lightnessMin + x * range / size);
|
_lightnessMin + x * range / size);
|
||||||
const auto value = anim::getPremultiplied(color.toRgb());
|
const auto value = anim::getPremultiplied(color.toRgb());
|
||||||
for (auto y = 0; y != cIntRetinaFactor(); ++y) {
|
for (auto y = 0; y != style::DevicePixelRatio(); ++y) {
|
||||||
ints[y * intsPerLine] = value;
|
ints[y * intsPerLine] = value;
|
||||||
}
|
}
|
||||||
++ints;
|
++ints;
|
|
@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "storage/localstorage.h"
|
#include "storage/localstorage.h"
|
||||||
#include "ui/boxes/confirm_box.h"
|
#include "ui/boxes/confirm_box.h"
|
||||||
|
#include "ui/widgets/color_editor.h"
|
||||||
#include "ui/widgets/scroll_area.h"
|
#include "ui/widgets/scroll_area.h"
|
||||||
#include "ui/widgets/shadow.h"
|
#include "ui/widgets/shadow.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
|
@ -32,7 +33,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "base/call_delayed.h"
|
#include "base/call_delayed.h"
|
||||||
#include "core/file_utilities.h"
|
#include "core/file_utilities.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "boxes/edit_color_box.h"
|
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "styles/style_window.h"
|
#include "styles/style_window.h"
|
||||||
#include "styles/style_dialogs.h"
|
#include "styles/style_dialogs.h"
|
||||||
|
|
|
@ -9,11 +9,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "base/call_delayed.h"
|
#include "base/call_delayed.h"
|
||||||
#include "boxes/abstract_box.h"
|
#include "boxes/abstract_box.h"
|
||||||
#include "boxes/edit_color_box.h"
|
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "ui/effects/ripple_animation.h"
|
#include "ui/effects/ripple_animation.h"
|
||||||
#include "ui/layers/generic_box.h"
|
#include "ui/layers/generic_box.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
#include "ui/widgets/color_editor.h"
|
||||||
#include "ui/widgets/shadow.h"
|
#include "ui/widgets/shadow.h"
|
||||||
#include "styles/style_layers.h"
|
#include "styles/style_layers.h"
|
||||||
#include "styles/style_window.h"
|
#include "styles/style_window.h"
|
||||||
|
|
|
@ -264,6 +264,8 @@ PRIVATE
|
||||||
ui/text/text_options.cpp
|
ui/text/text_options.cpp
|
||||||
ui/text/text_options.h
|
ui/text/text_options.h
|
||||||
|
|
||||||
|
ui/widgets/color_editor.cpp
|
||||||
|
ui/widgets/color_editor.h
|
||||||
ui/widgets/continuous_sliders.cpp
|
ui/widgets/continuous_sliders.cpp
|
||||||
ui/widgets/continuous_sliders.h
|
ui/widgets/continuous_sliders.h
|
||||||
ui/widgets/discrete_sliders.cpp
|
ui/widgets/discrete_sliders.cpp
|
||||||
|
|
Loading…
Add table
Reference in a new issue