Patch by Bryce Groff: Fixed the partition size slider. It had the partition

offset as minimum and the maximum partition size as maximum value. It's now
the partition start and end offset.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31459 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2009-07-08 12:35:24 +00:00
parent dec28f85e0
commit eff35b90f2
3 changed files with 33 additions and 16 deletions
+3 -2
View File
@@ -162,7 +162,8 @@ CreateParamsPanel::Go(off_t& offset, off_t& size, BString& type)
type << _type; type << _type;
} }
// Return the value back as bytes. // Return the value back as bytes.
size = (off_t)fSizeSlider->Value() * kMegaByte; size = (off_t)fSizeSlider->Size() * kMegaByte;
offset = (off_t)fSizeSlider->Offset() * kMegaByte;
} }
int32 value = fReturnValue; int32 value = fReturnValue;
@@ -196,7 +197,7 @@ CreateParamsPanel::_CreateViewControls(off_t offset, off_t size)
fTypeMenuField = new BMenuField("Partition Type", fTypePopUpMenu, NULL); fTypeMenuField = new BMenuField("Partition Type", fTypePopUpMenu, NULL);
fSizeSlider = new SizeSlider("Slider", "Partition Size", NULL, offset, fSizeSlider = new SizeSlider("Slider", "Partition Size", NULL, offset,
size); offset + size);
fSizeSlider->SetPosition(1.0); fSizeSlider->SetPosition(1.0);
fOKButton = new BButton("Create", new BMessage(MSG_OK)); fOKButton = new BButton("Create", new BMessage(MSG_OK));
+25 -11
View File
@@ -115,18 +115,16 @@ SpaceIDMap::SpaceIDFor(partition_id parentID, off_t spaceOffset)
SizeSlider::SizeSlider(const char* name, const char* label, SizeSlider::SizeSlider(const char* name, const char* label,
BMessage* message, int32 minValue, int32 maxValue) BMessage* message, int32 minValue, int32 maxValue)
: BSlider(name, label, message, minValue, maxValue, B_HORIZONTAL, : BSlider(name, label, message, minValue, maxValue,
B_TRIANGLE_THUMB), B_HORIZONTAL, B_TRIANGLE_THUMB),
fOffset(minValue), fStartOffset(minValue),
fSize(maxValue) fEndOffset(maxValue)
{ {
SetBarColor((rgb_color){ 0, 80, 255, 255 }); SetBarColor((rgb_color){ 0, 80, 255, 255 });
BString offset, size; BString startOffset, endOffset;
offset << fOffset; startOffset << "Offset: " << fStartOffset << " MB";
offset << " MB"; endOffset << "End: " << fEndOffset << " MB";
size << fSize; SetLimitLabels(startOffset.String(), endOffset.String());
size << " MB";
SetLimitLabels(offset.String(), size.String());
} }
@@ -139,8 +137,24 @@ const char*
SizeSlider::UpdateText() const SizeSlider::UpdateText() const
{ {
fStatusLabel.Truncate(0); fStatusLabel.Truncate(0);
fStatusLabel << Value(); fStatusLabel << Value() - fStartOffset;
fStatusLabel << " MB"; fStatusLabel << " MB";
return fStatusLabel.String(); return fStatusLabel.String();
} }
int32
SizeSlider::Size()
{
return Value() - fStartOffset;
}
int32
SizeSlider::Offset()
{
// TODO: This should be the changed offset once a double
// headed slider is implemented.
return fStartOffset;
}
+5 -3
View File
@@ -28,7 +28,7 @@ enum {
}; };
static const uint32 kMegaByte = 1048576; static const uint32 kMegaByte = 0x100000;
class SpaceIDMap : public HashMap<HashString, partition_id> { class SpaceIDMap : public HashMap<HashString, partition_id> {
public: public:
@@ -50,10 +50,12 @@ public:
virtual ~SizeSlider(); virtual ~SizeSlider();
virtual const char* UpdateText() const; virtual const char* UpdateText() const;
int32 Size();
int32 Offset();
private: private:
off_t fOffset; off_t fStartOffset;
off_t fSize; off_t fEndOffset;
mutable BString fStatusLabel; mutable BString fStatusLabel;
}; };