Commit c3c64c75 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(ui/modules/Linphone/Contact/Avatar): uses the `RoundedImage` component

parent 80a19c1d
...@@ -3,8 +3,11 @@ import QtQuick 2.7 ...@@ -3,8 +3,11 @@ import QtQuick 2.7
// =================================================================== // ===================================================================
Item { Item {
id: item
property alias source: image.source property alias source: image.source
property color colorMask: '#00000000' property color backgroundColor: '#00000000'
property color foregroundColor: '#00000000'
// vec4(0.812, 0.843, 0.866, 1.0) 0.9 // vec4(0.812, 0.843, 0.866, 1.0) 0.9
Item { Item {
...@@ -27,23 +30,25 @@ Item { ...@@ -27,23 +30,25 @@ Item {
layer { layer {
effect: ShaderEffect { effect: ShaderEffect {
property color backgroundColor: item.backgroundColor
property color foregroundColor: item.foregroundColor
property var image: imageContainer property var image: imageContainer
property var color: colorMask
fragmentShader: ' fragmentShader: '
uniform lowp sampler2D image; uniform lowp sampler2D image;
uniform lowp sampler2D mask; uniform lowp sampler2D mask;
uniform lowp vec4 color; uniform lowp vec4 backgroundColor;
uniform lowp vec4 foregroundColor;
uniform lowp float qt_Opacity; uniform lowp float qt_Opacity;
varying highp vec2 qt_TexCoord0; varying highp vec2 qt_TexCoord0;
void main () { void main () {
vec4 tex = texture2D(image, qt_TexCoord0); vec4 tex = texture2D(image, qt_TexCoord0);
vec4 interpolation = mix(backgroundColor, vec4(tex.rgb, 1.0), tex.a);
interpolation = mix(interpolation, vec4(foregroundColor.rgb, 1.0), foregroundColor.a);
gl_FragColor = mix(tex, vec4(color.rgb, 1.0), color.a) * gl_FragColor = interpolation * texture2D(mask, qt_TexCoord0) * qt_Opacity;
texture2D(mask, qt_TexCoord0) *
qt_Opacity;
} }
' '
} }
......
import QtQuick 2.7 import QtQuick 2.7
import QtGraphicalEffects 1.0 import QtGraphicalEffects 1.0
import Common 1.0
import Linphone 1.0 import Linphone 1.0
import Linphone.Styles 1.0 import Linphone.Styles 1.0
import Utils 1.0 import Utils 1.0
...@@ -8,12 +9,14 @@ import Utils 1.0 ...@@ -8,12 +9,14 @@ import Utils 1.0
// =================================================================== // ===================================================================
Item { Item {
property alias image: imageToFilter.source property alias image: roundedImage.source
property alias presenceLevel: presenceLevel.level property alias presenceLevel: presenceLevel.level
property string username property string username
property var _initialsRegex: /^\s*([^\s\.]+)(?:[\s\.]+([^\s\.]+))?/ property var _initialsRegex: /^\s*([^\s\.]+)(?:[\s\.]+([^\s\.]+))?/
// -----------------------------------------------------------------
function _computeInitials () { function _computeInitials () {
var result = username.match(_initialsRegex) var result = username.match(_initialsRegex)
...@@ -29,16 +32,8 @@ Item { ...@@ -29,16 +32,8 @@ Item {
) )
} }
// Image mask. (Circle) // -----------------------------------------------------------------
Rectangle {
id: mask
anchors.fill: parent
color: AvatarStyle.mask.color
radius: AvatarStyle.mask.radius
}
// Initials.
Text { Text {
anchors.centerIn: parent anchors.centerIn: parent
color: AvatarStyle.initials.color color: AvatarStyle.initials.color
...@@ -55,24 +50,13 @@ Item { ...@@ -55,24 +50,13 @@ Item {
text: _computeInitials() text: _computeInitials()
} }
Image { RoundedImage {
anchors.fill: parent id: roundedImage
id: imageToFilter
fillMode: Image.PreserveAspectFit
// Image must be invisible.
// The only visible image is the OpacityMask!
visible: false
}
// Avatar. anchors.fill: parent
OpacityMask { backgroundColor: AvatarStyle.backgroundColor
anchors.fill: imageToFilter
maskSource: mask
source: imageToFilter
} }
// Presence.
PresenceLevel { PresenceLevel {
id: presenceLevel id: presenceLevel
......
...@@ -6,14 +6,11 @@ import Common 1.0 ...@@ -6,14 +6,11 @@ import Common 1.0
// =================================================================== // ===================================================================
QtObject { QtObject {
property color backgroundColor: Colors.r
property QtObject initials: QtObject { property QtObject initials: QtObject {
property color color: Colors.k property color color: Colors.k
property int fontSize: 10 property int fontSize: 10
property int ratio: 30 property int ratio: 30
} }
property QtObject mask: QtObject {
property color color: Colors.r
property int radius: 500
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment