Discussion:
Gambas3: ScrollArea doesn't scroll
(too old to reply)
Rolf-Werner Eilert
2012-01-09 08:08:59 UTC
Permalink
Here I am definitely understanding something wrong.

I need a graphical object that allows for drawing some sort of
specialized table that can expand and collapse certain rows like a
TreeView. So I decided to program that either based on HTML in a
RichText thing or better everything by myself in a DrawingArea. The
DrawingArea would have to expand according to the contents and be
controlled by ScrollBars. Then I found there is a ScrollArea in Gambas3
which could do 90 % of the job by itself.

This is my understanding: A ScrollArea should be a DrawingArea which is
enlarged automagically as soon as you draw beyond its borders and will
produce ScrollBars for the user to slide the area forth and back below
the visible frame that confines it on screen.

Do you agree?

Ok, I have a small ScrollArea, say 100 x 100 px.

In Form_Open, I set its Contents to 2500 x 2500 px as from the
documentation I understand it won't do that by itself (why not?).

It shows two ScrollBars.

I draw a line from 1,1 to 500,500.

When I move the ScrollBars, nothing happens, i. e. the image shows the
beginning of the line and stands still. This happens in qt (KDE4) as
well as GTK (LXDE).

The ScrollArea is not cached. I guess if I really have to move it by
code, I will produce a whole lot of unnecessary Draw events.

But just in case, how would their position be calculated? I would have
to read the ScrollBar values, but their output is not documented - is it
percent? Or relative to anything?

(I cannot give you code snippets as this happened on my laptop this
weekend, and I don't have G3 here in my office yet.)

Really looking forward to your comments!

Rolf
Benoît Minisini
2012-01-09 11:51:27 UTC
Permalink
Post by Rolf-Werner Eilert
Here I am definitely understanding something wrong.
I need a graphical object that allows for drawing some sort of
specialized table that can expand and collapse certain rows like a
TreeView. So I decided to program that either based on HTML in a
RichText thing or better everything by myself in a DrawingArea. The
DrawingArea would have to expand according to the contents and be
controlled by ScrollBars. Then I found there is a ScrollArea in Gambas3
which could do 90 % of the job by itself.
This is my understanding: A ScrollArea should be a DrawingArea which is
enlarged automagically as soon as you draw beyond its borders and will
produce ScrollBars for the user to slide the area forth and back below
the visible frame that confines it on screen.
Do you agree?
Ok, I have a small ScrollArea, say 100 x 100 px.
In Form_Open, I set its Contents to 2500 x 2500 px as from the
documentation I understand it won't do that by itself (why not?).
It shows two ScrollBars.
I draw a line from 1,1 to 500,500.
When I move the ScrollBars, nothing happens, i. e. the image shows the
beginning of the line and stands still. This happens in qt (KDE4) as
well as GTK (LXDE).
The ScrollArea is not cached. I guess if I really have to move it by
code, I will produce a whole lot of unnecessary Draw events.
But just in case, how would their position be calculated? I would have
to read the ScrollBar values, but their output is not documented - is it
percent? Or relative to anything?
(I cannot give you code snippets as this happened on my laptop this
weekend, and I don't have G3 here in my office yet.)
Really looking forward to your comments!
Rolf
Because when you draw, you need to use the ScrollX and ScrollY to know
how much you must translate what you draw inside the Draw event handler.

Nothing is physically moved, it is really "just" a DrawingArea with two
scrollbars entirely made in Gambas (the source code is in gb.form if you
are curious).

Regards,
--
Benoît Minisini
Rolf-Werner Eilert
2012-01-09 12:07:26 UTC
Permalink
Post by Benoît Minisini
Post by Rolf-Werner Eilert
Here I am definitely understanding something wrong.
I need a graphical object that allows for drawing some sort of
specialized table that can expand and collapse certain rows like a
TreeView. So I decided to program that either based on HTML in a
RichText thing or better everything by myself in a DrawingArea. The
DrawingArea would have to expand according to the contents and be
controlled by ScrollBars. Then I found there is a ScrollArea in Gambas3
which could do 90 % of the job by itself.
This is my understanding: A ScrollArea should be a DrawingArea which is
enlarged automagically as soon as you draw beyond its borders and will
produce ScrollBars for the user to slide the area forth and back below
the visible frame that confines it on screen.
Do you agree?
Ok, I have a small ScrollArea, say 100 x 100 px.
In Form_Open, I set its Contents to 2500 x 2500 px as from the
documentation I understand it won't do that by itself (why not?).
It shows two ScrollBars.
I draw a line from 1,1 to 500,500.
When I move the ScrollBars, nothing happens, i. e. the image shows the
beginning of the line and stands still. This happens in qt (KDE4) as
well as GTK (LXDE).
The ScrollArea is not cached. I guess if I really have to move it by
code, I will produce a whole lot of unnecessary Draw events.
But just in case, how would their position be calculated? I would have
to read the ScrollBar values, but their output is not documented - is it
percent? Or relative to anything?
(I cannot give you code snippets as this happened on my laptop this
weekend, and I don't have G3 here in my office yet.)
Really looking forward to your comments!
Rolf
Because when you draw, you need to use the ScrollX and ScrollY to know
how much you must translate what you draw inside the Draw event handler.
Nothing is physically moved, it is really "just" a DrawingArea with two
scrollbars entirely made in Gambas (the source code is in gb.form if you
are curious).
Regards,
Ok, I think I understand: With the help of ScrollX and ScrollY I have to
decide at which coordinate within my large drawing I start to draw to
1,1 on the DrawingArea?

Rolf
Benoît Minisini
2012-01-09 12:39:02 UTC
Permalink
Post by Rolf-Werner Eilert
Ok, I think I understand: With the help of ScrollX and ScrollY I have to
decide at which coordinate within my large drawing I start to draw to
1,1 on the DrawingArea?
Rolf
Yes. If you don't care with drawing everything at each draw event, it is
just a matter of translating the coordinate system with Draw.Translate().
--
Benoît Minisini
Rolf-Werner Eilert
2012-01-10 07:19:00 UTC
Permalink
Post by Benoît Minisini
Post by Rolf-Werner Eilert
Ok, I think I understand: With the help of ScrollX and ScrollY I have to
decide at which coordinate within my large drawing I start to draw to
1,1 on the DrawingArea?
Rolf
Yes. If you don't care with drawing everything at each draw event, it is
just a matter of translating the coordinate system with Draw.Translate().
Last evening I found that with Gambas3 under KDE nothing is shown in
ScrollArea and DrawingArea, the areas just stay cleared, but no error
occurs. When I switch them cached = TRUE it will crash with Sig #11
after some drawings, but the IDE doesn't crash. Under LXDE everything
works flawlessly.

Rolf
Benoît Minisini
2012-01-12 05:36:27 UTC
Permalink
Post by Rolf-Werner Eilert
Post by Benoît Minisini
Post by Rolf-Werner Eilert
Ok, I think I understand: With the help of ScrollX and ScrollY I have to
decide at which coordinate within my large drawing I start to draw to
1,1 on the DrawingArea?
Rolf
Yes. If you don't care with drawing everything at each draw event, it is
just a matter of translating the coordinate system with Draw.Translate().
Last evening I found that with Gambas3 under KDE nothing is shown in
ScrollArea and DrawingArea, the areas just stay cleared, but no error
occurs. When I switch them cached = TRUE it will crash with Sig #11
after some drawings, but the IDE doesn't crash. Under LXDE everything
works flawlessly.
Rolf
Which graphics system is configured for your Qt library: 'X11', 'Raster'
or 'OpenGL'?
--
Benoît Minisini
Rolf-Werner Eilert
2012-01-12 07:48:41 UTC
Permalink
Post by Benoît Minisini
Post by Rolf-Werner Eilert
Post by Benoît Minisini
Post by Rolf-Werner Eilert
Ok, I think I understand: With the help of ScrollX and ScrollY I have to
decide at which coordinate within my large drawing I start to draw to
1,1 on the DrawingArea?
Rolf
Yes. If you don't care with drawing everything at each draw event, it is
just a matter of translating the coordinate system with Draw.Translate().
Last evening I found that with Gambas3 under KDE nothing is shown in
ScrollArea and DrawingArea, the areas just stay cleared, but no error
occurs. When I switch them cached = TRUE it will crash with Sig #11
after some drawings, but the IDE doesn't crash. Under LXDE everything
works flawlessly.
Rolf
Which graphics system is configured for your Qt library: 'X11', 'Raster'
or 'OpenGL'?
Hmmm - before I go searching for an answer: Where can I verify that?

Rolf
Rolf-Werner Eilert
2012-01-17 07:48:11 UTC
Permalink
Post by Benoît Minisini
Post by Rolf-Werner Eilert
Post by Benoît Minisini
Post by Rolf-Werner Eilert
Ok, I think I understand: With the help of ScrollX and ScrollY I have to
decide at which coordinate within my large drawing I start to draw to
1,1 on the DrawingArea?
Rolf
Yes. If you don't care with drawing everything at each draw event, it is
just a matter of translating the coordinate system with Draw.Translate().
Last evening I found that with Gambas3 under KDE nothing is shown in
ScrollArea and DrawingArea, the areas just stay cleared, but no error
occurs. When I switch them cached = TRUE it will crash with Sig #11
after some drawings, but the IDE doesn't crash. Under LXDE everything
works flawlessly.
Rolf
Which graphics system is configured for your Qt library: 'X11', 'Raster'
or 'OpenGL'?
Hi Benoit,

I still don't know where to look for an answer to this. Frankly spoken,
I do not even know what you mean: Gambas' Qt library, or system's Qt
library?

Have a nice Tuesday

Rolf
Benoît Minisini
2012-01-17 09:01:20 UTC
Permalink
Post by Rolf-Werner Eilert
Post by Benoît Minisini
Post by Rolf-Werner Eilert
Post by Benoît Minisini
Post by Rolf-Werner Eilert
Ok, I think I understand: With the help of ScrollX and ScrollY I have to
decide at which coordinate within my large drawing I start to draw to
1,1 on the DrawingArea?
Rolf
Yes. If you don't care with drawing everything at each draw event, it is
just a matter of translating the coordinate system with Draw.Translate().
Last evening I found that with Gambas3 under KDE nothing is shown in
ScrollArea and DrawingArea, the areas just stay cleared, but no error
occurs. When I switch them cached = TRUE it will crash with Sig #11
after some drawings, but the IDE doesn't crash. Under LXDE everything
works flawlessly.
Rolf
Which graphics system is configured for your Qt library: 'X11', 'Raster'
or 'OpenGL'?
Hi Benoit,
I still don't know where to look for an answer to this. Frankly spoken,
I do not even know what you mean: Gambas' Qt library, or system's Qt
library?
Have a nice Tuesday
Rolf
The Qt graphics system defined how things are drawn on the screen by Qt:
- X11: by using X11 and XRender libraries.
- Raster: by doing everything in memory, and just blitting the result to
X11.
- OpenGL: by using OpenGL.

KDE has a entry for that in the control center on my Ubuntu, named "Qt
Graphics System".

It just modifies a shell script file named "qt-graphicssystem.sh"
located in ~/.kde/env. That script just defined the value of the
QT_GRAPHICSSYSTEM environment variable.

You can test your crashing application by defining this environmental
variable directory from a shell console:

$ cd /path/to/my/project
$ QT_GRAPHICSSYSTEM=raster gbx3

The value of QT_GRAPHICSSYSTEM can be "raster", "x11" or "opengl" (in
lower case).

Regards,
--
Benoît Minisini
Loading...