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