1 | package CFPlus::UI::Canvas; |
1 | package DC::UI::Canvas; |
2 | |
2 | |
3 | use strict; |
3 | use strict; |
4 | use utf8; |
4 | use utf8; |
5 | |
5 | |
6 | use List::Util qw(max min); |
6 | use List::Util qw(max min); |
7 | |
7 | |
8 | use CFPlus::OpenGL; |
8 | use DC::OpenGL; |
9 | |
9 | |
10 | our @ISA = CFPlus::UI::Fixed::; |
10 | our @ISA = DC::UI::Fixed::; |
11 | |
11 | |
12 | sub new { |
12 | sub new { |
13 | my ($class, %arg) = @_; |
13 | my ($class, %arg) = @_; |
14 | |
14 | |
15 | my $items = delete $arg{items}; |
15 | my $items = delete $arg{items}; |
16 | |
16 | |
17 | my $self = $class->SUPER::new ( |
17 | my $self = $class->SUPER::new ( |
18 | items => [], |
18 | items => [], |
19 | @_, |
19 | @_, |
20 | ); |
20 | ); |
21 | |
21 | |
22 | $self->add (@$items) |
22 | $self->add (@$items) |
23 | if $items && @$items; |
23 | if $items && @$items; |
… | |
… | |
46 | sub size_request { |
46 | sub size_request { |
47 | my ($self) = @_; |
47 | my ($self) = @_; |
48 | |
48 | |
49 | my ($w, $h) = $self->SUPER::size_request; |
49 | my ($w, $h) = $self->SUPER::size_request; |
50 | |
50 | |
51 | ((max $w, $self->{item_max_w}), (max $h, $self->{item_max_h})) |
51 | ( |
|
|
52 | (max $w, $self->{item_max_w}), |
|
|
53 | (max $h, $self->{item_max_h}), |
|
|
54 | ) |
52 | } |
55 | } |
53 | |
56 | |
54 | my %GLTYPE = ( |
57 | my %GLTYPE = ( |
55 | lines => GL_LINES, |
58 | lines => GL_LINES, |
56 | line_strip => GL_LINE_STRIP, |
59 | line_strip => GL_LINE_STRIP, |
… | |
… | |
82 | glEnd; |
85 | glEnd; |
83 | } |
86 | } |
84 | |
87 | |
85 | glPopMatrix; |
88 | glPopMatrix; |
86 | } |
89 | } |
|
|
90 | |
|
|
91 | glLineWidth 1; |
|
|
92 | glPointSize 1; |
87 | } |
93 | } |
88 | |
94 | |
89 | 1 |
95 | 1 |
90 | |
96 | |