Debugger: Cleanups for BreakConditionConfigWindow.
- When switching between breaking on all images vs a custom list, rather than enabling/disabling the controls individually, which wasn't necessarily obvious from a visibility standpoint, simply show/hide the entire group of controls as needed. - Update state of add/remove buttons properly. - Sanitize input for leading/trailing whitespace.
This commit is contained in:
@@ -30,7 +30,8 @@ enum {
|
|||||||
MSG_SET_STOP_FOR_CUSTOM_IMAGES = 'sfci',
|
MSG_SET_STOP_FOR_CUSTOM_IMAGES = 'sfci',
|
||||||
MSG_IMAGE_NAME_SELECTION_CHANGED = 'insc',
|
MSG_IMAGE_NAME_SELECTION_CHANGED = 'insc',
|
||||||
MSG_ADD_IMAGE_NAME = 'anin',
|
MSG_ADD_IMAGE_NAME = 'anin',
|
||||||
MSG_REMOVE_IMAGE_NAME = 'arin'
|
MSG_REMOVE_IMAGE_NAME = 'arin',
|
||||||
|
MSG_IMAGE_NAME_INPUT_CHANGED = 'inic'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -43,13 +44,6 @@ static int SortStringItems(const void* a, const void* b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool UpdateItemState(BListItem* item, void* enabled)
|
|
||||||
{
|
|
||||||
item->SetEnabled((bool)enabled);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BreakConditionConfigWindow::BreakConditionConfigWindow(::Team* team,
|
BreakConditionConfigWindow::BreakConditionConfigWindow(::Team* team,
|
||||||
UserInterfaceListener* listener, BHandler* target)
|
UserInterfaceListener* listener, BHandler* target)
|
||||||
:
|
:
|
||||||
@@ -57,6 +51,8 @@ BreakConditionConfigWindow::BreakConditionConfigWindow(::Team* team,
|
|||||||
B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE),
|
B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE),
|
||||||
fTeam(team),
|
fTeam(team),
|
||||||
fListener(listener),
|
fListener(listener),
|
||||||
|
fExceptionSettingsBox(NULL),
|
||||||
|
fImageSettingsBox(NULL),
|
||||||
fExceptionThrown(NULL),
|
fExceptionThrown(NULL),
|
||||||
fExceptionCaught(NULL),
|
fExceptionCaught(NULL),
|
||||||
fStopOnImageLoad(NULL),
|
fStopOnImageLoad(NULL),
|
||||||
@@ -65,6 +61,8 @@ BreakConditionConfigWindow::BreakConditionConfigWindow(::Team* team,
|
|||||||
fStopImageNameInput(NULL),
|
fStopImageNameInput(NULL),
|
||||||
fAddImageNameButton(NULL),
|
fAddImageNameButton(NULL),
|
||||||
fRemoveImageNameButton(NULL),
|
fRemoveImageNameButton(NULL),
|
||||||
|
fCustomImageGroup(NULL),
|
||||||
|
fStopOnLoadEnabled(false),
|
||||||
fUseCustomImages(false),
|
fUseCustomImages(false),
|
||||||
fCloseButton(NULL),
|
fCloseButton(NULL),
|
||||||
fTarget(target)
|
fTarget(target)
|
||||||
@@ -116,19 +114,17 @@ BreakConditionConfigWindow::MessageReceived(BMessage* message)
|
|||||||
|
|
||||||
case MSG_SET_STOP_FOR_ALL_IMAGES:
|
case MSG_SET_STOP_FOR_ALL_IMAGES:
|
||||||
{
|
{
|
||||||
fUseCustomImages = false;
|
|
||||||
fListener->SetStopOnImageLoadRequested(
|
fListener->SetStopOnImageLoadRequested(
|
||||||
fStopOnImageLoad->Value() == B_CONTROL_ON,
|
fStopOnImageLoad->Value() == B_CONTROL_ON,
|
||||||
fUseCustomImages);
|
false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case MSG_SET_STOP_FOR_CUSTOM_IMAGES:
|
case MSG_SET_STOP_FOR_CUSTOM_IMAGES:
|
||||||
{
|
{
|
||||||
fUseCustomImages = true;
|
|
||||||
fListener->SetStopOnImageLoadRequested(
|
fListener->SetStopOnImageLoadRequested(
|
||||||
fStopOnImageLoad->Value() == B_CONTROL_ON,
|
fStopOnImageLoad->Value() == B_CONTROL_ON,
|
||||||
fUseCustomImages);
|
true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,6 +138,14 @@ BreakConditionConfigWindow::MessageReceived(BMessage* message)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case MSG_IMAGE_NAME_INPUT_CHANGED:
|
||||||
|
{
|
||||||
|
BString imageName(fStopImageNameInput->Text());
|
||||||
|
imageName.Trim();
|
||||||
|
fAddImageNameButton->SetEnabled(!imageName.IsEmpty());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case MSG_STOP_ON_IMAGE_LOAD:
|
case MSG_STOP_ON_IMAGE_LOAD:
|
||||||
{
|
{
|
||||||
fListener->SetStopOnImageLoadRequested(
|
fListener->SetStopOnImageLoadRequested(
|
||||||
@@ -152,13 +156,14 @@ BreakConditionConfigWindow::MessageReceived(BMessage* message)
|
|||||||
|
|
||||||
case MSG_STOP_IMAGE_SETTINGS_CHANGED:
|
case MSG_STOP_IMAGE_SETTINGS_CHANGED:
|
||||||
{
|
{
|
||||||
_UpdateStopImageButtons();
|
_UpdateStopImageState();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case MSG_ADD_IMAGE_NAME:
|
case MSG_ADD_IMAGE_NAME:
|
||||||
{
|
{
|
||||||
BString imageName(fStopImageNameInput->Text());
|
BString imageName(fStopImageNameInput->Text());
|
||||||
|
imageName.Trim();
|
||||||
AutoLocker< ::Team> teamLocker(fTeam);
|
AutoLocker< ::Team> teamLocker(fTeam);
|
||||||
if (fTeam->StopImageNames().HasString(imageName))
|
if (fTeam->StopImageNames().HasString(imageName))
|
||||||
break;
|
break;
|
||||||
@@ -268,18 +273,16 @@ BreakConditionConfigWindow::StopOnImageLoadNameRemoved(
|
|||||||
void
|
void
|
||||||
BreakConditionConfigWindow::_Init()
|
BreakConditionConfigWindow::_Init()
|
||||||
{
|
{
|
||||||
BBox* exceptionSettingsBox = new BBox("exceptionBox");
|
fExceptionSettingsBox = new BBox("exceptionBox");
|
||||||
exceptionSettingsBox->SetLabel("Exceptions");
|
fExceptionSettingsBox->SetLabel("Exceptions");
|
||||||
exceptionSettingsBox->AddChild(BLayoutBuilder::Group<>()
|
fExceptionSettingsBox->AddChild(BLayoutBuilder::Group<>(B_VERTICAL,
|
||||||
.AddGroup(B_VERTICAL)
|
B_USE_DEFAULT_SPACING)
|
||||||
.SetInsets(B_USE_DEFAULT_SPACING)
|
.Add(fExceptionThrown = new BCheckBox("exceptionThrown",
|
||||||
.Add(fExceptionThrown = new BCheckBox("exceptionThrown",
|
"Stop when an exception is thrown",
|
||||||
"Stop when an exception is thrown",
|
new BMessage(MSG_STOP_ON_THROWN_EXCEPTION_CHANGED)))
|
||||||
new BMessage(MSG_STOP_ON_THROWN_EXCEPTION_CHANGED)))
|
.Add(fExceptionCaught = new BCheckBox("exceptionCaught",
|
||||||
.Add(fExceptionCaught = new BCheckBox("exceptionCaught",
|
"Stop when an exception is caught",
|
||||||
"Stop when an exception is caught",
|
new BMessage(MSG_STOP_ON_CAUGHT_EXCEPTION_CHANGED)))
|
||||||
new BMessage(MSG_STOP_ON_CAUGHT_EXCEPTION_CHANGED)))
|
|
||||||
.End()
|
|
||||||
.View());
|
.View());
|
||||||
|
|
||||||
fExceptionThrown->SetTarget(this);
|
fExceptionThrown->SetTarget(this);
|
||||||
@@ -289,8 +292,8 @@ BreakConditionConfigWindow::_Init()
|
|||||||
fExceptionCaught->SetEnabled(false);
|
fExceptionCaught->SetEnabled(false);
|
||||||
|
|
||||||
|
|
||||||
BBox* imageSettingsBox = new BBox("imageBox");
|
fImageSettingsBox = new BBox("imageBox");
|
||||||
imageSettingsBox->SetLabel("Images");
|
fImageSettingsBox->SetLabel("Images");
|
||||||
BMenu* stopImageMenu = new BMenu("stopImageTypesMenu");
|
BMenu* stopImageMenu = new BMenu("stopImageTypesMenu");
|
||||||
|
|
||||||
stopImageMenu->AddItem(new BMenuItem("All",
|
stopImageMenu->AddItem(new BMenuItem("All",
|
||||||
@@ -303,26 +306,28 @@ BreakConditionConfigWindow::_Init()
|
|||||||
fStopImageNames->SetSelectionMessage(
|
fStopImageNames->SetSelectionMessage(
|
||||||
new BMessage(MSG_IMAGE_NAME_SELECTION_CHANGED));
|
new BMessage(MSG_IMAGE_NAME_SELECTION_CHANGED));
|
||||||
|
|
||||||
imageSettingsBox->AddChild(BLayoutBuilder::Group<>()
|
fCustomImageGroup = new BGroupView();
|
||||||
.AddGroup(B_VERTICAL)
|
BLayoutBuilder::Group<>(fCustomImageGroup, B_VERTICAL, 0.0)
|
||||||
.SetInsets(B_USE_DEFAULT_SPACING)
|
.Add(new BScrollView("stopImageScroll", fStopImageNames,
|
||||||
.Add(fStopOnImageLoad = new BCheckBox("stopOnImage",
|
0, false, true))
|
||||||
"Stop when an image is loaded",
|
.Add(fStopImageNameInput = new BTextControl("stopImageName",
|
||||||
new BMessage(MSG_STOP_ON_IMAGE_LOAD)))
|
"Image:", NULL, NULL))
|
||||||
.Add(fStopImageConstraints = new BMenuField(
|
.AddGroup(B_HORIZONTAL)
|
||||||
"stopTypes", "Types:", stopImageMenu))
|
.AddGlue()
|
||||||
.Add(new BScrollView("stopImageScroll", fStopImageNames,
|
.Add(fAddImageNameButton = new BButton("Add",
|
||||||
0, false, true))
|
new BMessage(MSG_ADD_IMAGE_NAME)))
|
||||||
.Add(fStopImageNameInput = new BTextControl("stopImageName",
|
.Add(fRemoveImageNameButton = new BButton("Remove",
|
||||||
"Image:", NULL, NULL))
|
new BMessage(MSG_REMOVE_IMAGE_NAME)))
|
||||||
.AddGroup(B_HORIZONTAL)
|
.End();
|
||||||
.AddGlue()
|
|
||||||
.Add(fAddImageNameButton = new BButton("Add",
|
fImageSettingsBox->AddChild(BLayoutBuilder::Group<>(B_VERTICAL)
|
||||||
new BMessage(MSG_ADD_IMAGE_NAME)))
|
.SetInsets(B_USE_DEFAULT_SPACING)
|
||||||
.Add(fRemoveImageNameButton = new BButton("Remove",
|
.Add(fStopOnImageLoad = new BCheckBox("stopOnImage",
|
||||||
new BMessage(MSG_REMOVE_IMAGE_NAME)))
|
"Stop when an image is loaded",
|
||||||
.End()
|
new BMessage(MSG_STOP_ON_IMAGE_LOAD)))
|
||||||
.End()
|
.Add(fStopImageConstraints = new BMenuField(
|
||||||
|
"stopTypes", "Types:", stopImageMenu))
|
||||||
|
.Add(fCustomImageGroup)
|
||||||
.View());
|
.View());
|
||||||
|
|
||||||
font_height fontHeight;
|
font_height fontHeight;
|
||||||
@@ -333,8 +338,8 @@ BreakConditionConfigWindow::_Init()
|
|||||||
|
|
||||||
BLayoutBuilder::Group<>(this, B_VERTICAL)
|
BLayoutBuilder::Group<>(this, B_VERTICAL)
|
||||||
.SetInsets(B_USE_DEFAULT_SPACING)
|
.SetInsets(B_USE_DEFAULT_SPACING)
|
||||||
.Add(exceptionSettingsBox)
|
.Add(fExceptionSettingsBox)
|
||||||
.Add(imageSettingsBox)
|
.Add(fImageSettingsBox)
|
||||||
.AddGroup(B_HORIZONTAL)
|
.AddGroup(B_HORIZONTAL)
|
||||||
.AddGlue()
|
.AddGlue()
|
||||||
.Add(fCloseButton = new BButton("Close", new BMessage(
|
.Add(fCloseButton = new BButton("Close", new BMessage(
|
||||||
@@ -343,8 +348,14 @@ BreakConditionConfigWindow::_Init()
|
|||||||
|
|
||||||
|
|
||||||
fCloseButton->SetTarget(this);
|
fCloseButton->SetTarget(this);
|
||||||
|
fAddImageNameButton->SetEnabled(false);
|
||||||
|
fRemoveImageNameButton->SetEnabled(false);
|
||||||
stopImageMenu->SetTargetForItems(this);
|
stopImageMenu->SetTargetForItems(this);
|
||||||
stopImageMenu->SetLabelFromMarked(true);
|
stopImageMenu->SetLabelFromMarked(true);
|
||||||
|
fStopImageNameInput->SetModificationMessage(
|
||||||
|
new BMessage(MSG_IMAGE_NAME_INPUT_CHANGED));
|
||||||
|
|
||||||
|
fCustomImageGroup->Hide();
|
||||||
|
|
||||||
AutoLocker< ::Team> teamLocker(fTeam);
|
AutoLocker< ::Team> teamLocker(fTeam);
|
||||||
_UpdateStopImageState();
|
_UpdateStopImageState();
|
||||||
@@ -418,9 +429,15 @@ BreakConditionConfigWindow::_UpdateExceptionState()
|
|||||||
void
|
void
|
||||||
BreakConditionConfigWindow::_UpdateStopImageState()
|
BreakConditionConfigWindow::_UpdateStopImageState()
|
||||||
{
|
{
|
||||||
|
bool previousStop = fStopOnLoadEnabled;
|
||||||
|
bool previousCustomImages = fUseCustomImages;
|
||||||
|
|
||||||
|
fStopOnLoadEnabled = fTeam->StopOnImageLoad();
|
||||||
|
fStopOnImageLoad->SetValue(
|
||||||
|
fStopOnLoadEnabled ? B_CONTROL_ON : B_CONTROL_OFF);
|
||||||
fUseCustomImages = fTeam->StopImageNameListEnabled();
|
fUseCustomImages = fTeam->StopImageNameListEnabled();
|
||||||
fStopImageConstraints->Menu()->ItemAt(0)->SetMarked(!fUseCustomImages);
|
fStopImageConstraints->Menu()
|
||||||
fStopImageConstraints->Menu()->ItemAt(1)->SetMarked(fUseCustomImages);
|
->ItemAt(fUseCustomImages ? 1 : 0)->SetMarked(true);
|
||||||
|
|
||||||
fStopImageNames->MakeEmpty();
|
fStopImageNames->MakeEmpty();
|
||||||
const BStringList& imageNames = fTeam->StopImageNames();
|
const BStringList& imageNames = fTeam->StopImageNames();
|
||||||
@@ -436,20 +453,17 @@ BreakConditionConfigWindow::_UpdateStopImageState()
|
|||||||
itemDeleter.Detach();
|
itemDeleter.Detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
_UpdateStopImageButtons();
|
_UpdateStopImageButtons(previousStop, previousCustomImages);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BreakConditionConfigWindow::_UpdateStopImageButtons()
|
BreakConditionConfigWindow::_UpdateStopImageButtons(bool previousStop,
|
||||||
|
bool previousCustomImages)
|
||||||
{
|
{
|
||||||
bool stopOnImageLoad = fTeam->StopOnImageLoad();
|
fStopImageConstraints->SetEnabled(fStopOnLoadEnabled);
|
||||||
fStopOnImageLoad->SetValue(stopOnImageLoad ? B_CONTROL_ON : B_CONTROL_OFF);
|
if (!previousCustomImages && fUseCustomImages)
|
||||||
bool enabled = stopOnImageLoad && fUseCustomImages;
|
fCustomImageGroup->Show();
|
||||||
fStopImageConstraints->SetEnabled(stopOnImageLoad);
|
else if (previousCustomImages && !fUseCustomImages)
|
||||||
fAddImageNameButton->SetEnabled(enabled);
|
fCustomImageGroup->Hide();
|
||||||
fRemoveImageNameButton->SetEnabled(enabled
|
|
||||||
&& fStopImageNames->CurrentSelection() >= 0);
|
|
||||||
fStopImageNames->DoForEach(UpdateItemState, (void*)enabled);
|
|
||||||
fStopImageNameInput->TextView()->MakeEditable(enabled);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#include "types/Types.h"
|
#include "types/Types.h"
|
||||||
|
|
||||||
|
|
||||||
|
class BBox;
|
||||||
class BButton;
|
class BButton;
|
||||||
class BCheckBox;
|
class BCheckBox;
|
||||||
class BListView;
|
class BListView;
|
||||||
@@ -56,7 +57,8 @@ private:
|
|||||||
|
|
||||||
void _UpdateExceptionState();
|
void _UpdateExceptionState();
|
||||||
void _UpdateStopImageState();
|
void _UpdateStopImageState();
|
||||||
void _UpdateStopImageButtons();
|
void _UpdateStopImageButtons(bool previousStop,
|
||||||
|
bool previousCustomImages);
|
||||||
// must be called with team lock held
|
// must be called with team lock held
|
||||||
|
|
||||||
|
|
||||||
@@ -64,6 +66,8 @@ private:
|
|||||||
private:
|
private:
|
||||||
::Team* fTeam;
|
::Team* fTeam;
|
||||||
UserInterfaceListener* fListener;
|
UserInterfaceListener* fListener;
|
||||||
|
BBox* fExceptionSettingsBox;
|
||||||
|
BBox* fImageSettingsBox;
|
||||||
BCheckBox* fExceptionThrown;
|
BCheckBox* fExceptionThrown;
|
||||||
BCheckBox* fExceptionCaught;
|
BCheckBox* fExceptionCaught;
|
||||||
BCheckBox* fStopOnImageLoad;
|
BCheckBox* fStopOnImageLoad;
|
||||||
@@ -72,6 +76,8 @@ private:
|
|||||||
BTextControl* fStopImageNameInput;
|
BTextControl* fStopImageNameInput;
|
||||||
BButton* fAddImageNameButton;
|
BButton* fAddImageNameButton;
|
||||||
BButton* fRemoveImageNameButton;
|
BButton* fRemoveImageNameButton;
|
||||||
|
BView* fCustomImageGroup;
|
||||||
|
bool fStopOnLoadEnabled;
|
||||||
bool fUseCustomImages;
|
bool fUseCustomImages;
|
||||||
BButton* fCloseButton;
|
BButton* fCloseButton;
|
||||||
BHandler* fTarget;
|
BHandler* fTarget;
|
||||||
|
|||||||
Reference in New Issue
Block a user