← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/bug-1672059-table-message-arrival into lp:widelands

 

GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-1672059-table-message-arrival into lp:widelands.

Commit message:
Fixes for popup news messages when the window is already open

- When sending a popup message, do not select the new message if the user is currently multiselecting
- When selecing the new message, scroll to top

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1672059 in widelands: "Selection is not cleared when new message arrives"
  https://bugs.launchpad.net/widelands/+bug/1672059

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1672059-table-message-arrival/+merge/344926
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1672059-table-message-arrival into lp:widelands.
=== modified file 'src/ui_basic/table.cc'
--- src/ui_basic/table.cc	2018-04-29 09:20:29 +0000
+++ src/ui_basic/table.cc	2018-05-02 07:09:35 +0000
@@ -530,6 +530,10 @@
 	scrollpos_ = i;
 }
 
+void Table<void*>::scroll_to_top() {
+	scrollbar_->set_scrollpos(0);
+}
+
 /**
  * Remove the table entry at the given (zero-based) index.
  */

=== modified file 'src/ui_basic/table.h'
--- src/ui_basic/table.h	2018-04-29 09:20:29 +0000
+++ src/ui_basic/table.h	2018-05-02 07:09:35 +0000
@@ -275,6 +275,8 @@
 	/// If entries == 0, the current entries are used.
 	void fit_height(uint32_t entries = 0);
 
+	void scroll_to_top();
+
 	void layout() override;
 
 	// Drawing and event handling

=== modified file 'src/wui/game_message_menu.cc'
--- src/wui/game_message_menu.cc	2018-04-07 16:59:00 +0000
+++ src/wui/game_message_menu.cc	2018-05-02 07:09:35 +0000
@@ -241,14 +241,23 @@
                                                       "images/wui/messages/message_archived.png"};
 
 void GameMessageMenu::show_new_message(MessageId const id, const Widelands::Message& message) {
+	// Do not disturb the user while multiselecting.
+	if (list->selections().size() > 1) {
+		return;
+	}
+
 	assert(iplayer().player().messages()[id] == &message);
 	assert(!list->find(id.value()));
 	Message::Status const status = message.status();
-	if ((mode == Archive) != (status == Message::Status::kArchived))
+	if ((mode == Archive) != (status == Message::Status::kArchived)) {
 		toggle_mode();
-	UI::Table<uintptr_t>::EntryRecord& te = list->add(id.value(), true);
+	}
+	UI::Table<uintptr_t>::EntryRecord& te = list->add(id.value());
 	update_record(te, message);
 	list->sort();
+	list->clear_selections();
+	list->select(0);
+	list->scroll_to_top();
 }
 
 void GameMessageMenu::think() {

=== modified file 'src/wui/game_message_menu.h'
--- src/wui/game_message_menu.h	2018-04-07 16:59:00 +0000
+++ src/wui/game_message_menu.h	2018-05-02 07:09:35 +0000
@@ -40,7 +40,8 @@
 
 	/// Shows a newly created message. Assumes that the message is not yet in
 	/// the list (the message was added to the queue after the last time think()
-	/// was executed.
+	/// was executed. Toggles to inbox and autoselects the new entry unless the user
+	/// is currently multiselecting messages.
 	void show_new_message(Widelands::MessageId, const Widelands::Message&);
 
 	enum Mode { Inbox, Archive };


Follow ups