Commits

Herbert Breunung committed 5f341ca

polish splitter: started get method, set now stores all parameter, better docs

  • Participants
  • Parent commits d9d4098

Comments (0)

Files changed (1)

lib/Kephra/App/Splitter.pm

 
 sub _eval_parameter {
 	my ($self, $parameter) = @_;
-	# parameter: left=widget right=widget top=widget bottom=widget
-	#            dominant_child=1/2 orientation=horizontal/vertical 
-	#            gravity=0..1 position(px size of child1) split=no
+	# parameter: left=widget right=widget / top=widget bottom=widget (just one works too)
+	#            dominant_child=1/2/left/right/top/bottom
+	#            orientation=horizontal/vertical 
+	#            gravity=0..1 position=px size of child1 split=yes/no/keep
 	return Kephra::Log::error('need parameter as hash') unless ref $parameter eq 'HASH';
 	return Kephra::Log::error('have no first child widget')
 		unless $is_widget->( $parameter->{'top'} )
 	$self->{'dominant_child'} = 2
 		if $self->{'dominant_child'} eq 'right' or $self->{'dominant_child'} eq 'bottom';
 
+
 	$self->{'position'} = exists $parameter->{'position'} ? $parameter->{'position'} : 0;
 
-	return $self->unsplit()
-		if not exists $self->{'child1'} or not $self->{'child1'}
-		or not exists $self->{'child2'} or not $self->{'child2'}
-		or exists $parameter->{'split'} and $parameter->{'split'} eq 'no';
-	$self->resplit();
 
 	$self->{'gravity'} = $parameter->{'gravity'} if exists $parameter->{'gravity'};
 	if (not exists $self->{'gravity'} and exists $parameter->{'dominant_child'}){
 		$self->{'gravity'} = $self->{'dominant_child'} == 1 ? 1 : 0;
 	}
 	$self->{'gravity'} = 0.5 unless exists $self->{'gravity'};
+
+
+	return if defined $parameter->{'split'} and $parameter->{'split'} eq 'keep';
+	return $self->unsplit()
+		if not exists $self->{'child1'} or not $self->{'child1'}
+		or not exists $self->{'child2'} or not $self->{'child2'}
+		or exists $parameter->{'split'} and $parameter->{'split'} eq 'no';
+	$self->resplit();
 	$self->SetSashGravity( $self->{'gravity'} ); # 1 is left/top - 0 is right/bottom
 }
 
 	$self->_eval_parameter( $parameter );
 }
 
+sub get {
+	my ($self, $parameter) = @_;
+	return unless $parameter and not ref $parameter;
+	if ($parameter eq 'dominant_child'){
+		if ($self->GetSplitMode() == &Wx::wxSPLIT_HORIZONTAL){
+			return $self->{'dominant_child'} == 1 ? 'top' : 'bottom';
+		}
+		else {
+			return $self->{'dominant_child'} == 1 ? 'left' : 'right';
+		}
+	}
+}
+
 sub resplit {
 	my $self = shift;
 	return if $self->IsSplit;