Source

Kephra / lib / Kephra / App / Splitter.pm

Diff from to

lib/Kephra/App/Splitter.pm

 }
 
 sub resize {
-	my ($self, $size) = @_;
-	return unless defined $size;
-	$size = 0.5 if $size eq 'equal';
-	return unless looks_like_number($size);
+	my ($self, $pos) = @_;
+	return unless defined $pos;
+	$pos = 0.5 if $pos eq 'equal';
+	return unless looks_like_number($pos);
 
-	if ($size <= 1 and $size > -1){
+	# negative sizes are counted from right border
+	# sizes between -1 and 1 are percentages of splitter size
+	if ($pos <= 1 and $pos > -1){
 		my $size = $self->GetSize;
 		if ($self->GetSplitMode eq &Wx::wxSPLIT_HORIZONTAL){
-			$self->SetSashPosition( $size->GetHeight * $size, 1);
+			$self->SetSashPosition( $size->GetHeight * $pos, 1);
 		} 
 		elsif ($self->GetSplitMode eq &Wx::wxSPLIT_VERTICAL) {
-			$self->SetSashPosition( $size->GetWidth * $size, 1);
+			#say "resize $pos ",$size->GetHeight;
+			$self->SetSashPosition( $size->GetWidth * $pos, 1);
 		} 
-		else { return }
+		else { return; }
 	} 
-	else { $self->SetSashPosition($size, 1) }
+	else { $self->SetSashPosition($pos, 1) }
 
 	$self->{'position'} = $self->GetSashPosition;
 	$self;