- Replace every hand drawn symbol and unicode glyph with Lucide icons via Symbol, with tooltips on icon buttons (built-in Tooltip, which does not swallow clicks), a proper gear and a clear log-out button for leaving a server. - Center text and controls vertically in channel rows, headers, the user panel and friend rows. - Message actions: quick reactions, add reaction, reply, edit and delete as icons. The bar stays visible while the pointer is over its buttons. - Emoji picker with categories and Russian and English search for the composer and for reactions. Reactions are shown under the message and toggle on click (ReactionAdd or ReactionRemove). - Remove the keyboard hint under the composer, add a placeholder and a growing editor with emoji and send buttons. - Voice room: participant cards with avatar and speaking ring, round icon controls with off states in red, accent gradient background. - One AvatarView everywhere (including voice cards and members). The local user is listed as online in the member list. - Real checkbox on the connect screen, theme overlay colour for the trust dialog, accent primary button. - ui_smoke now renders screens in all four themes and checks the member status, the action bar and the picker with real pointer input.
121 lines
6.6 KiB
Text
121 lines
6.6 KiB
Text
import { Theme, ActionButton } from "theme.slint";
|
|
import { AudioSlider } from "controls.slint";
|
|
|
|
export component AvatarCropper inherits Rectangle {
|
|
in property <image> avatar-source;
|
|
in property <float> source-width: 1;
|
|
in property <float> source-height: 1;
|
|
in property <float> offset-x;
|
|
in property <float> offset-y;
|
|
in-out property <float> zoom: 1;
|
|
in property <string> error;
|
|
callback crop-moved(float, float);
|
|
callback zoom-changed(float);
|
|
callback confirm();
|
|
callback cancel();
|
|
private property <length> frame-size: Math.min(320px, Math.max(220px, root.height - 350px));
|
|
private property <float> cover-scale: Math.max(root.frame-size / 1px / Math.max(root.source-width, 1), root.frame-size / 1px / Math.max(root.source-height, 1)) * root.zoom;
|
|
background: Theme.overlay;
|
|
TouchArea { }
|
|
keyboard := FocusScope {
|
|
init => { self.focus(); }
|
|
key-pressed(event) => {
|
|
if event.text == Key.Escape { root.cancel(); return accept; }
|
|
if event.text == "+" || event.text == "=" { root.set-zoom(root.zoom + 0.1); return accept; }
|
|
if event.text == "-" { root.set-zoom(root.zoom - 0.1); return accept; }
|
|
return reject;
|
|
}
|
|
Rectangle {
|
|
width: 440px;
|
|
height: Math.min(620px, root.height - 24px);
|
|
x: (root.width - self.width) / 2;
|
|
y: (root.height - self.height) / 2;
|
|
background: Theme.bg-surface;
|
|
border-radius: 12px;
|
|
border-width: 1px;
|
|
border-color: Theme.border;
|
|
VerticalLayout {
|
|
padding: 18px; spacing: 8px; alignment: start;
|
|
HorizontalLayout {
|
|
Text { text: @tr("Crop photo"); color: Theme.text-primary; font-size: Theme.font-size + 5px; font-weight: 600; horizontal-stretch: 1; vertical-alignment: center; }
|
|
ActionButton { text: @tr("Cancel"); icon: "x"; width: 30px; quiet: true; clicked => { root.cancel(); } }
|
|
}
|
|
Text { text: @tr("Drag the photo and adjust the zoom."); color: Theme.text-muted; font-size: Math.max(Theme.font-size - 3px, 11px); }
|
|
Rectangle { height: 4px; }
|
|
HorizontalLayout {
|
|
Rectangle { horizontal-stretch: 1; }
|
|
frame := Rectangle {
|
|
width: root.frame-size; height: root.frame-size;
|
|
clip: true; background: Theme.bg-surface;
|
|
accessible-role: image;
|
|
accessible-label: @tr("Photo crop area. Drag the image to adjust the crop.");
|
|
Image {
|
|
source: root.avatar-source;
|
|
width: root.source-width * root.cover-scale * 1px;
|
|
height: root.source-height * root.cover-scale * 1px;
|
|
x: (frame.width - self.width) / 2 + root.offset-x * frame.width;
|
|
y: (frame.height - self.height) / 2 + root.offset-y * frame.height;
|
|
image-fit: fill;
|
|
}
|
|
// The mask makes the final circular avatar explicit, independently
|
|
// of renderer support for rounded clipping of bitmap images.
|
|
Path {
|
|
width: parent.width; height: parent.height;
|
|
viewbox-width: 320; viewbox-height: 320;
|
|
fill: Theme.bg-surface;
|
|
fill-rule: evenodd;
|
|
commands: "M0 0H320V320H0Z M320 160 A160 160 0 1 0 0 160 A160 160 0 1 0 320 160Z";
|
|
}
|
|
Rectangle {
|
|
width: parent.width; height: parent.height;
|
|
border-radius: parent.width / 2;
|
|
border-width: 1px; border-color: Theme.border;
|
|
background: transparent;
|
|
}
|
|
drag := TouchArea {
|
|
property <float> start-x;
|
|
property <float> start-y;
|
|
pointer-event(event) => {
|
|
if event.button == PointerEventButton.left && event.kind == PointerEventKind.down {
|
|
self.start-x = root.offset-x;
|
|
self.start-y = root.offset-y;
|
|
keyboard.focus();
|
|
}
|
|
}
|
|
moved => {
|
|
if self.pressed {
|
|
root.crop-moved(self.start-x + (self.mouse-x - self.pressed-x) / frame.width,
|
|
self.start-y + (self.mouse-y - self.pressed-y) / frame.height);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
Rectangle { horizontal-stretch: 1; }
|
|
}
|
|
Rectangle { height: 2px; }
|
|
HorizontalLayout {
|
|
spacing: 10px;
|
|
ActionButton { text: "-"; width: 32px; clicked => { root.set-zoom(root.zoom - 0.1); } }
|
|
AudioSlider { minimum: 1; maximum: 3; value <=> root.zoom; changed(value) => { root.zoom-changed(value); } }
|
|
ActionButton { text: "+"; width: 32px; clicked => { root.set-zoom(root.zoom + 0.1); } }
|
|
}
|
|
HorizontalLayout {
|
|
Text { text: @tr("Zoom {}%", Math.round(root.zoom * 100)); color: Theme.text-muted; font-size: Math.max(Theme.font-size - 4px, 11px); vertical-alignment: center; horizontal-stretch: 1; }
|
|
ActionButton { text: @tr("Reset crop"); quiet: true; clicked => { root.crop-moved(0,0); root.set-zoom(1); } }
|
|
}
|
|
if root.error != "" : Text { text: root.error; color: Theme.danger; font-size: Math.max(Theme.font-size - 3px, 11px); wrap: word-wrap; }
|
|
Rectangle { vertical-stretch: 1; }
|
|
HorizontalLayout {
|
|
spacing: 9px;
|
|
ActionButton { text: @tr("Cancel"); quiet: true; clicked => { root.cancel(); } }
|
|
Rectangle { horizontal-stretch: 1; }
|
|
ActionButton { text: @tr("Use photo"); active: true; clicked => { root.confirm(); } }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function set-zoom(value: float) {
|
|
root.zoom = Math.clamp(value, 1, 3);
|
|
root.zoom-changed(root.zoom);
|
|
}
|
|
}
|