123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|644|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> On Topic -> Drag, Drop, Resizing rectangles

Sun, 03 Oct 2010, 13:38
dna
Here's the basic code. I'll flash it out later.



I wanted to know the basic way to achieve this using this code. No types.


-=-=-
DNA
Tue, 05 Oct 2010, 14:35
dna
On the Subject of resizing rectangles. How much of a border, drawn or not, should I allow for the so called grabbing edge?
In Pixels?

-=-=-
DNA
Tue, 12 Oct 2010, 13:04
Teasy
Cool colors!
That looks a bit like Zone66.

To be honest,
I have no idea what the purpose of your program is,
or what you want the purpose of your program to be.

Anyway,
I've made a little 'box control' program
that illustrates 'box management'
without the use of functions or objects

Maybe, just maybe ,
it is along the lines of your intentions


Tue, 12 Oct 2010, 21:05
dna
The purpose of my code quest was to write a program that places a rectangle, allows you to drag it, and allows you to resize it.

It is to be a part of something larger and I thought to not put the other crap on here to bog anyone down.

What I had previously listed was something akin to drag and draw rectangles.

-=-=-
DNA
Wed, 13 Oct 2010, 14:45
dna
Teasy.

Your code made me re think the whole process. I need to start over.

What I have here is not Drag and Drop, resize.
It's Drag and Draw.

-=-=-
DNA
Tue, 19 Oct 2010, 09:26
Teasy
Cool
Wed, 20 Oct 2010, 14:58
dna
your code never did anything. No Box no Nothing.
Thu, 21 Oct 2010, 13:20
Teasy
When I run my program I see 4 boxes,
each in the colors of your original program.
And when I hover my mouse over the boxes,
a white border is displayed over them.

My program illustrates how to use boxes
without the use of functions or objects.
Are you looking for an example program
of dragging and resizing?

Maybe if you express what you really want,
it is easier for me (or anyone else) to help you.
Help me help you

Here's a few old programs
that illustrate some things
you may be looking for

First, a simple program
in which you can create boxes
by clicking and dragging the mouse.



Next up, a program
where you can drag
a single box
around the screen.



And finally, a program
illustrating multi-window dragging
using objects.



Sat, 23 Oct 2010, 12:02
dna
I forgot all about this thread.

Here's the code I made:


This does part of what I need. This is what I meant.
Next comes the resizing of the thing.

Those tutorials are good but they all have that 'SNAP' to center move that some people do not like. I corrected that in my code with:

X_1=MX-XX1:Y_1=MY-YY1

and then used:

Rect MX-X_1,MY-Y_1,R_WID,R_HEI,1

to set the rect at the new position with the mouse in the same offset spot that it was grabbed.


-=-=-
DNA
Sun, 24 Oct 2010, 09:08
Teasy
Cool that you were able to use the code
and modify it to your liking/needs

I've taken the liberty to modify your code
introducing the following primary benefits:
- A single loop/IF statement
  for the entire mouse-box-drag algorithm
- Preventing the mouse-drag from starting
  when entering the box

I've provided some comments
to go along with the algorithm in the code
so I hope you'll understand what's going on

And I also hope that you'll find something in here
that you can use


what a drag 2a-tc1.bb

Sun, 24 Oct 2010, 10:48
dna
I did not modify that code. I wrote it before coming back to this thread.

However, put the code that you commented into the archive it's a good tutorial.


-=-=-
DNA
Sun, 24 Oct 2010, 13:37
Teasy
Naah, but thanks for the suggestion
Sun, 24 Oct 2010, 14:41
dna

I put it in the code archive.

The version with your comments.

-=-=-
DNA
Sun, 24 Oct 2010, 19:22
dna
Here's something odd. I run the code and it works fine until something causes the variables to jump inside of the set minimum width that I set.



i cannot figure it out.

-=-=-
DNA
Mon, 25 Oct 2010, 13:02
dna
That odd occurrence with resizing the right side may have been caused by my wireless mouse.

If someone else uses a wireless mouse, try resizing the right side and releasing at odd angles to see if you get a box that is smaller than the designated minimum.

Still cannot find out why.

-=-=-
DNA
Tue, 26 Oct 2010, 18:04
Teasy
(i'm using a wired trackball ^^)

* SetBuffer BackBuffer
i'm curious why you're calling SetBuffer BackBuffer() so often and in many places,
so i've decided to remove them and place a single statement at the top of hte program

* Flip : Cls
i've moved around some Flip:Cls statements to accord for the in-loop flipping and correct updating of the screen

* DX/DY
i've added DX and DY which indicate a minimum drag 'snap' for the sides, so that u dont have to click on the exact pixel ^^
i've simply replaced ur -2 and +2 with -DX and +DX

* Order
i've moved the top section of ur program to the bottom, so it removes the flicker before/after some actions.

* Resize indicator
i've remarked the indicator in the main loop, and placed new ones inside the other loops.
this way u can customize each indicator (resizing left/right) and it clarifies the code
to make it work, i've separated the mousedown(1) from each IF.
and i've placed the mousedown(1) below the mouse position check.

* Debug
to figure out 'wtf' was going on, i've added a Gosub to some simple code showing some stuff on the screen.
for example the coordinates, sizes, mouse and such.
and i've placed this gosub in every loop, along with a loop variable to show in which loop the code is

* Side drag from any height
i've noticed that u can drag ur box from any vertical position.
i assume u'd like to resize ur box when the mouse is near the box.
so i've added another IF check to see if mouse Y is within box pos/size.

* Right side dragging box vanish
when u drag the right side left, it doesn't seem to update the rect.
it sometimes disappears too ^^

to put it simply, what happens there, is that u can drag it all the way left, because it only changes the displaying of the rect -- not the values.

so, i've placed the Rect outside the IF, so it shows always.
and inside the IF i have placed a MoveMouse call so that u can't move ur mouse further left ^^

and i've changed the >= to a <= so that it forces the pos on the left, instead of the right.
i guess for the left side, u can simply reverse this

* Left side resize
i haven't fixed the (similar) prob here; i leave that up to u ^^



just for fun, i've made another prog
to illustrate how easy it is, or can be,
to make a single box drag program
which includes resizing

this program can also give u some clues
for various things in your program

i hope u enjoy
(if no joy, why do it? )



Wed, 27 Oct 2010, 08:13
j\\'ordos
The rectangle sometimes disappears completely while resizing (using wireless logitech mouse)
Wed, 27 Oct 2010, 13:18
dna
This happens in my Code!!!

If so, then let me know where it happens or if it is another bug in BB.


-=-=-
DNA
Thu, 28 Oct 2010, 16:42
j\\'ordos
Yes that happens in your code. I think Teasy already identified the problem no?
Thu, 28 Oct 2010, 18:31
dna
Oh. I see what you mean. The disappearing rectangle never happened in my code.
There was just some odd resizing that happened on the right side.
That disappearing rectangle is in his code only.

That Jitter in Teasys code is also not in mine. Mine works fine except for the odd resizing at odd times.
The resizing is not consistent and so could be the mouse.
maybe not.
If it's in the code then it would be in the right resize loop.


-=-=-
DNA
Mon, 01 Nov 2010, 15:28
Teasy
It sounds, to me, like your mind is in a loop, DNA
Press the 'Untangle' button to unwind, relax and enjoy