Skip to content

Commit

Permalink
Merge pull request libRocket#63 from viciious/warsow10_features
Browse files Browse the repository at this point in the history
Warsow 1.0 features
  • Loading branch information
lloydw committed Aug 23, 2012
2 parents d21317a + e2ae51a commit b8fe552
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
2 changes: 2 additions & 0 deletions Include/Rocket/Controls/ElementDataGridRow.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ friend class ElementDataGrid;
// 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();

Expand Down
16 changes: 12 additions & 4 deletions Source/Controls/ElementDataGridRow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
{
Expand Down
3 changes: 2 additions & 1 deletion Source/Controls/WidgetTextInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,11 @@ Core::Element* WidgetTextInput::GetElement()
}

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

Expand Down
2 changes: 1 addition & 1 deletion Source/Controls/WidgetTextInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class WidgetTextInput : public Core::EventListener
Core::Element* GetElement();

/// Dispatches a change event to the widget's element.
void DispatchChangeEvent();
void DispatchChangeEvent(bool linebreak = false);

private:
/// Moves the cursor along the current line.
Expand Down
2 changes: 1 addition & 1 deletion Source/Controls/WidgetTextInputSingleLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ bool WidgetTextInputSingleLine::IsCharacterValid(Rocket::Core::word character)
// Called when the user pressed enter.
void WidgetTextInputSingleLine::LineBreak()
{
DispatchChangeEvent();
DispatchChangeEvent(true);
}

// Strips all \n and \r characters from the string.
Expand Down

0 comments on commit b8fe552

Please sign in to comment.