diff --git a/src/apps/drivesetup/CreateParamsPanel.cpp b/src/apps/drivesetup/CreateParamsPanel.cpp index 0ac94be003..ce9b8f0d41 100644 --- a/src/apps/drivesetup/CreateParamsPanel.cpp +++ b/src/apps/drivesetup/CreateParamsPanel.cpp @@ -162,7 +162,8 @@ CreateParamsPanel::Go(off_t& offset, off_t& size, BString& type) type << _type; } // 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; @@ -196,7 +197,7 @@ CreateParamsPanel::_CreateViewControls(off_t offset, off_t size) fTypeMenuField = new BMenuField("Partition Type", fTypePopUpMenu, NULL); fSizeSlider = new SizeSlider("Slider", "Partition Size", NULL, offset, - size); + offset + size); fSizeSlider->SetPosition(1.0); fOKButton = new BButton("Create", new BMessage(MSG_OK)); diff --git a/src/apps/drivesetup/Support.cpp b/src/apps/drivesetup/Support.cpp index 87357a9712..cbe7d6185e 100644 --- a/src/apps/drivesetup/Support.cpp +++ b/src/apps/drivesetup/Support.cpp @@ -115,18 +115,16 @@ SpaceIDMap::SpaceIDFor(partition_id parentID, off_t spaceOffset) SizeSlider::SizeSlider(const char* name, const char* label, BMessage* message, int32 minValue, int32 maxValue) - : BSlider(name, label, message, minValue, maxValue, B_HORIZONTAL, - B_TRIANGLE_THUMB), - fOffset(minValue), - fSize(maxValue) + : BSlider(name, label, message, minValue, maxValue, + B_HORIZONTAL, B_TRIANGLE_THUMB), + fStartOffset(minValue), + fEndOffset(maxValue) { SetBarColor((rgb_color){ 0, 80, 255, 255 }); - BString offset, size; - offset << fOffset; - offset << " MB"; - size << fSize; - size << " MB"; - SetLimitLabels(offset.String(), size.String()); + BString startOffset, endOffset; + startOffset << "Offset: " << fStartOffset << " MB"; + endOffset << "End: " << fEndOffset << " MB"; + SetLimitLabels(startOffset.String(), endOffset.String()); } @@ -139,8 +137,24 @@ const char* SizeSlider::UpdateText() const { fStatusLabel.Truncate(0); - fStatusLabel << Value(); + fStatusLabel << Value() - fStartOffset; fStatusLabel << " MB"; 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; +} diff --git a/src/apps/drivesetup/Support.h b/src/apps/drivesetup/Support.h index adf7287d9f..18579d230c 100644 --- a/src/apps/drivesetup/Support.h +++ b/src/apps/drivesetup/Support.h @@ -28,7 +28,7 @@ enum { }; -static const uint32 kMegaByte = 1048576; +static const uint32 kMegaByte = 0x100000; class SpaceIDMap : public HashMap { public: @@ -50,10 +50,12 @@ public: virtual ~SizeSlider(); virtual const char* UpdateText() const; + int32 Size(); + int32 Offset(); private: - off_t fOffset; - off_t fSize; + off_t fStartOffset; + off_t fEndOffset; mutable BString fStatusLabel; };