Commits

Herbert Breunung committed 88db378

copypasta splitter changes from main branch

Comments (0)

Files changed (1)

lib/Kephra/App/Splitter.pm

 	return Kephra::Log::error('have no first child widget')
 		unless is_widget( $parameter->{'top'} )
 		or is_widget( $parameter->{'left'} ) or $self->{'child1'};
-	return Kephra::Log::error('have no second child widget') 
-		unless is_widget( $parameter->{'bottom'} )
-		or is_widget( $parameter->{'right'} ) or $self->{'child2'};
 	return Kephra::Log::error('declare left/right or top/bottom children or none', 1) 
 		unless (exists $parameter->{'top'} and not exists $parameter->{'left'} and not exists $parameter->{'right'})
 		or (exists $parameter->{'left'} and not exists $parameter->{'top'} and not exists $parameter->{'bottom'})
 		or (not exists $parameter->{'top'} and not exists $parameter->{'bottom'}
 			and not exists $parameter->{'left'} and not exists $parameter->{'right'});
 
+	$self->Reparent( $parameter->{'parent'} )
+		if defined $parameter->{'parent'} and is_widget( $parameter->{'parent'} );
 
-	$self->{'child1'} = $parameter->{'top'} if exists $parameter->{'top'};
-	$self->{'child2'} = $parameter->{'bottom'} if exists $parameter->{'bottom'};
-	$self->{'child1'} = $parameter->{'left'} if exists $parameter->{'left'};
+	$self->{'child1'} = $parameter->{'top'}   if exists $parameter->{'top'};
+	$self->{'child2'} = $parameter->{'bottom'}if exists $parameter->{'bottom'};
+	$self->{'child1'} = $parameter->{'left'}  if exists $parameter->{'left'};
 	$self->{'child2'} = $parameter->{'right'} if exists $parameter->{'right'};
-	$self->{'child1'}->Reparent($self)
-		if $self->{'child1'} and $self->{'child1'}->GetParent ne $self;
-	$self->{'child2'}->Reparent($self)
-		if $self->{'child2'} and $self->{'child2'}->GetParent ne $self;
+
+	$self->{'child1'}->Reparent($self) if $self->{'child1'};
+	$self->{'child2'}->Reparent($self) if defined $self->{'child2'}
+										and is_widget( $self->{'child2'} );
 
 
 	$self->SetSplitMode( &Wx::wxSPLIT_HORIZONTAL )
 		if $self->{'dominant_child'} eq 'left' or $self->{'dominant_child'} eq 'top';
 	$self->{'dominant_child'} = 2
 		if $self->{'dominant_child'} eq 'right' or $self->{'dominant_child'} eq 'bottom';
+	$self->{'dominant_child'} = 1 
+		unless $self->{'dominant_child'} eq 1 or $self->{'dominant_child'} eq 2;
 
 
-	$self->{'position'} = exists $parameter->{'position'} ? $parameter->{'position'} : 0;
+	$self->{'position'} = 0 unless exists $self->{'position'};
+	$self->{'position'} = $parameter->{'pos'}      if exists $parameter->{'pos'};
+	$self->{'position'} = $parameter->{'position'} if exists $parameter->{'position'};
+
+
+	$self->{'min_size'} = 70 unless exists $self->{'min_size'};
+	$self->{'min_size'} = $parameter->{'min'}      if exists $parameter->{'min'};
+	$self->{'min_size'} = $parameter->{'min_size'} if exists $parameter->{'min_size'};
+	$self->SetMinimumPaneSize( $self->{'min_size'} );
 
 
 	$self->{'gravity'} = $parameter->{'gravity'} if exists $parameter->{'gravity'};
 		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();
+
+
+	if ($self->{'child2'}) { $self->resplit()                       }
+	else                   { $self->Initialize( $self->{'child1'} ) }
 }
 
 # call only if children or other property changes
 sub resplit {
 	my $self = shift;
 	return if $self->IsSplit;
-	return Kephra::Log::error("can't split without two child widgets")
-		unless $self->{'child1'} and $self->{'child2'};
+	return Kephra::Log::error("need at least one child", 0) unless $self->{'child1'};
+	return Kephra::Log::warning("need a second child", 0) unless $self->{'child2'};
 	if ($self->GetSplitMode eq &Wx::wxSPLIT_HORIZONTAL){
 		$self->SplitHorizontally( $self->{'child1'}, $self->{'child2'}, $self->{'position'} )
 	} else { 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.