diff --git a/include/DrawingAreaVisualDisk.h b/include/DrawingAreaVisualDisk.h index cdc9e19d..a96bbed9 100644 --- a/include/DrawingAreaVisualDisk.h +++ b/include/DrawingAreaVisualDisk.h @@ -73,9 +73,6 @@ private: struct visual_partition { double fraction ; //Partition size as a fraction of containing disk or extended partition size - double fraction_used ; //Used space as a fraction of partition size - double fraction_unallocated ; //Unallocated space as a fraction of partition size - int x_start, length ; int y_start, height ; int x_used_start, used_length ; @@ -94,7 +91,7 @@ private: visual_partition() { - fraction = fraction_used = fraction_unallocated = 0.0 ; + fraction = 0.0 ; x_start = length = y_start = height = x_used_start = used_length = diff --git a/src/DrawingAreaVisualDisk.cc b/src/DrawingAreaVisualDisk.cc index 75bd854d..81d2a040 100644 --- a/src/DrawingAreaVisualDisk.cc +++ b/src/DrawingAreaVisualDisk.cc @@ -97,34 +97,6 @@ void DrawingAreaVisualDisk::set_static_data( const std::vector & part Sector partition_length = partitions[ t ] .get_sector_length() ; visual_partitions .back() .fraction = partition_length / static_cast( length ) ; - if ( partitions[ t ] .type == GParted::TYPE_UNALLOCATED || partitions[ t ] .type == GParted::TYPE_EXTENDED ) - { - //Don't calculate or draw partition used, unused or unallocated rectangles - // to show usage. Only partition color rectangle will be drawn. - visual_partitions .back() .fraction_unallocated = -1.0 ; - visual_partitions .back() .fraction_used = -1.0 ; - } - else - { - //Use sum_sectors as the denominator to calculate fraction_used and - // fraction_unallocated in case it doesn't equal partition_length. - Sector used = partitions[ t ] .get_sectors_used() ; - Sector unused = partitions[ t ] .get_sectors_unused() ; - Sector unallocated = partitions[ t ] .get_sectors_unallocated() ; - Sector sum_sectors = used + unused + unallocated ; - if ( unallocated > 0 ) - visual_partitions .back() .fraction_unallocated = - unallocated / static_cast( sum_sectors ) ; - else - visual_partitions .back() .fraction_unallocated = 0.0 ; - - //Calculate fraction used from free space so any hidden overhead is counted as used - if ( unused >= 0 ) - visual_partitions .back() .fraction_used = - 1.0 - visual_partitions .back() .fraction_unallocated - - unused / static_cast( sum_sectors ) ; - } - visual_partitions .back() .color = partitions[ t ] .color; get_colormap() ->alloc_color( visual_partitions .back() .color ); @@ -181,17 +153,28 @@ void DrawingAreaVisualDisk::calc_usage( std::vector & visual_p { for ( unsigned int t = 0 ; t < visual_partitions .size() ; t++ ) { - if ( visual_partitions[ t ] .fraction_used >= 0.0 ) - { + if ( visual_partitions[ t ] .partition .type != GParted::TYPE_UNALLOCATED && + visual_partitions[ t ] .partition .type != GParted::TYPE_EXTENDED ) + { + if ( visual_partitions[ t ] .partition .sector_usage_known() ) + { + Partition::calc_usage_triple( + visual_partitions[ t ] .partition .get_sectors_used(), + visual_partitions[ t ] .partition .get_sectors_unused(), + visual_partitions[ t ] .partition .get_sectors_unallocated(), + visual_partitions[ t ] .length - BORDER *2, + visual_partitions[ t ] .used_length, + visual_partitions[ t ] .unused_length, + visual_partitions[ t ] .unallocated_length ) ; + } + else + { + //Specifically show unknown figures as unused + visual_partitions[ t ] .used_length = 0 ; + visual_partitions[ t ] .unused_length = visual_partitions[ t ] .length - BORDER *2 ; + visual_partitions[ t ] .unallocated_length = 0 ; + } - Partition::calc_usage_triple( visual_partitions[ t ] .fraction_used, - 1.0 - visual_partitions[ t ] .fraction_used - - visual_partitions[ t ] .fraction_unallocated, - visual_partitions[ t ] .fraction_unallocated, - visual_partitions[ t ] .length - BORDER *2, - visual_partitions[ t ] .used_length, - visual_partitions[ t ] .unused_length, - visual_partitions[ t ] .unallocated_length ) ; //used visual_partitions[ t ] .x_used_start = visual_partitions[ t ] .x_start + BORDER ;