Deliantra-Client
view release on metacpan or search on metacpan
DC/UI/Dockable.pm view on Meta::CPAN
sub set_dockbar_pos {
my ($self, $pos) = @_;
$self->{dockbar_pos} = $pos;
$self->update_tab;
}
# (private) This method tells the dockable that it is 'active', which means:
# it is docked and it's tab has been activated and it is currently shown.
sub set_dockbar_tab_active {
my ($self, $active) = @_;
$self->{dockbar_active} = $active;
$self->update_tab;
}
# (private) This method updates the tab and other things of the dockable
# whenever something has been changed (title, color, ...)
sub update_tab {
my ($self) = @_;
# TODO: set color according to dockbar_active
my $oldcolor = $self->{tab_label}->{fg};
if ($self->is_docked_active) {
$self->{tab_label}->{fg} = $self->{active_fg} || [1, 1, 1];
} else {
$self->{tab_label}->{fg} = $self->{inactive_fg} || [1, 1, 1,];
}
if (join (',', @$oldcolor) ne join (',', @{$self->{tab_label}->{fg}})) {
# update colors
$self->{tab_label}->realloc;
$self->{tab_label}->update;
}
$self->{tab_label}->set_markup (
$self->get_title
. (defined $self->{dockbar_pos}
? "-" . ($self->{dockbar_pos} + 1)
: "")
);
}
# This method sets the active foreground color of the dockable tab
sub set_active_fg {
my ($self, $fg) = @_;
$self->{active_fg} = $fg;
$self->update_tab;
}
# This method sets the inactive foreground color of the dockable tab
sub set_inactive_fg {
my ($self, $fg) = @_;
$self->{inactive_fg} = $fg;
$self->update_tab;
}
# (private) This method is used by the Dockbar to tell the Dockable which
# Dockbar it belongs to. Do not call this method yourself, use the dockbars
# add_dock and remove_dock methods instead.
sub set_dockbar {
my ($self, $dockbar) = @_;
$self->{dockbar} = $dockbar;
Scalar::Util::weaken $self->{dockbar};
}
# This method is called when someone wants to 'activate' the dockable,
# the meaning of being 'activated' is given by subclasses that inherit
# from Dockable. Eg. In ChatView the 'activation' means that the entry field
# of for chat is activated for input.
sub activate {
my ($self) = @_;
$self->emit ("activate");
}
# Returns whether this dockable is docked on a Dockbar.
sub is_docked {
my ($self) = @_;
$self->{dockbar} or return 0;
return $self->{dockbar}->is_docked ($self);
}
# Returns whether this dockable is docked _and_ it's tab
# is active.
sub is_docked_active {
my ($self) = @_;
$self->{dockbar} or return 0;
return $self->{dockbar_active};
}
# This method is called when the Dockable wants to be closed, which means
# that it's window is closed or tab is removed from the dockbar and it
# is removed from the dockbar.
sub close {
my ($self) = @_;
return if !$self->{can_close};
$self->emit ("close_dock");
}
1
( run in 1.724 second using v1.01-cache-2.11-cpan-39bf76dae61 )