Limit graphic movement according to required boot record space
Also respect minimum size for extended partition in graphical representation. This change is part of adding the option to align to MiB (#617409).
This commit is contained in:
parent
24d96114ca
commit
95c9577d8f
|
@ -1,4 +1,5 @@
|
||||||
/* Copyright (C) 2004 Bart
|
/* Copyright (C) 2004 Bart
|
||||||
|
* Copyright (C) 2010 Curtis Gedak
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -36,6 +37,7 @@ public:
|
||||||
void set_rgb_partition_color( const Gdk::Color & color ) ;
|
void set_rgb_partition_color( const Gdk::Color & color ) ;
|
||||||
void override_default_rgb_unused_color( const Gdk::Color & color ) ;
|
void override_default_rgb_unused_color( const Gdk::Color & color ) ;
|
||||||
|
|
||||||
|
void set_x_min_space_before( int x_min_space_before ) ;
|
||||||
void set_x_start( int x_start ) ;
|
void set_x_start( int x_start ) ;
|
||||||
void set_x_end( int x_end ) ;
|
void set_x_end( int x_end ) ;
|
||||||
void set_used( int used );
|
void set_used( int used );
|
||||||
|
@ -54,6 +56,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int BORDER, GRIPPER ;
|
int BORDER, GRIPPER ;
|
||||||
|
int X_MIN_SPACE_BEFORE ;
|
||||||
int X_START, USED, UNUSED, X_END, X_START_MOVE, MIN_SIZE, MAX_SIZE;
|
int X_START, USED, UNUSED, X_END, X_START_MOVE, MIN_SIZE, MAX_SIZE;
|
||||||
bool GRIP_LEFT, GRIP_RIGHT, GRIP_MOVE ;
|
bool GRIP_LEFT, GRIP_RIGHT, GRIP_MOVE ;
|
||||||
|
|
||||||
|
|
|
@ -52,8 +52,9 @@ void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, cons
|
||||||
long COPIED_LENGTH_MB = Utils::round( Utils::sector_to_unit( copied_min_sectors, selected_partition .sector_size, UNIT_MIB ) ) ;
|
long COPIED_LENGTH_MB = Utils::round( Utils::sector_to_unit( copied_min_sectors, selected_partition .sector_size, UNIT_MIB ) ) ;
|
||||||
|
|
||||||
//now calculate proportional length of partition
|
//now calculate proportional length of partition
|
||||||
frame_resizer_base ->set_x_start( 0 ) ;
|
frame_resizer_base ->set_x_min_space_before( Utils::round( MIN_SPACE_BEFORE_MB / MB_PER_PIXEL ) ) ;
|
||||||
int x_end = Utils::round( COPIED_LENGTH_MB / ( TOTAL_MB/500.00 ) ) ; //> 500 px only possible with xfs...
|
frame_resizer_base ->set_x_start( Utils::round(MIN_SPACE_BEFORE_MB / MB_PER_PIXEL) ) ;
|
||||||
|
int x_end = Utils::round( (MIN_SPACE_BEFORE_MB + COPIED_LENGTH_MB) / ( TOTAL_MB/500.00 ) ) ; //> 500 px only possible with xfs...
|
||||||
frame_resizer_base ->set_x_end( x_end > 500 ? 500 : x_end ) ;
|
frame_resizer_base ->set_x_end( x_end > 500 ? 500 : x_end ) ;
|
||||||
frame_resizer_base ->set_used(
|
frame_resizer_base ->set_used(
|
||||||
Utils::round( Utils::sector_to_unit(
|
Utils::round( Utils::sector_to_unit(
|
||||||
|
|
|
@ -279,6 +279,7 @@ void Dialog_Partition_New::optionmenu_changed( bool type )
|
||||||
if ( ! fs .MAX || ( fs .MAX > ((TOTAL_MB - MIN_SPACE_BEFORE_MB) * MEBIBYTE) ) )
|
if ( ! fs .MAX || ( fs .MAX > ((TOTAL_MB - MIN_SPACE_BEFORE_MB) * MEBIBYTE) ) )
|
||||||
fs .MAX = ((TOTAL_MB - MIN_SPACE_BEFORE_MB) * MEBIBYTE) ;
|
fs .MAX = ((TOTAL_MB - MIN_SPACE_BEFORE_MB) * MEBIBYTE) ;
|
||||||
|
|
||||||
|
frame_resizer_base ->set_x_min_space_before( Utils::round( MIN_SPACE_BEFORE_MB / MB_PER_PIXEL ) ) ;
|
||||||
frame_resizer_base ->set_size_limits( Utils::round( fs .MIN / (MB_PER_PIXEL * MEBIBYTE) ),
|
frame_resizer_base ->set_size_limits( Utils::round( fs .MIN / (MB_PER_PIXEL * MEBIBYTE) ),
|
||||||
Utils::round( fs .MAX / (MB_PER_PIXEL * MEBIBYTE) ) ) ;
|
Utils::round( fs .MAX / (MB_PER_PIXEL * MEBIBYTE) ) ) ;
|
||||||
|
|
||||||
|
|
|
@ -110,6 +110,7 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector<Partiti
|
||||||
MB_PER_PIXEL = TOTAL_MB / 500.00 ;
|
MB_PER_PIXEL = TOTAL_MB / 500.00 ;
|
||||||
|
|
||||||
//now calculate proportional length of partition
|
//now calculate proportional length of partition
|
||||||
|
frame_resizer_base ->set_x_min_space_before( Utils::round( MIN_SPACE_BEFORE_MB / MB_PER_PIXEL ) ) ;
|
||||||
frame_resizer_base ->set_x_start( Utils::round( previous / ( total_length / 500.00 ) ) ) ;
|
frame_resizer_base ->set_x_start( Utils::round( previous / ( total_length / 500.00 ) ) ) ;
|
||||||
frame_resizer_base ->set_x_end(
|
frame_resizer_base ->set_x_end(
|
||||||
Utils::round( selected_partition .get_sector_length() / ( total_length / 500.00 ) ) + frame_resizer_base ->get_x_start() ) ;
|
Utils::round( selected_partition .get_sector_length() / ( total_length / 500.00 ) ) + frame_resizer_base ->get_x_start() ) ;
|
||||||
|
@ -198,6 +199,7 @@ void Dialog_Partition_Resize_Move::Resize_Move_Extended( const std::vector<Parti
|
||||||
MB_PER_PIXEL = TOTAL_MB / 500.00 ;
|
MB_PER_PIXEL = TOTAL_MB / 500.00 ;
|
||||||
|
|
||||||
//calculate proportional length of partition ( in pixels )
|
//calculate proportional length of partition ( in pixels )
|
||||||
|
frame_resizer_base ->set_x_min_space_before( Utils::round( MIN_SPACE_BEFORE_MB / MB_PER_PIXEL ) ) ;
|
||||||
frame_resizer_base ->set_x_start( Utils::round( previous / ( total_length / 500.00 ) ) ) ;
|
frame_resizer_base ->set_x_start( Utils::round( previous / ( total_length / 500.00 ) ) ) ;
|
||||||
frame_resizer_base ->set_x_end( Utils::round( selected_partition .get_sector_length() / ( total_length / 500.00 ) ) + frame_resizer_base ->get_x_start() ) ;
|
frame_resizer_base ->set_x_end( Utils::round( selected_partition .get_sector_length() / ( total_length / 500.00 ) ) + frame_resizer_base ->get_x_start() ) ;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
/* Copyright (C) 2004 Bart
|
/* Copyright (C) 2004 Bart
|
||||||
|
* Copyright (C) 2010 Curtis Gedak
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -21,6 +22,7 @@ Frame_Resizer_Base::Frame_Resizer_Base()
|
||||||
{
|
{
|
||||||
BORDER = 8 ;
|
BORDER = 8 ;
|
||||||
GRIPPER = 10 ;
|
GRIPPER = 10 ;
|
||||||
|
X_MIN_SPACE_BEFORE = 0 ;
|
||||||
|
|
||||||
fixed_start = false ;
|
fixed_start = false ;
|
||||||
init() ;
|
init() ;
|
||||||
|
@ -85,6 +87,11 @@ void Frame_Resizer_Base::set_x_start( int x_start )
|
||||||
this ->X_START = x_start + GRIPPER ;
|
this ->X_START = x_start + GRIPPER ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Frame_Resizer_Base::set_x_min_space_before( int x_min_space_before )
|
||||||
|
{
|
||||||
|
this ->X_MIN_SPACE_BEFORE = x_min_space_before ;
|
||||||
|
}
|
||||||
|
|
||||||
void Frame_Resizer_Base::set_x_end( int x_end )
|
void Frame_Resizer_Base::set_x_end( int x_end )
|
||||||
{
|
{
|
||||||
this ->X_END = x_end + GRIPPER + BORDER * 2 ;
|
this ->X_END = x_end + GRIPPER + BORDER * 2 ;
|
||||||
|
@ -147,7 +154,7 @@ bool Frame_Resizer_Base::drawingarea_on_mouse_motion( GdkEventMotion * ev )
|
||||||
{
|
{
|
||||||
if ( GRIP_LEFT )
|
if ( GRIP_LEFT )
|
||||||
{
|
{
|
||||||
if ( ev ->x > GRIPPER &&
|
if ( ev ->x > (GRIPPER + X_MIN_SPACE_BEFORE) &&
|
||||||
(X_END - ev ->x) < MAX_SIZE &&
|
(X_END - ev ->x) < MAX_SIZE &&
|
||||||
(X_END - ev ->x) > MIN_SIZE )
|
(X_END - ev ->x) > MIN_SIZE )
|
||||||
{
|
{
|
||||||
|
@ -161,8 +168,8 @@ bool Frame_Resizer_Base::drawingarea_on_mouse_motion( GdkEventMotion * ev )
|
||||||
{
|
{
|
||||||
X_START = X_END - MAX_SIZE ;
|
X_START = X_END - MAX_SIZE ;
|
||||||
|
|
||||||
if ( X_START < GRIPPER )
|
if ( X_START < (GRIPPER + X_MIN_SPACE_BEFORE) )
|
||||||
X_START = GRIPPER ;
|
X_START = GRIPPER + X_MIN_SPACE_BEFORE ;
|
||||||
|
|
||||||
//-1 to force the spinbutton to its max.
|
//-1 to force the spinbutton to its max.
|
||||||
signal_resize .emit( X_START - GRIPPER -1,
|
signal_resize .emit( X_START - GRIPPER -1,
|
||||||
|
@ -170,11 +177,11 @@ bool Frame_Resizer_Base::drawingarea_on_mouse_motion( GdkEventMotion * ev )
|
||||||
ARROW_LEFT ) ;
|
ARROW_LEFT ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( ev ->x <= GRIPPER )
|
else if ( ev ->x <= (GRIPPER + X_MIN_SPACE_BEFORE) )
|
||||||
{
|
{
|
||||||
if ( X_START > GRIPPER && X_END - X_START < MAX_SIZE )
|
if ( X_START > (GRIPPER + X_MIN_SPACE_BEFORE) && X_END - X_START < MAX_SIZE )
|
||||||
{
|
{
|
||||||
X_START = GRIPPER ;
|
X_START = GRIPPER + X_MIN_SPACE_BEFORE ;
|
||||||
|
|
||||||
signal_resize .emit( X_START - GRIPPER,
|
signal_resize .emit( X_START - GRIPPER,
|
||||||
X_END - GRIPPER - BORDER * 2,
|
X_END - GRIPPER - BORDER * 2,
|
||||||
|
@ -249,17 +256,17 @@ bool Frame_Resizer_Base::drawingarea_on_mouse_motion( GdkEventMotion * ev )
|
||||||
{
|
{
|
||||||
temp_x = X_START + static_cast<int>( ev ->x - X_START_MOVE );
|
temp_x = X_START + static_cast<int>( ev ->x - X_START_MOVE );
|
||||||
temp_y = X_END - X_START ;
|
temp_y = X_END - X_START ;
|
||||||
|
|
||||||
if ( temp_x > GRIPPER && temp_x + temp_y < 500 + GRIPPER + BORDER * 2 )
|
if ( temp_x > (GRIPPER + X_MIN_SPACE_BEFORE) && temp_x + temp_y < 500 + GRIPPER + BORDER * 2 )
|
||||||
{
|
{
|
||||||
X_START = temp_x ;
|
X_START = temp_x ;
|
||||||
X_END = X_START + temp_y ;
|
X_END = X_START + temp_y ;
|
||||||
}
|
}
|
||||||
else if ( temp_x <= GRIPPER )
|
else if ( temp_x <= (GRIPPER + X_MIN_SPACE_BEFORE) )
|
||||||
{
|
{
|
||||||
if ( X_START > GRIPPER )
|
if ( X_START > (GRIPPER + X_MIN_SPACE_BEFORE) )
|
||||||
{
|
{
|
||||||
X_START = GRIPPER ;
|
X_START = GRIPPER + X_MIN_SPACE_BEFORE;
|
||||||
X_END = X_START + temp_y ;
|
X_END = X_START + temp_y ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -271,8 +278,8 @@ bool Frame_Resizer_Base::drawingarea_on_mouse_motion( GdkEventMotion * ev )
|
||||||
X_START = X_END - temp_y ;
|
X_START = X_END - temp_y ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
X_START_MOVE = static_cast<int>( ev ->x ) ;
|
X_START_MOVE = static_cast<int>( ev ->x ) ;
|
||||||
signal_move .emit( X_START - GRIPPER, X_END - GRIPPER - BORDER * 2 ) ;
|
signal_move .emit( X_START - GRIPPER, X_END - GRIPPER - BORDER * 2 ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
/* Copyright (C) 2004 Bart
|
/* Copyright (C) 2004 Bart
|
||||||
|
* Copyright (C) 2010 Curtis Gedak
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -35,19 +36,20 @@ bool Frame_Resizer_Extended::drawingarea_on_mouse_motion( GdkEventMotion * ev )
|
||||||
{
|
{
|
||||||
if ( GRIP_LEFT )
|
if ( GRIP_LEFT )
|
||||||
{
|
{
|
||||||
if ( ev ->x > GRIPPER &&
|
if ( ev ->x > (GRIPPER + X_MIN_SPACE_BEFORE) &&
|
||||||
ev->x < X_END - BORDER *2 &&
|
ev ->x < (X_END - MIN_SIZE - BORDER * 2) &&
|
||||||
( ev ->x < USED_START || USED == 0 ) )
|
( ev ->x < USED_START || USED == 0 )
|
||||||
|
)
|
||||||
{
|
{
|
||||||
X_START = static_cast<int>( ev ->x ) ;
|
X_START = static_cast<int>( ev ->x ) ;
|
||||||
|
|
||||||
signal_resize .emit( X_START - GRIPPER, X_END - GRIPPER - BORDER * 2, ARROW_LEFT ) ;
|
signal_resize .emit( X_START - GRIPPER, X_END - GRIPPER - BORDER * 2, ARROW_LEFT ) ;
|
||||||
}
|
}
|
||||||
else if ( ev ->x <= GRIPPER )
|
else if ( ev ->x <= (GRIPPER + X_MIN_SPACE_BEFORE) )
|
||||||
{
|
{
|
||||||
if ( X_START > GRIPPER )
|
if ( X_START > (GRIPPER + X_MIN_SPACE_BEFORE) )
|
||||||
{
|
{
|
||||||
X_START = GRIPPER ;
|
X_START = GRIPPER + X_MIN_SPACE_BEFORE ;
|
||||||
|
|
||||||
signal_resize .emit( X_START - GRIPPER,
|
signal_resize .emit( X_START - GRIPPER,
|
||||||
X_END - GRIPPER - BORDER * 2,
|
X_END - GRIPPER - BORDER * 2,
|
||||||
|
@ -66,11 +68,11 @@ bool Frame_Resizer_Extended::drawingarea_on_mouse_motion( GdkEventMotion * ev )
|
||||||
ARROW_LEFT ) ;
|
ARROW_LEFT ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( USED == 0 && ev ->x >= X_END - BORDER * 2 )
|
else if ( USED == 0 && ev ->x >= (X_END - MIN_SIZE - BORDER * 2) )
|
||||||
{
|
{
|
||||||
if ( X_START < X_END - BORDER * 2 )
|
if ( X_START < X_END - BORDER * 2 )
|
||||||
{
|
{
|
||||||
X_START = X_END - BORDER * 2 ;
|
X_START = X_END - MIN_SIZE - BORDER * 2 ;
|
||||||
|
|
||||||
signal_resize .emit( X_START - GRIPPER,
|
signal_resize .emit( X_START - GRIPPER,
|
||||||
X_END - GRIPPER - BORDER * 2,
|
X_END - GRIPPER - BORDER * 2,
|
||||||
|
@ -81,7 +83,7 @@ bool Frame_Resizer_Extended::drawingarea_on_mouse_motion( GdkEventMotion * ev )
|
||||||
else if ( GRIP_RIGHT )
|
else if ( GRIP_RIGHT )
|
||||||
{
|
{
|
||||||
if ( ev ->x < 500 + GRIPPER + BORDER * 2 &&
|
if ( ev ->x < 500 + GRIPPER + BORDER * 2 &&
|
||||||
ev ->x > X_START + BORDER *2 &&
|
ev ->x > (X_START + MIN_SIZE + BORDER * 2) &&
|
||||||
( ev ->x > USED_START + USED + BORDER *2 || USED == 0 ) )
|
( ev ->x > USED_START + USED + BORDER *2 || USED == 0 ) )
|
||||||
{
|
{
|
||||||
X_END = static_cast<int>( ev ->x ) ;
|
X_END = static_cast<int>( ev ->x ) ;
|
||||||
|
@ -110,11 +112,11 @@ bool Frame_Resizer_Extended::drawingarea_on_mouse_motion( GdkEventMotion * ev )
|
||||||
X_END - GRIPPER - BORDER * 2 -1, ARROW_RIGHT ) ;
|
X_END - GRIPPER - BORDER * 2 -1, ARROW_RIGHT ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( USED == 0 && ev ->x <= X_START + BORDER *2 )
|
else if ( USED == 0 && ev ->x <= (X_START + MIN_SIZE + BORDER * 2) )
|
||||||
{
|
{
|
||||||
if ( X_END > X_START + BORDER *2 )
|
if ( X_END > (X_START + MIN_SIZE + BORDER * 2) )
|
||||||
{
|
{
|
||||||
X_END = X_START + BORDER *2 ;
|
X_END = X_START + MIN_SIZE + BORDER *2 ;
|
||||||
|
|
||||||
signal_resize .emit( X_START - GRIPPER,
|
signal_resize .emit( X_START - GRIPPER,
|
||||||
X_END - GRIPPER - BORDER * 2,
|
X_END - GRIPPER - BORDER * 2,
|
||||||
|
|
Loading…
Reference in New Issue