Added Draggable area widget

This commit is contained in:
Syniis 2024-01-28 23:50:43 +01:00
parent dfffb658f4
commit 4d1d2e58da

View File

@ -24,6 +24,7 @@ use vek::Vec2;
widget_ids! {
struct Ids {
draggable_area,
message_box,
message_box_bg,
chat_input,
@ -269,8 +270,6 @@ impl<'a> Widget for Chat<'a> {
}
};
handle_chat_mouse_events(state.ids.message_box, ui, &mut events);
// Maintain scrolling //
if !self.new_messages.is_empty() {
for message in self.new_messages.iter() {
@ -569,6 +568,7 @@ impl<'a> Widget for Chat<'a> {
.w(self.chat_size.x - 17.0)
.color(color)
.line_spacing(2.0);
// Add space between messages.
let y = match text.get_y_dimension(ui) {
Dimension::Absolute(y) => y + 2.0,
@ -775,6 +775,21 @@ impl<'a> Widget for Chat<'a> {
events.push(Event::SendMessage(msg));
}
}
Rectangle::fill([self.chat_size.x, self.chat_size.y])
.rgba(0.0, 0.0, 0.0, 0.0)
.and(|r| {
if input_focused {
r.up_from(
state.ids.chat_input_border_up,
0.0 + CHAT_MARGIN_THICKNESS / 2.0,
)
} else {
r.bottom_left_with_margins_on(ui.window, self.chat_pos.y, self.chat_pos.x)
}
})
.set(state.ids.draggable_area, ui);
handle_chat_mouse_events(state.ids.draggable_area, ui, &mut events);
events
}
}