--- deliantra/Deliantra-Client/DC/UI.pm 2006/04/11 18:00:45 1.72 +++ deliantra/Deliantra-Client/DC/UI.pm 2006/04/11 18:06:53 1.73 @@ -1,12 +1,9 @@ -package CFClient::Widget; +package CFClient::UI; use strict; use Scalar::Util; -use SDL::OpenGL; -use SDL::OpenGL::Constants; - use CFClient; our ($FOCUS, $HOVER, $GRAB); # various widgets @@ -72,6 +69,14 @@ $HOVER->mouse_motion ($ev, $HOVER->translate ($x, $y)) if $HOVER; } +############################################################################# + +package CFClient::UI::Base; + +use strict; + +use SDL::OpenGL; + sub new { my $class = shift; @@ -160,7 +165,7 @@ glPopMatrix; if ($self == $HOVER) { - my ($x, $y) = @$self->{qw(x y)}; + my ($x, $y) = @$self{qw(x y)}; glColor 1, 1, 1, 0.1; glEnable GL_BLEND; @@ -242,9 +247,9 @@ ############################################################################# -package CFClient::Widget::DrawBG; +package CFClient::UI::DrawBG; -our @ISA = CFClient::Widget::; +our @ISA = CFClient::UI::Base::; use strict; use SDL::OpenGL; @@ -277,9 +282,9 @@ ############################################################################# -package CFClient::Widget::Empty; +package CFClient::UI::Empty; -our @ISA = CFClient::Widget::; +our @ISA = CFClient::UI::Base::; sub size_request { (0, 0) @@ -289,9 +294,9 @@ ############################################################################# -package CFClient::Widget::Container; +package CFClient::UI::Container; -our @ISA = CFClient::Widget::; +our @ISA = CFClient::UI::Base::; sub new { my ($class, %arg) = @_; @@ -351,14 +356,14 @@ ############################################################################# -package CFClient::Widget::Bin; +package CFClient::UI::Bin; -our @ISA = CFClient::Widget::Container::; +our @ISA = CFClient::UI::Container::; sub new { my ($class, %arg) = @_; - my $child = (delete $arg{child}) || new CFClient::Widget::Empty::; + my $child = (delete $arg{child}) || new CFClient::UI::Empty::; $class->SUPER::new (children => [$child], %arg) } @@ -376,7 +381,7 @@ $self->SUPER::remove ($widget); - $self->{children} = [new CFClient::Widget::Empty] + $self->{children} = [new CFClient::UI::Empty] unless @{$self->{children}}; } @@ -397,9 +402,9 @@ ############################################################################# -package CFClient::Widget::Window; +package CFClient::UI::Window; -our @ISA = CFClient::Widget::Bin::; +our @ISA = CFClient::UI::Bin::; use SDL::OpenGL; @@ -459,9 +464,9 @@ ############################################################################# -package CFClient::Widget::Frame; +package CFClient::UI::Frame; -our @ISA = CFClient::Widget::Bin::; +our @ISA = CFClient::UI::Bin::; use SDL::OpenGL; @@ -507,9 +512,9 @@ ############################################################################# -package CFClient::Widget::FancyFrame; +package CFClient::UI::FancyFrame; -our @ISA = CFClient::Widget::Bin::; +our @ISA = CFClient::UI::Bin::; use SDL::OpenGL; @@ -594,9 +599,9 @@ ############################################################################# -package CFClient::Widget::Table; +package CFClient::UI::Table; -our @ISA = CFClient::Widget::; +our @ISA = CFClient::UI::Base::; use SDL::OpenGL; @@ -681,9 +686,9 @@ ############################################################################# -package CFClient::Widget::VBox; +package CFClient::UI::VBox; -our @ISA = CFClient::Widget::Container::; +our @ISA = CFClient::UI::Container::; use SDL::OpenGL; @@ -745,9 +750,9 @@ ############################################################################# -package CFClient::Widget::Label; +package CFClient::UI::Label; -our @ISA = CFClient::Widget::; +our @ISA = CFClient::UI::Base::; use SDL::OpenGL; @@ -856,9 +861,9 @@ ############################################################################# -package CFClient::Widget::Entry; +package CFClient::UI::Entry; -our @ISA = CFClient::Widget::Label::; +our @ISA = CFClient::UI::Label::; use SDL; use SDL::OpenGL; @@ -1008,14 +1013,14 @@ ############################################################################# -package CFClient::Widget::Slider; +package CFClient::UI::Slider; use strict; use SDL::OpenGL; use SDL::OpenGL::Constants; -our @ISA = CFClient::Widget::DrawBG::; +our @ISA = CFClient::UI::DrawBG::; sub size_request { my ($self) = @_; @@ -1122,7 +1127,7 @@ ############################################################################# -package CFClient::Widget::MapWidget; +package CFClient::UI::MapWidget; use strict; @@ -1132,7 +1137,7 @@ use SDL::OpenGL; use SDL::OpenGL::Constants; -our @ISA = CFClient::Widget::; +our @ISA = CFClient::UI::Base::; sub new { my $class = shift; @@ -1308,11 +1313,11 @@ ############################################################################# -package CFClient::Widget::Animator; +package CFClient::UI::Animator; use SDL::OpenGL; -our @ISA = CFClient::Widget::Bin::; +our @ISA = CFClient::UI::Bin::; sub moveto { my ($self, $x, $y) = @_; @@ -1350,9 +1355,9 @@ ############################################################################# -package CFClient::Widget::Toplevel; +package CFClient::UI::Toplevel; -our @ISA = CFClient::Widget::Container::; +our @ISA = CFClient::UI::Container::; sub size_request { ($::WIDTH, $::HEIGHT) @@ -1396,9 +1401,9 @@ ############################################################################# -package CFClient::Widget; +package CFClient::UI; -$TOPLEVEL = new CFClient::Widget::Toplevel; +$TOPLEVEL = new CFClient::UI::Toplevel; 1