Skip to content

Commit

Permalink
Debugger: Flesh out option-based value editors.
Browse files Browse the repository at this point in the history
TableCellOptionPopUpEditor:
- Add virtual hook for retrieving the final selected value. Implement
  accordingly in Bool and Enumeration editor subclasses.
- Implement calling the edit completion hook upon value changes.
  • Loading branch information
anevilyak committed Jul 24, 2015
1 parent 1f8d1f6 commit 1f3db0d
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/apps/debugger/user_interface/gui/value/TableCellBoolEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,18 @@ TableCellBoolEditor::ConfigureOptions()

return SelectOptionFor(initialValue->GetValue());
}


status_t
TableCellBoolEditor::GetSelectedValue(::Value*& _value) const
{
const char* name = NULL;
int32 selectedValue = 0;
SelectedOption(&name, &selectedValue);
BoolValue* value = new(std::nothrow) BoolValue((bool)selectedValue);
if (value == NULL)
return B_NO_MEMORY;

_value = value;
return B_OK;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class TableCellBoolEditor : public TableCellOptionPopUpEditor {

virtual status_t ConfigureOptions();

protected:
virtual status_t GetSelectedValue(::Value*& _value) const;
};

#endif // TABLE_CELL_BOOL_EDITOR_H
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,23 @@ TableCellEnumerationEditor::ConfigureOptions()

return SelectOptionFor(integerValue.ToInt32());
}


status_t
TableCellEnumerationEditor::GetSelectedValue(::Value*& _value) const
{
EnumerationValue* initialValue = dynamic_cast<EnumerationValue*>(
InitialValue());
EnumerationType* type = initialValue->GetType();
const char* name = NULL;
int32 selectedValue = 0;
SelectedOption(&name, &selectedValue);

EnumerationValue* value = new(std::nothrow) EnumerationValue(type,
BVariant(selectedValue));
if (value == NULL)
return B_NO_MEMORY;

_value = value;
return B_OK;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class TableCellEnumerationEditor : public TableCellOptionPopUpEditor {

virtual status_t ConfigureOptions();

protected:
virtual status_t GetSelectedValue(::Value*& _value) const;
};

#endif // TABLE_CELL_ENUMERATION_EDITOR_H
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,13 @@ TableCellOptionPopUpEditor::MessageReceived(BMessage* message)
switch (message->what) {
case MSG_SELECTED_OPTION_CHANGED:
{
// TODO: implement
::Value* value = NULL;
if (GetSelectedValue(value) == B_OK) {
BReference< ::Value> valueReference(value, true);
NotifyEditCompleted(value);
} else
NotifyEditCancelled();

break;
}
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class TableCellOptionPopUpEditor : public TableCellFormattedValueEditor,
virtual status_t ConfigureOptions() = 0;

protected:
virtual status_t GetSelectedValue(::Value*& _value) const = 0;

virtual void AttachedToWindow();
virtual void MessageReceived(BMessage* message);
};
Expand Down

0 comments on commit 1f3db0d

Please sign in to comment.