ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/kgsueme/kgsueme/board.pl
(Generate patch)

Comparing kgsueme/kgsueme/board.pl (file contents):
Revision 1.13 by pcg, Sun Jul 20 01:29:20 2003 UTC vs.
Revision 1.14 by pcg, Mon Jul 21 14:00:48 2003 UTC

11 "Board Size", 11 "Board Size",
12 "The Go Board size, 2..38", 12 "The Go Board size, 2..38",
13 2, 38, 19, 13 2, 38, 19,
14 [qw(construct-only writable readable)], 14 [qw(construct-only writable readable)],
15 ), 15 ),
16 Glib::ParamSpec->double (
17 "aspect",
18 "Aspect",
19 "the aspect ratio of the board (overwritten by traditional)",
20 0, 2, 1,
21 [qw(construct-only writable readable)],
22 ),
23 Glib::ParamSpec->boolean (
24 "traditional",
25 "Traditional Layout",
26 "Enable a more traditional goban layout",
27 1,
28 [qw(construct-only writable readable)],
29 ),
30 ]; 16 ];
31 17
32use KGS::Constants; 18use KGS::Constants;
33use KGS::Game::Board; 19use KGS::Game::Board;
34 20
41 27
42sub INIT_INSTANCE { 28sub INIT_INSTANCE {
43 my $self = shift; 29 my $self = shift;
44 30
45 $self->double_buffered (0); 31 $self->double_buffered (0);
46 $self->set (border_width => 0, shadow_type => 'none', obey_child => 0); 32 $self->set (border_width => 0, shadow_type => 'none',
33 obey_child => 0, ratio => TRAD_WIDTH / TRAD_HEIGHT);
47 34
48 $self->add ($self->{canvas} = new Gtk2::DrawingArea); 35 $self->add ($self->{canvas} = new Gtk2::DrawingArea);
49 $self->{canvas}->signal_connect (configure_event => sub { $self->configure_event ($_[1]) }); 36 $self->{canvas}->signal_connect (configure_event => sub { $self->configure_event ($_[1]) });
50} 37}
51 38
52sub FINALIZE_INSTANCE { 39sub FINALIZE_INSTANCE {
53 my $self = shift; 40 my $self = shift;
54 41
55 die "FINALIZE board\n";#d# 42 die "FINALIZE board\n";#d#
56}
57
58sub SET_PROPERTY {
59 my ($self, $pspec, $newval) = @_;
60 my $name = $pspec->get_name;
61
62 $self->{$name} = $newval;
63
64 if ($name eq "aspect") {
65 $self->set (ratio => $newval);
66 } elsif ($name eq "traditional") {
67 $self->set (aspect => TRAD_WIDTH / TRAD_HEIGHT) if $newval;
68 }
69} 43}
70 44
71sub configure_event { 45sub configure_event {
72 my ($self, $event) = @_; 46 my ($self, $event) = @_;
73 47
171 my $gridcolour = 0x88444400; # black is traditional, but only with overlapping stones 145 my $gridcolour = 0x88444400; # black is traditional, but only with overlapping stones
172 my $labelcolour = 0x88444400; 146 my $labelcolour = 0x88444400;
173 147
174 # we leave enough space for the shadows.. I like smaller stones, and we 148 # we leave enough space for the shadows.. I like smaller stones, and we
175 # do no need to do the nifty recursive screen updates that cgoban2 does 149 # do no need to do the nifty recursive screen updates that cgoban2 does
150 # TODO: smaller == buggy, want visual perfectness
176 my $borderw = int ($w / ($size + 3) * 0.5); 151 my $borderw = int ($w / ($size + 3) * 0.5);
177 my $borderh = int ($h / ($size + 3) * 0.5); 152 my $borderh = $borderw;
178 my $w2 = $w - $borderw * 2; 153 my $w2 = $w - $borderw * 2;
179 my $h2 = $h - $borderh * 2; 154 my $h2 = $h - $borderh * 2;
180 my $edge = $self->{edge} = $w2 / ($size + 1) * 0.975 - 1; 155 my $edge = $self->{edge} = $w2 / ($size + 1) * 0.975 - 1;
181 my $ofs = $edge * 0.5; 156 my $ofs = $edge * 0.5;
182 157

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines