The size control now actually sets the size instead of the offset.

* SizeSlider::MaxPartitionSize() also now returns the size instead of the end
  offset.
* Renamed CreateParamsPanel::_UpdateTextControl() to _UpdateSizeTextControl().
* Removed code duplication, and instead just call _UpdateSizeTextControl()
  twice.
* Minor other cleanup.
This commit is contained in:
Axel Dörfler
2012-06-17 20:04:39 +02:00
parent 2ffea8e8a3
commit 7b2ba07326
3 changed files with 37 additions and 29 deletions
+26 -24
View File
@@ -1,15 +1,15 @@
/*
* Copyright 2008-20011 Haiku Inc. All rights reserved.
* Copyright 2008-2012 Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT license.
*
* Authors:
* Stephan Aßmus <[email protected]>
* Bryce Groff <[email protected]>
* Karsten Heimrich. <[email protected]>
* Bryce Groff <[email protected]>
* Karsten Heimrich <[email protected]>
*/
#include "CreateParamsPanel.h"
#include "Support.h"
#include <Button.h>
#include <Catalog.h>
@@ -28,6 +28,8 @@
#include <Partition.h>
#include <String.h>
#include "Support.h"
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "CreateParamsPanel"
@@ -36,7 +38,8 @@
class CreateParamsPanel::EscapeFilter : public BMessageFilter {
public:
EscapeFilter(CreateParamsPanel* target)
: BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE),
:
BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE),
fPanel(target)
{
}
@@ -85,7 +88,8 @@ enum {
CreateParamsPanel::CreateParamsPanel(BWindow* window, BPartition* partition,
off_t offset, off_t size)
: BWindow(BRect(300.0, 200.0, 600.0, 300.0), 0, B_MODAL_WINDOW_LOOK,
:
BWindow(BRect(300.0, 200.0, 600.0, 300.0), 0, B_MODAL_WINDOW_LOOK,
B_MODAL_SUBSET_WINDOW_FEEL,
B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS),
fEscapeFilter(new EscapeFilter(this)),
@@ -140,20 +144,18 @@ CreateParamsPanel::MessageReceived(BMessage* message)
fEditor->PartitionTypeChanged(type);
}
break;
case MSG_SIZE_SLIDER:
_UpdateTextControl();
_UpdateSizeTextControl();
break;
case MSG_SIZE_TEXTCONTROL:
{
BString sizeString;
sizeString = fSizeTextControl->Text();
int32 sizeInt = atoi(sizeString.String());
if (sizeInt >= 0 && sizeInt <= fSizeSlider->MaxPartitionSize())
fSizeSlider->SetValue(sizeInt);
int32 size = atoi(fSizeTextControl->Text());
if (size >= 0 && size <= fSizeSlider->MaxPartitionSize())
fSizeSlider->SetValue(size + fSizeSlider->Offset());
else
_UpdateTextControl();
_UpdateSizeTextControl();
break;
}
@@ -244,16 +246,15 @@ CreateParamsPanel::_CreateViewControls(BPartition* parent, off_t offset,
offset, offset + size);
fSizeSlider->SetPosition(1.0);
fSizeSlider->SetModificationMessage(new BMessage(MSG_SIZE_SLIDER));
BString sizeText;
sizeText << fSizeSlider->Value();
fSizeTextControl = new BTextControl("Size Control",
"", sizeText.String(), NULL);
fSizeTextControl = new BTextControl("Size Control", "", "", NULL);
for(int32 i = 0; i < 256; i++)
fSizeTextControl->TextView()->DisallowChar(i);
for(int32 i = '0'; i <= '9'; i++)
fSizeTextControl->TextView()->AllowChar(i);
fSizeTextControl->SetModificationMessage(new BMessage(MSG_SIZE_TEXTCONTROL));
_UpdateSizeTextControl();
fSizeTextControl->SetModificationMessage(
new BMessage(MSG_SIZE_TEXTCONTROL));
fNameTextControl = new BTextControl("Name Control",
B_TRANSLATE("Partition name:"), "", NULL);
@@ -295,7 +296,8 @@ CreateParamsPanel::_CreateViewControls(BPartition* parent, off_t offset,
)
);
status_t err = parent->GetParameterEditor(B_CREATE_PARAMETER_EDITOR, &fEditor);
status_t err = parent->GetParameterEditor(B_CREATE_PARAMETER_EDITOR,
&fEditor);
if (err == B_OK && fEditor != NULL)
AddChild(fEditor->View());
else
@@ -316,9 +318,9 @@ CreateParamsPanel::_CreateViewControls(BPartition* parent, off_t offset,
void
CreateParamsPanel::_UpdateTextControl()
CreateParamsPanel::_UpdateSizeTextControl()
{
BString sizeString;
sizeString << fSizeSlider->Value();
sizeString << fSizeSlider->Value() - fSizeSlider->Offset();
fSizeTextControl->SetText(sizeString.String());
}
+8 -3
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2008 Haiku Inc. All rights reserved.
* Copyright 2008-2012 Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT license.
*
* Authors:
@@ -15,13 +15,15 @@
#include <PartitionParameterEditor.h>
#include <Partition.h>
class BMenuField;
class BTextControl;
class SizeSlider;
class CreateParamsPanel : public BWindow {
public:
CreateParamsPanel(BWindow* window,
CreateParamsPanel(BWindow* window,
BPartition* parent, off_t offset,
off_t size);
virtual ~CreateParamsPanel();
@@ -38,9 +40,11 @@ private:
void _CreateViewControls(BPartition* parent,
off_t offset, off_t size);
void _UpdateTextControl();
void _UpdateSizeTextControl();
private:
class EscapeFilter;
EscapeFilter* fEscapeFilter;
sem_id fExitSemaphore;
BWindow* fWindow;
@@ -55,4 +59,5 @@ private:
BTextControl* fSizeTextControl;
};
#endif // CREATE_PARAMS_PANEL_H
+3 -2
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 Haiku Inc. All rights reserved.
* Copyright 2002-2012 Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT license.
*
* Authors:
@@ -9,6 +9,7 @@
* Bryce Groff <[email protected]>
*/
#include "Support.h"
#include <stdio.h>
@@ -100,7 +101,7 @@ SizeSlider::SizeSlider(const char* name, const char* label,
B_HORIZONTAL, B_TRIANGLE_THUMB),
fStartOffset(minValue),
fEndOffset(maxValue),
fMaxPartitionSize(maxValue)
fMaxPartitionSize(maxValue - minValue)
{
rgb_color fillColor = ui_color(B_CONTROL_HIGHLIGHT_COLOR);
UseFillColor(true, &fillColor);