Re: [whatwg] Canvas ScrollBar

2012-01-27 Thread Bronislav Klučka



On 27.1.2012 20:02, Ian Hickson wrote:

On Thu, 20 Oct 2011, Bronislav Klu�~Mka wrote:

Would it be possible to extend canvas specification to include scroll
bar functionality? To add scroll bar, to manage scroll bar (total size,
page size). Creating control based on canvas that needs scrollbar at
this point is unnecessarily difficult at this point.

It is expected that the component model feature being discussed in the
public-weba...@w3.org mailing list will be how you make widgets on the
platform.

You wouldn't want to put the scrollbar in the canvas itself, since then it
wouldn't follow platform native conventions, for example. Instead, you
would create a widget which uses overflow:scroll with an element of the
right height or width to create scrollbars, and then you would react to
scroll events to repaint the canvas.
How does scrollbar on div, p, textarea etc. follow platform native 
conventions but scroll bar on canvas would not?


On Thu, 20 Oct 2011, Bronislav Klu�~Mka wrote:

b) how about creating user controls using canvas? (rich controls are
better doing this way, one has pixel perfect control, full browser
compatibility) like document viewer, rich listview/treeview control...

Generally speaking, canvas isn't intended for anything but the simplest of
interactive controls.

HTH,
Generally speaking, widgets are intended to be HTML container, which 
makes them far inferior to possibilities of canvas... simpler, but 
inferior (as is any HTML container at this point).


Brona



Re: [whatwg] Canvas ScrollBar

2012-01-27 Thread Ian Hickson
On Thu, 20 Oct 2011, Bronislav Klu�~Mka wrote:
>
> Would it be possible to extend canvas specification to include scroll 
> bar functionality? To add scroll bar, to manage scroll bar (total size, 
> page size). Creating control based on canvas that needs scrollbar at 
> this point is unnecessarily difficult at this point.

It is expected that the component model feature being discussed in the 
public-weba...@w3.org mailing list will be how you make widgets on the 
platform. 

You wouldn't want to put the scrollbar in the canvas itself, since then it 
wouldn't follow platform native conventions, for example. Instead, you 
would create a widget which uses overflow:scroll with an element of the 
right height or width to create scrollbars, and then you would react to 
scroll events to repaint the canvas.


On Thu, 20 Oct 2011, Bronislav Klu�~Mka wrote:
> 
> b) how about creating user controls using canvas? (rich controls are 
> better doing this way, one has pixel perfect control, full browser 
> compatibility) like document viewer, rich listview/treeview control...

Generally speaking, canvas isn't intended for anything but the simplest of 
interactive controls.

HTH,
-- 
Ian Hickson   U+1047E)\._.,--,'``.fL
http://ln.hixie.ch/   U+263A/,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Re: [whatwg] Canvas ScrollBar

2011-10-20 Thread Bronislav Klučka

Hi
1/ not all browsers supports such big canvas (but OK, this is browsers 
issue), but one need to work around it
2/ the optimalization you describe is implied (paint only what you 
need), never the less.. you still have to create unnecessary elements 
(overflow hidden? didn't you mean scroll?)
3/ sure... i can somehow do that... but do we need element.textContent? 
querySelector API? HTML5 forms? and lot of other new stuff we get? No, 
we can do them using some libraries... but we have, because it makes 
programming easier...


Essentially... if there are no plans for that, fine :), I can imagine 
there is too much work to be done on other issues, but "we can do it 
using more elements and more programming" is not an argument...


I was not asking how to do that, I know how... I was asking whether 
there is a plan to add scrollbar to canvas.


Brona Klucka


On 20.10.2011 17:17, Robert Eisele wrote:

Hi,

what is wrong with a 100k x 100k canvas? Just draw on the currently 
visible region with some overlapping to make slow event listeners not 
a problem. This tends to another optimization: Create scrollbars of 
the dimension you need and draw on a very small canvas only the 
information that is really necessary. Why should you update all the 
invisible pixels?


I would say, this problem can be solved simply with JavaScript + 
overflow:hidden and doesn't need an extension of the canvas element in 
any way.


Robert Eisele


2011/10/20 Bronislav Klučka >




On 20.10.2011 14:35, João Eiras wrote:

On Thu, 20 Oct 2011 14:14:12 +0200, Bronislav Klučka
mailto:bronislav.klu...@bauglir.com>> wrote:

Hello,
Would it be possible to extend canvas specification to
include scroll bar functionality? To add scroll bar, to
manage scroll bar (total size, page size). Creating
control based on canvas that needs scrollbar at this point
is unnecessarily difficult at this point.


Brona Klucka


Which is your use case ?

It doesn't make any sense at all to me to have scrollbars in a
canvas. However, if you need scrolling, you can wrap the
canvas with an element with specified dimensions and
overflow:auto.


Hi,
1/ your solution is very wrong solution could you imagine
canvas 10x10px? well not possible, only solution is to
create smaller canvas, wrap it into overflow auto div with inner
div and then compute the dimension of whole image with javascript
and transfer it to inner div dimensions (so scrollbars would
match) and listen to onScroll event of outer div, and  repaint the
image with shifted origin

2/ use cases?
a)
diagram modeller
http://www.webnt.cz/demos/033_canvas_diagram/
what if I have some large diagram?

b) how about creating user controls using canvas? (rich controls
are better doing this way, one has pixel perfect control, full
browser compatibility) like document viewer, rich
listview/treeview control...

Brona Klucka







Re: [whatwg] Canvas ScrollBar

2011-10-20 Thread Bronislav Klučka



On 20.10.2011 14:35, João Eiras wrote:
On Thu, 20 Oct 2011 14:14:12 +0200, Bronislav Klučka 
 wrote:



Hello,
Would it be possible to extend canvas specification to include scroll 
bar functionality? To add scroll bar, to manage scroll bar (total 
size, page size). Creating control based on canvas that needs 
scrollbar at this point is unnecessarily difficult at this point.



Brona Klucka


Which is your use case ?

It doesn't make any sense at all to me to have scrollbars in a canvas. 
However, if you need scrolling, you can wrap the canvas with an 
element with specified dimensions and overflow:auto.


Hi,
1/ your solution is very wrong solution could you imagine canvas 
10x10px? well not possible, only solution is to create smaller 
canvas, wrap it into overflow auto div with inner div and then compute 
the dimension of whole image with javascript and transfer it to inner 
div dimensions (so scrollbars would match) and listen to onScroll event 
of outer div, and  repaint the image with shifted origin


2/ use cases?
a)
diagram modeller
http://www.webnt.cz/demos/033_canvas_diagram/
what if I have some large diagram?

b) how about creating user controls using canvas? (rich controls are 
better doing this way, one has pixel perfect control, full browser 
compatibility) like document viewer, rich listview/treeview control...


Brona Klucka


Re: [whatwg] Canvas ScrollBar

2011-10-20 Thread João Eiras
On Thu, 20 Oct 2011 14:14:12 +0200, Bronislav Klučka  
 wrote:



Hello,
Would it be possible to extend canvas specification to include scroll  
bar functionality? To add scroll bar, to manage scroll bar (total size,  
page size). Creating control based on canvas that needs scrollbar at  
this point is unnecessarily difficult at this point.



Brona Klucka


Which is your use case ?

It doesn't make any sense at all to me to have scrollbars in a canvas.  
However, if you need scrolling, you can wrap the canvas with an element  
with specified dimensions and overflow:auto.


[whatwg] Canvas ScrollBar

2011-10-20 Thread Bronislav Klučka

Hello,
Would it be possible to extend canvas specification to include scroll 
bar functionality? To add scroll bar, to manage scroll bar (total size, 
page size). Creating control based on canvas that needs scrollbar at 
this point is unnecessarily difficult at this point.



Brona Klucka