Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-style all text inputs to be consistent with better coloring #318

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 3 additions & 82 deletions src/home/room_screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -824,90 +824,11 @@ live_design! {
text: "",
}

message_input = <TextInput> {
width: Fill, height: Fit, margin: 0
message_input = <RobrixTextInput> {
width: Fill, height: Fit,
margin: 0,
align: {y: 0.5}
empty_message: "Write a message (in Markdown) ..."
draw_bg: {
color: (COLOR_PRIMARY)
instance radius: 2.0
instance border_width: 0.8
instance border_color: #D0D5DD
instance inset: vec4(0.0, 0.0, 0.0, 0.0)

fn get_color(self) -> vec4 {
return self.color
}

fn get_border_color(self) -> vec4 {
return self.border_color
}

fn pixel(self) -> vec4 {
let sdf = Sdf2d::viewport(self.pos * self.rect_size)
sdf.box(
self.inset.x + self.border_width,
self.inset.y + self.border_width,
self.rect_size.x - (self.inset.x + self.inset.z + self.border_width * 2.0),
self.rect_size.y - (self.inset.y + self.inset.w + self.border_width * 2.0),
max(1.0, self.radius)
)
sdf.fill_keep(self.get_color())
if self.border_width > 0.0 {
sdf.stroke(self.get_border_color(), self.border_width)
}
return sdf.result;
}
}
draw_text: {
color: (MESSAGE_TEXT_COLOR),
text_style: <MESSAGE_TEXT_STYLE>{},

fn get_color(self) -> vec4 {
return mix(
self.color,
#B,
self.is_empty
)
}
}

// TODO find a way to override colors
draw_cursor: {
instance focus: 0.0
uniform border_radius: 0.5
fn pixel(self) -> vec4 {
let sdf = Sdf2d::viewport(self.pos * self.rect_size);
sdf.box(
0.,
0.,
self.rect_size.x,
self.rect_size.y,
self.border_radius
)
sdf.fill(mix(#0f0, #0b0, self.focus));
return sdf.result
}
}

// TODO find a way to override colors
draw_selection: {
instance hover: 0.0
instance focus: 0.0
uniform border_radius: 2.0
fn pixel(self) -> vec4 {
let sdf = Sdf2d::viewport(self.pos * self.rect_size);
sdf.box(
0.,
0.,
self.rect_size.x,
self.rect_size.y,
self.border_radius
)
sdf.fill(mix(#dfffd6, #bfffb0, self.focus));
return sdf.result
}
}
}

send_message_button = <IconButton> {
Expand Down
96 changes: 6 additions & 90 deletions src/login/login_screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,93 +16,7 @@ live_design! {

IMG_APP_LOGO = dep("crate://self/resources/robrix_logo_alpha.png")
ICON_SEARCH = dep("crate://self/resources/icons/search.svg")

LoginTextInput = <TextInput> {
width: Fill, height: Fit, margin: 0
align: {y: 0.5}
draw_bg: {
color: (COLOR_PRIMARY)
instance radius: 2.0
instance border_width: 0.8
instance border_color: #D0D5DD
instance inset: vec4(0.0, 0.0, 0.0, 0.0)

fn get_color(self) -> vec4 {
return self.color
}

fn get_border_color(self) -> vec4 {
return self.border_color
}

fn pixel(self) -> vec4 {
let sdf = Sdf2d::viewport(self.pos * self.rect_size)
sdf.box(
self.inset.x + self.border_width,
self.inset.y + self.border_width,
self.rect_size.x - (self.inset.x + self.inset.z + self.border_width * 2.0),
self.rect_size.y - (self.inset.y + self.inset.w + self.border_width * 2.0),
max(1.0, self.radius)
)
sdf.fill_keep(self.get_color())
if self.border_width > 0.0 {
sdf.stroke(self.get_border_color(), self.border_width)
}
return sdf.result;
}
}

draw_text: {
color: (MESSAGE_TEXT_COLOR),
text_style: <MESSAGE_TEXT_STYLE>{},

fn get_color(self) -> vec4 {
return mix(
self.color,
#B,
self.is_empty
)
}
}


// TODO find a way to override colors
draw_cursor: {
instance focus: 0.0
uniform border_radius: 0.5
fn pixel(self) -> vec4 {
let sdf = Sdf2d::viewport(self.pos * self.rect_size);
sdf.box(
0.,
0.,
self.rect_size.x,
self.rect_size.y,
self.border_radius
)
sdf.fill(mix(#fff, #bbb, self.focus));
return sdf.result
}
}

// TODO find a way to override colors
draw_selection: {
instance hover: 0.0
instance focus: 0.0
uniform border_radius: 2.0
fn pixel(self) -> vec4 {
let sdf = Sdf2d::viewport(self.pos * self.rect_size);
sdf.box(
0.,
0.,
self.rect_size.x,
self.rect_size.y,
self.border_radius
)
sdf.fill(mix(#eee, #ddd, self.focus)); // Pad color
return sdf.result
}
}
}
SsoButton = <RoundedView> {
width: Fit,
height: Fit,
Expand Down Expand Up @@ -136,13 +50,15 @@ live_design! {
draw_bg: {
color: (COLOR_PRIMARY)
}
align: {x: 0.5, y: 0.5}
// Note: *do NOT* vertically center this, it will break scrolling.
align: {x: 0.5}

<RoundedView> {
width: Fit, height: Fit
flow: Down
align: {x: 0.5, y: 0.5}
padding: 30
margin: 40
spacing: 15.0

show_bg: true,
Expand All @@ -166,12 +82,12 @@ live_design! {
text: "Login to Robrix"
}

user_id_input = <LoginTextInput> {
user_id_input = <RobrixTextInput> {
width: 250, height: 40
empty_message: "User ID"
}

password_input = <LoginTextInput> {
password_input = <RobrixTextInput> {
width: 250, height: 40
empty_message: "Password"
draw_text: { text_style: { is_secret: true } }
Expand All @@ -185,7 +101,7 @@ live_design! {
width: 215, height: Fit,
flow: Down,

homeserver_input = <LoginTextInput> {
homeserver_input = <RobrixTextInput> {
width: 215, height: 30,
empty_message: "matrix.org"
draw_text: {
Expand Down
78 changes: 3 additions & 75 deletions src/shared/search_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,86 +39,14 @@ live_design! {
icon_walk: {width: 14, height: Fit}
}

input = <TextInput> {
input = <RobrixTextInput> {
width: Fill,
height: 30.,
height: Fit,

empty_message: "Search"
empty_message: "Search..."

draw_text: {
text_style: { font_size: 10 },
fn get_color(self) -> vec4 {
return (COLOR_TEXT_INPUT_IDLE);
}
}

// TODO find a way to override colors
draw_cursor: {
instance focus: 0.0
uniform border_radius: 0.5
fn pixel(self) -> vec4 {
let sdf = Sdf2d::viewport(self.pos * self.rect_size);
sdf.box(
0.,
0.,
self.rect_size.x,
self.rect_size.y,
self.border_radius
)
sdf.fill(mix(#fff, #bbb, self.focus));
return sdf.result
}
}

// TODO find a way to override colors
draw_selection: {
instance hover: 0.0
instance focus: 0.0
uniform border_radius: 2.0
fn pixel(self) -> vec4 {
let sdf = Sdf2d::viewport(self.pos * self.rect_size);
sdf.box(
0.,
0.,
self.rect_size.x,
self.rect_size.y,
self.border_radius
)
sdf.fill(mix(#eee, #ddd, self.focus)); // Pad color
return sdf.result
}
}

draw_bg: {
color: (COLOR_PRIMARY)
instance radius: 0.0
instance border_width: 0.0
instance border_color: #3
instance inset: vec4(0.0, 0.0, 0.0, 0.0)

fn get_color(self) -> vec4 {
return self.color
}

fn get_border_color(self) -> vec4 {
return self.border_color
}

fn pixel(self) -> vec4 {
let sdf = Sdf2d::viewport(self.pos * self.rect_size)
sdf.box(
self.inset.x + self.border_width,
self.inset.y + self.border_width,
self.rect_size.x - (self.inset.x + self.inset.z + self.border_width * 2.0),
self.rect_size.y - (self.inset.y + self.inset.w + self.border_width * 2.0),
max(1.0, self.radius)
)
sdf.fill_keep(self.get_color())
if self.border_width > 0.0 {
sdf.stroke(self.get_border_color(), self.border_width)
}
return sdf.result;
}
}
}

Expand Down
Loading
Loading