Browse Source

Merge pull request #63 from viciious/warsow10_features

Warsow 1.0 features
Lloyd Weehuizen 13 years ago
parent
commit
b8fe552c45

+ 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
 	// 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.
 	// default to the rest of the children after the first row.
 	void RemoveChildren(int first_row_removed = 0, int num_rows_removed = -1);
 	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)
 	// Returns the number of rows under this row (children, grandchildren, etc)
 	int GetNumDescendants();
 	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)
 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)
 	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)
 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);
 	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)
 // Returns the number of rows under this row (children, grandchildren, etc)
 int ElementDataGridRow::GetNumDescendants()
 int ElementDataGridRow::GetNumDescendants()
 {
 {

+ 2 - 1
Source/Controls/WidgetTextInput.cpp

@@ -234,10 +234,11 @@ Core::Element* WidgetTextInput::GetElement()
 }
 }
 
 
 // Dispatches a change event to the widget's element.
 // Dispatches a change event to the widget's element.
-void WidgetTextInput::DispatchChangeEvent()
+void WidgetTextInput::DispatchChangeEvent(bool linebreak)
 {
 {
 	Rocket::Core::Dictionary parameters;
 	Rocket::Core::Dictionary parameters;
 	parameters.Set("value", GetElement()->GetAttribute< Rocket::Core::String >("value", ""));
 	parameters.Set("value", GetElement()->GetAttribute< Rocket::Core::String >("value", ""));
+	parameters.Set("linebreak", linebreak);
 	GetElement()->DispatchEvent("change", parameters);
 	GetElement()->DispatchEvent("change", parameters);
 }
 }
 
 

+ 1 - 1
Source/Controls/WidgetTextInput.h

@@ -109,7 +109,7 @@ protected:
 	Core::Element* GetElement();
 	Core::Element* GetElement();
 
 
 	/// Dispatches a change event to the widget's element.
 	/// Dispatches a change event to the widget's element.
-	void DispatchChangeEvent();
+	void DispatchChangeEvent(bool linebreak = false);
 
 
 private:
 private:
 	/// Moves the cursor along the current line.
 	/// Moves the cursor along the current line.

+ 1 - 1
Source/Controls/WidgetTextInputSingleLine.cpp

@@ -58,7 +58,7 @@ bool WidgetTextInputSingleLine::IsCharacterValid(Rocket::Core::word character)
 // Called when the user pressed enter.
 // Called when the user pressed enter.
 void WidgetTextInputSingleLine::LineBreak()
 void WidgetTextInputSingleLine::LineBreak()
 {
 {
-	DispatchChangeEvent();
+	DispatchChangeEvent(true);
 }
 }
 
 
 // Strips all \n and \r characters from the string.
 // Strips all \n and \r characters from the string.