mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 09:17:52 -06:00
Status bar and progress bar for rotation and scaling
This commit is contained in:
parent
32f6d0143b
commit
83b69b18d0
2 changed files with 154 additions and 7 deletions
|
@ -32,6 +32,10 @@ sub OnInit {
|
|||
EVT_MENU($frame, wxID_EXIT, sub {$_[0]->Close(1)});
|
||||
EVT_MENU($frame, wxID_ABOUT, \&About);
|
||||
|
||||
# status bar
|
||||
$frame->{statusbar} = Slic3r::GUI::ProgressStatusBar->new($frame, -1);
|
||||
$frame->SetStatusBar($frame->{statusbar});
|
||||
|
||||
# File menu
|
||||
my $fileMenu = Wx::Menu->new;
|
||||
$fileMenu->Append(1, "Save Config…");
|
||||
|
@ -87,4 +91,132 @@ sub warning_catcher {
|
|||
};
|
||||
}
|
||||
|
||||
package Slic3r::GUI::ProgressStatusBar;
|
||||
use base 'Wx::StatusBar';
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my $self = $class->SUPER::new(@_);
|
||||
|
||||
$self->{_changed} = 0;
|
||||
$self->{busy} = 0;
|
||||
$self->{timer} = Wx::Timer->new($self);
|
||||
$self->{prog} = Wx::Gauge->new($self, &Wx::wxGA_HORIZONTAL, 100, [-1,-1], [-1,-1]);
|
||||
$self->{prog}->Hide;
|
||||
|
||||
$self->SetFieldsCount(2);
|
||||
$self->SetStatusWidths(-1, 155);
|
||||
|
||||
Wx::Event::EVT_IDLE($self, sub { $self->_Reposition });
|
||||
Wx::Event::EVT_TIMER($self, \&OnTimer, $self->{timer});
|
||||
Wx::Event::EVT_SIZE($self, \&OnSize);
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub DESTROY {
|
||||
my $self = shift;
|
||||
$self->{timer}->Stop if $self->{timer} && $self->{timer}->IsRunning;
|
||||
}
|
||||
|
||||
sub _Reposition {
|
||||
my $self = shift;
|
||||
|
||||
##if ($self->{_changed}) {
|
||||
my $rect = $self->GetFieldRect($self->GetFieldsCount - 1);
|
||||
my $prog_pos = [$rect->GetX + 2, $rect->GetY + 2];
|
||||
$self->{prog}->Move($prog_pos);
|
||||
$self->{prog}->SetSize($rect->GetWidth - 8, $rect->GetHeight - 4);
|
||||
##}
|
||||
$self->{_changed} = 0;
|
||||
}
|
||||
|
||||
sub OnSize {
|
||||
my ($self, $event) = @_;
|
||||
|
||||
$self->{_changed} = 1;
|
||||
$self->_Reposition;
|
||||
$event->Skip;
|
||||
}
|
||||
|
||||
sub OnTimer {
|
||||
my ($self, $event) = @_;
|
||||
|
||||
if ($self->{prog}->IsShown) {
|
||||
$self->{timer}->Stop;
|
||||
}
|
||||
$self->{prog}->Pulse if $self->{_busy};
|
||||
}
|
||||
|
||||
sub Run {
|
||||
my $self = shift;
|
||||
my $rate = shift || 100;
|
||||
if (!$self->{timer}->IsRunning) {
|
||||
$self->{timer}->Start($rate);
|
||||
}
|
||||
}
|
||||
|
||||
sub GetProgress {
|
||||
my $self = shift;
|
||||
return $self->{prog}->GetValue;
|
||||
}
|
||||
|
||||
sub SetProgress {
|
||||
my $self = shift;
|
||||
my ($val) = @_;
|
||||
if (!$self->{prog}->IsShown) {
|
||||
$self->ShowProgress(1);
|
||||
}
|
||||
if ($val == $self->{prog}->GetRange) {
|
||||
$self->{prog}->SetValue(0);
|
||||
$self->ShowProgress(0);
|
||||
} else {
|
||||
$self->{prog}->SetValue($val);
|
||||
}
|
||||
}
|
||||
|
||||
sub SetRange {
|
||||
my $self = shift;
|
||||
my ($val) = @_;
|
||||
|
||||
if ($val != $self->{prog}->GetRange) {
|
||||
$self->{prog}->SetRange($val);
|
||||
}
|
||||
}
|
||||
|
||||
sub ShowProgress {
|
||||
my $self = shift;
|
||||
my ($show) = @_;
|
||||
|
||||
$self->_Reposition;
|
||||
$self->{prog}->Show($show);
|
||||
$self->{prog}->Pulse;
|
||||
}
|
||||
|
||||
sub StartBusy {
|
||||
my $self = shift;
|
||||
my $rate = shift || 100;
|
||||
|
||||
$self->{_busy} = 1;
|
||||
$self->_Reposition;
|
||||
$self->ShowProgress(1);
|
||||
if (!$self->{timer}->IsRunning) {
|
||||
$self->{timer}->Start($rate);
|
||||
}
|
||||
}
|
||||
|
||||
sub StopBusy {
|
||||
my $self = shift;
|
||||
|
||||
$self->{timer}->Stop;
|
||||
$self->ShowProgress(0);
|
||||
$self->{prog}->SetValue(0);
|
||||
$self->{_busy} = 0;
|
||||
}
|
||||
|
||||
sub IsBusy {
|
||||
my $self = shift;
|
||||
return $self->{_busy};
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue