Skip to content

Commit

Permalink
Bump Makepad version - update set_visible and set_text usage (#355)
Browse files Browse the repository at this point in the history
* Bump Makepad version - update set_visible and set_text usage

* Add missing spaces after (cx,...) for consistency

* Revert AI autocomplete slop

* Bump Makepad
  • Loading branch information
joulei authored Jan 28, 2025
1 parent a0997b4 commit 9fb2cb5
Show file tree
Hide file tree
Showing 28 changed files with 308 additions and 305 deletions.
55 changes: 28 additions & 27 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ impl App {

match notification {
DownloadPendingNotification::DownloadedFile(file) => {
popup.set_data(&file, DownloadResult::Success);
popup.set_data(cx, &file, DownloadResult::Success);
cx.action(ModelSelectorListAction::AddedOrDeletedModel);
}
DownloadPendingNotification::DownloadErrored(file) => {
Expand All @@ -315,20 +315,20 @@ impl App {
0 => {
self.timer = cx.start_timeout(15.0);
self.download_retry_attempts += 1;
popup.set_retry_data();
popup.set_retry_data(cx);
},
1 => {
self.timer = cx.start_timeout(30.0);
self.download_retry_attempts += 1;
popup.set_retry_data();
popup.set_retry_data(cx);
},
2 => {
self.timer = cx.start_timeout(60.0);
self.download_retry_attempts += 1;
popup.set_retry_data();
popup.set_retry_data(cx);
},
_ => {
popup.set_data(&file, DownloadResult::Failure);
popup.set_data(cx, &file, DownloadResult::Failure);
self.download_retry_attempts = 0;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/chat/chat_history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,12 @@ impl Widget for ChatHistory {
}
Item::NoAgentsWarning(text) => {
let item = list.item(cx, item_id, live_id!(NoAgentsWarning));
item.set_text(text);
item.set_text(cx, text);
item.draw_all(cx, scope);
}
Item::AgentButton(agent) => {
let item = list.item(cx, item_id, live_id!(Agent));
item.as_entity_button().set_agent(agent);
item.as_entity_button().set_agent(cx, agent);
item.draw_all(cx, scope);
}
Item::ChatButton(chat_id) => {
Expand Down
29 changes: 15 additions & 14 deletions src/chat/chat_history_card.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,10 +347,11 @@ impl Widget for ChatHistoryCard {

let caption = store.get_chat_entity_name(self.chat_id);
self.set_title_text(
cx,
chat.borrow_mut().get_title(),
&caption.clone().unwrap_or_default(),
);
self.update_title_visibility();
self.update_title_visibility(cx);

let initial_letter = caption
.unwrap_or("A".to_string())
Expand All @@ -364,17 +365,17 @@ impl Widget for ChatHistoryCard {
Some(ChatEntityId::Agent(agent_id)) => {
let agent = store.chats.get_agent_or_placeholder(&agent_id);

self.view(id!(avatar_section.model)).set_visible(false);
self.view(id!(avatar_section.model)).set_visible(cx, false);
self.chat_agent_avatar(id!(avatar_section.agent))
.set_visible(true);
self.chat_agent_avatar(id!(avatar_section.agent))
.set_agent(agent);
}
_ => {
self.view(id!(avatar_section.model)).set_visible(true);
self.view(id!(avatar_section.model)).set_visible(cx, true);
self.chat_agent_avatar(id!(avatar_section.agent))
.set_visible(false);
self.view.label(id!(avatar_label)).set_text(&initial_letter);
self.view.label(id!(avatar_label)).set_text(cx, &initial_letter);
}
}

Expand Down Expand Up @@ -448,23 +449,23 @@ impl ChatHistoryCard {
}
}

fn set_title_text(&mut self, text: &str, caption: &str) {
self.view.label(id!(title_label)).set_text(text.trim());
fn set_title_text(&mut self, cx: &mut Cx, text: &str, caption: &str) {
self.view.label(id!(title_label)).set_text(cx, text.trim());
if let TitleState::Editable = self.title_edition_state {
self.view.text_input(id!(title_input)).set_text(text.trim());
self.view.text_input(id!(title_input)).set_text(cx, text.trim());
}
self.label(id!(model_or_agent_name_label))
.set_text(&human_readable_name(caption));
.set_text(cx, &human_readable_name(caption));
}

fn update_title_visibility(&mut self) {
fn update_title_visibility(&mut self, cx: &mut Cx) {
let on_edit = matches!(self.title_edition_state, TitleState::OnEdit);
self.view(id!(edit_buttons)).set_visible(on_edit);
self.view(id!(title_input_container)).set_visible(on_edit);
self.button(id!(chat_options)).set_visible(!on_edit);
self.view(id!(edit_buttons)).set_visible(cx, on_edit);
self.view(id!(title_input_container)).set_visible(cx, on_edit);
self.button(id!(chat_options)).set_visible(cx, !on_edit);

let editable = matches!(self.title_edition_state, TitleState::Editable);
self.view(id!(title_label_container)).set_visible(editable);
self.view(id!(title_label_container)).set_visible(cx, editable);
}

fn transition_title_state(&mut self, cx: &mut Cx) {
Expand All @@ -473,7 +474,7 @@ impl ChatHistoryCard {
TitleState::Editable => TitleState::OnEdit,
};

self.update_title_visibility();
self.update_title_visibility(cx);
self.redraw(cx);

match self.title_edition_state {
Expand Down
Loading

0 comments on commit 9fb2cb5

Please sign in to comment.