Browse Source

Feature: add "rowchange" event

Datagrid now dispatches "rowchange" event upon the NotifyRowChange call. Event parameters are the same as for "rowadd" and "rowremove" events.
Victor Luchitz 13 years ago
parent
commit
cdb3cb0a36

+ 2 - 0
Include/Rocket/Controls/ElementDataGridRow.h

@@ -121,6 +121,8 @@ private:
 	// If the num_rows_removed parameter is left as the -1 default, it'll
 	// default to the rest of the children after the first row.
 	void RemoveChildren(int first_row_removed = 0, int num_rows_removed = -1);
+	// Marks children as dirty and dispatches the event.
+	void ChangeChildren(int first_row_changed = 0, int num_rows_changed = -1);
 	// Returns the number of rows under this row (children, grandchildren, etc)
 	int GetNumDescendants();
 

+ 12 - 4
Source/Controls/ElementDataGridRow.cpp

@@ -268,10 +268,7 @@ void ElementDataGridRow::OnRowRemove(DataSource* _data_source, const Rocket::Cor
 void ElementDataGridRow::OnRowChange(DataSource* _data_source, const Rocket::Core::String& _data_table, int first_row_changed, int num_rows_changed)
 {
 	if (_data_source == data_source && _data_table == data_table)
-	{
-		for (int i = first_row_changed; i < first_row_changed + num_rows_changed; i++)
-			children[i]->DirtyCells();
-	}
+		ChangeChildren(first_row_changed, num_rows_changed);
 }
 
 void ElementDataGridRow::OnRowChange(DataSource* _data_source, const Rocket::Core::String& _data_table)
@@ -428,6 +425,17 @@ void ElementDataGridRow::RemoveChildren(int first_row_removed, int num_rows_remo
 	parent_grid->DispatchEvent("rowremove", parameters);
 }
 
+void ElementDataGridRow::ChangeChildren(int first_row_changed, int num_rows_changed)
+{
+	for (int i = first_row_changed; i < first_row_changed + num_rows_changed; i++)
+		children[i]->DirtyCells();
+
+	Rocket::Core::Dictionary parameters;
+	parameters.Set("first_row_changed", GetChildTableRelativeIndex(first_row_changed));
+	parameters.Set("num_rows_changed", num_rows_changed);
+	parent_grid->DispatchEvent("rowchange", parameters);
+}
+
 // Returns the number of rows under this row (children, grandchildren, etc)
 int ElementDataGridRow::GetNumDescendants()
 {