Help with level editor user interface
Felix-The-Ghost

(Note file attached)
I'm drawing four overlapping tabs onto the screen in different stacking orders depending on which one is selected. It's functional, but it has slight graphical errors. The tabs are currently and I'd like to keep them all as sub-bitmaps; I have a colored spacing betweeen them in the mother bitmap which shows on the screen unwanted. There is also a red border to the tabs that doesn't always show and the tab labels run together making them harder to read. If you don't understand what I'm doing download the zip and look at the Goal Preview.bmp inside.

Edgar Reynaldo

The left hand panel doesn't really have enough room for the tabs. Why not just use a set of four buttons in a 2X2 arrangement? You've got a little extra vertical space above the 'SuperCoolMap' map name display and you could take a little vertical space from the tile selection area. That already has a scroll bar anyway.

I'm not sure what the actual problem you're having is though, at least I don't see it in the 'Goal Preview.bmp' file.

LennyLen
Quote:

I'm not sure what the actual problem you're having is though, at least I don't see it in the 'Goal Preview.bmp' file.

He means this:


{"name":"596593","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/7\/e77773d4d755a9640385bd174f52c077.png","w":718,"h":502,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/7\/e77773d4d755a9640385bd174f52c077"}596593

Your code is too convoluted for me to bother fully reading, but this stands out:

Click_X_Spawn[0]=124; Click_X_Spawn[1]=170;

The leftmost pixel is 124, and the rightmost is 170.

Then:

masked_blit(Tab_Spawn[1], Buffer, ((Click_X_Spawn[0]+1)-125), 0, Click_X_Spawn[0]+1, TabArea_Y[0]+1, ((Click_X_Spawn[1])-(Click_X_Spawn[0])+1), 15);

So you're blitting width = 170 -124 + 1 = 67, yet the width of that tab on the master bitmap is only 65 pixels.

Edgar Reynaldo
Quote:

He means this :

I don't see anything wrong with the picture he said to look at, other than overlapping tabs and that's a design preference he chose, so what am I supposed to be seeing? The only thing I see in your picture is some purplish lines between the second and third tabs, and the third and fourth tabs which isn't in the picture he said to look at as an example.

LennyLen
Quote:

I don't see anything wrong with the picture he said to look at, other than overlapping tabs and that's a design preference he chose

I got the impression that the overlapping wasn't intentional.

Quote:

The only thing I see in your picture is some purplish lines between the second and third tabs, and the third and fourth tabs which isn't in the picture he said to look at as an example.

It's not in the supplied .bmp, which is why I made the image I posted.

I'm fairly certain that all the problems - the overlapping, the purplish lines, the sometimes missing red border - are due to incorrect hard-coded values in the code, and the way in which the tabs are drawn. I was able to remove the purplsh lines by changing some of the hard-coded values. But changing these meant that some of the other positions were off.

Felix-The-Ghost

I hard-coded as least as I possibly could, I kept the Y coordinates that way because they weren't meant to change. The preview Goal.bmp is the correct way I want. Sorry my code is confusing in that area...:-[
And yes LennyLen the purple is a problem but if you click on some of the other tabs(like the options one) the red border for some disappears. Overlapping is intentional.
The were drawn by blitting only parts of it based on the "Click_X..." values it had. These values changed when a different tab was clicked.
If you guys are having trouble knowing what I want each tab to look like when its selected I can upload an image.
I'll look at those values again because the Click_X_'s were always one more or less than wanted so I could use mx < Click_X_value
but I could use <= and that would be easier for the blitting area.
edit: the code tags changed my underscores to spaces. :P

LennyLen
Quote:

And yes LennyLen the purple is a problem but if you click on some of the other tabs(like the options one) the red border for some disappears.

I'm guessing that some of the other 'x' values are also incorrect. Where you're not getting the border, it's because you're blitting too small a width, and where you get the purple, it's where you blit too great a width.

Felix-The-Ghost

Okay I finally got it working correctly after a bunch of bull ship in MS Paint.
I edited a minor error in the tabs.bmp and had to change how I made the sub-bitmaps accordingly. I changed the values of the X's and changed all < > to <= >=

I will keep this thread though in the event I need more help, but I have a lot of it thought out and don't expect too many problems.

edit: I tried to add a new function and it's giving me errors but I don't see what's wrong with it...

here's the declaration
void draw_damaged_block(BITMAP *destination, BITMAP *source, int damage_level);

here's the definition

void draw_damaged_block(BITMAP *destination, BITMAP *source, int damage_level)
{
     //to do
}

there currently aren't any function calls at this time.

It says I didn't declare any of the function variables in the scope but I never had to before...

LennyLen
Quote:

It says I didn't declare any of the function variables in the scope but I never had to before...

Can you attach the full code?

Felix-The-Ghost

I thought I might do that...
I've done similar things before, so I don't know what went wrong...
hang on a sec...
attached
I hope that's the right one. I really need to clean up my flash drive a bit lot.

LennyLen

The problem is that you include your header file before you include allegro.h, and your header refers to the BITMAP structure. Either swap the order of the includes in main.cpp, or include allegro.h in DecAndProt.h.

Felix-The-Ghost

oh whoops... :P
yes I remember specifically removing that line because I had no need for it at the time. I thought it'd be something simple that I messed up. It would've taken me a while to remember that though :P

edit: okay I went a step further and something is crashing the program.
Basically what I am doing:

Declare a bitmap
during the init_program() I make it equal to create_bitmap(etc)
I clear the bitmap to the mask color
I make a call to a function that is supposed to draw tiles onto this bitmap
the bitmap is drawn onto the buffer
buffer is drawn to the screen
death. crashed program.

I tried a lot of rearranging and substituting but it keeps crashing and when it doesn't it's because I'm not drawing it to the buffer :P
No error messages...

Can a problem be diagnosed or should I upload the new code?

LennyLen
Quote:

Can a problem be diagnosed or should I upload the new code?

Always upload the code. ;)

edit: don't worry about attaching the bitmaps, just the .cpp and .h file.

Felix-The-Ghost

I think it'd be easier with them... but okay.
I'll have to do it tomorrow though it's like 10:30 here and I'm tired and have to wake up early :(

LennyLen
Quote:

I think it'd be easier with them... but okay.

I already have them from last time.

Felix-The-Ghost

But I added more... Anyways here you go. Assuming you want a smaller size I did not include the alleg24.dll. [attached files]
sorry I did not compress them. I ended up putting them directly on my flash drive. I'm very tired right now and don't feel like going back to change it. I have to work on something else right now. Thanks for helping.

LennyLen
Quote:

But I added more...

Ah, well the extra graphics would be handy then. ;)

Felix-The-Ghost

Gosh I need to get internet on my programming computer...I need to go get the files now...It'd help if you said what was missing. I think you need the "~broken" and "~brick" right? Are there anymore? Well, actually the "~broken" one isn't being used just yet. It was but it crashed right before I could implement it.

edit: done.

LennyLen

I did have all the graphics, but it didn't really matter. The problem was easy to spot:

return (0); // A return code of 0 indicates no errors
  
/**/BlockSelectionBuffer = create_bitmap(202, 247);
    clear_to_color(BlockSelectionBuffer, makecol24(255, 0, 255));
    if (BlockSelectionBuffer)
    {
    allegro_message("Failed to create the memory bitmap \"BlockSelectionBuffer\"");
    return (16);
    }

You return from the function before you create BlockSelectionBuffer, so when you go to use it later, the program crashes.

You should also place the clear_to_color() line after the if (BlockSelectionBuffer) line, since if the bitmap hadn't been created, trying to clear it will crash.

edit: Oh, and it should be if (!BlockSelectionBuffer) not if (BlockSelectionBuffer)

Felix-The-Ghost

Woah that was in my code? I should've noticed the forgotten bang. Well you know what I mean. Also I messed up big with the return :P
Going to bed here, like 10:46 and I wake up early. I'll try to fix iot it tomorrow. Thanks. That's another thing I can add to my "common mistakes I make" list

Tobias Dammers
Quote:

a bunch of bull ship isn MS Paint.

There, fixed that for you.

Felix-The-Ghost

I couldn't find the post where I said that. Why are you pointing that out?
Also I remember specifically removing the bang to see if the error message would appear, and it didn't which was weird. I should've realized that that part of the code wasn't being executed.

Martin KalbfuƟ

You said that in post 8.

Maybe he wants to say that using ms paint is not the best choice.

Felix-The-Ghost

Oh, it looked like he was pointing out a typo...MS Paint is underrated and to fully harness it's ability requires skill.

However...
I fixed up the code and I get an "access denied, Id returned 1" from DevCpp. I don't know what's wrong. I restored it to it's original state and I still get the error. It doesn't do this with other projects though. I don't remember tinkering with any options either... Should I just delete the makefile and let it remake it?

Edgar Reynaldo

Check the running processes through Task Manager and see if the program is still running in the background. It can happen fairly often with programs that crash.

Felix-The-Ghost

Right, okay I'll do that. See I had to reset it several times yesterday. I really hope it's not still running from then O_O edit: thanks, Edgar. You hit the nail on the head, I had like 4-5 of them still running. I'm surprised my computer did not die a horrible death. Some of them looked like the processes weren't using much to run though... Anyhow it's working as I intended it to now :) hey you know whats pretty cool when you put two bangs !! its like they're not there

-----------------------------------------------------------------------------------

Okay I need help again.
I got the above to work although I edited commented out some of it's code so I can work on getting a working scrollbar. I am trying to take advantage of a ratio:
full bitmap size / view size
should equal
scroll area / scrollbar

I thought I had the math part right but it's drawing slightly off. It looks fine at first, but when scrolled all the way down the scollbar overlaps the button :P

I have the function at the very bottom; draw_scrollbar.
Any help would be appreciated.
And sorry if you think the code is messy. I usually do tests like these before cleaning up the code.

I think it's calculating the X wrong, but I think the stretched width is correct.

Edgar Reynaldo

I haven't looked at the code, but don't forget to scale the offset for the position of the top of the scrollbar as well. That could be why it overextends. Another consideration is that you need to track the offset of the mouse click on the scrollbar and record it when you start to drag the scrollbar so it doesn't move too far in either direction.

Felix-The-Ghost

Heh. I can tell you didn't look at the code :P
Thanks for helping though. See I haven't tried to get the scrollbar to function yet...I was just getting it to show the view position accurately. The only way to scroll right now is the buttons. Also the view is vertical scrolling, but the scrollbar is horizontal scrolling. Weird I know, but I like the idea. If you do look at the code, the function is on the very bottom.

But why would I need to scale the offset? I'm using stretched blitting so it just has the first x,y and the width and height, which are relative to the first x and y. So if I got the x wrong...the whole thing's wrong.

LennyLen

I took a look at the code, but your program is getting so big now (especially for a single file project) that trying to figure out exactly what you're doing is difficult. It doesn't help that some of the variable names you're using aren't very descriptive.

If you can isolate the scrollbar code into a new smaller project, then it would be easier to help you, and when the problem is sorted, you can fix it in the main project.

This might also be a good time to break your code down into smaller modules, before it gets too big to work with easily.

Felix-The-Ghost

Do you mean I should permanently separate it or just for the sake of easy aid? What sort of things to people usually separate? I was thinking about getting the bitmap loading into a new file but I didn't really know how I'd do that. I can try to make a new program with the scrollbar code if that's what you want. Thanks. Oh and which variable names aren't descriptive? Some of the vague ones should have comments next to their declarations if that helps. I don't remember having any ridiculous ones though...the worst is that some of them are similar, such as Scrollbar->w and Scrollbar_Width. The first is the length of the bitmap file, the second is the width of the stretched scrollbar.

LennyLen
Quote:

I can try to make a new program with the scrollbar code if that's what you want.

That's what I meant, yes.

Quote:

What sort of things to people usually separate?

It varies from project to project, but for yours, I'd initially seperate it into the 'main' module, which contains your main() function plus your variable definitions and your initialization routines; a 'drawing' module; and a 'logic' module. You can then break these down further if necessary.

edit:

Quote:

Oh and which variable names aren't descriptive?

TestClipT and TestBuffer were the two I was thinking of.

Edgar Reynaldo
Quote:

What sort of things to people usually separate?

I separate things that are easily recognized as discrete objects or ideas. In effect, things like widgets, sets of data, data manipulation, generic i/o handlers, etc...

When you asked me about why the scrollbar offset should be scaled, I was talking about the offset of the drawing position of the scrollbar handle in relation to the scrollbar area.

Felix-The-Ghost

I don't know how I'd do that...
Would I use the same ratio?

Also would there ever be a need to group related variables? I sort of did that with this code but they are still all in the same file. Should I make the functions separate like put them in another .CPP? If I include the file in the DevProject it'll arrange it the necessary way automatically?

Oh and LennyLen, TestBuffer is the name of the loaded bitmap that is clipped. Look in the part where it loads bitmaps, probably one of the last ones. The TestClipT stands for TestClipTop; it represents the top of the clipping area of the TestBuffer(which is drawn at the top of the view area). I increase this by one (with limits) when the scrollbutton is clicked, and blit with this variable and a fixed height to produce a clipping effect. Once I get the scrollbar working I'll actually remove TestBuffer and related and just hard-code the drawing of tiles onto a new one, so when there are updates the scrollbar remains relative with the ratio.

I guess I'll get started with a new one since I already had gotten decent dragging support for the bar and a splash screen. I'll strip all the other functions off though.

edit: attached the stripped down version. I removed everything except the splash screen, because it's sexy :)

drag the scrollbar as far as it goes, then click the scrolldown button and you'll see it goes a little further.

Edgar Reynaldo
Quote:

Would I use the same ratio?

Yes. All you need to do is find the ratios for :
a) The total length of the object being viewed (including the non-visible portion) to the total length of the scrollbar area (not including buttons).

b) The length of the visible portion of the object being viewed to the total length of the viewable object.

The ratio of (a) is your stretch factor in that dimension. The ratio of (b) times the length of the scrollbar area gives you the length of the scrollbar handle.

The scrollbar handle's offset divided by the ratio of (b) gives you the actual size of the viewing object's drawing offset.

It's best to just draw out the design on paper first, and then when you know what you're doing, put it into code. That method helps me finish things anyway.

Quote:

Also would there ever be a need to group related variables? I sort of did that with this code but they are still all in the same file. Should I make the functions separate like put them in another .CPP?

Well, it would probably help you to make a separate module for your map data and methods, a map class that knows which tiles can be in it and holds an index to a tile list for each position in the map. Another module could be used for your editor. A third module could be for a tileset class, that's used by your map class and your editor class, etc...

Felix-The-Ghost

Okay I get it, very distinct things get grouped together.
like...

drawing everything
editor mouse logic
map area mouse logic
saving/loading
reset/clear all

?

Also I'll try using the ratio...I thought I tried it before but it didn't work...maybe I used the wrong one. I sketch math based things on paper too. Or MS Paint.

edit: okay this is not working out so well...

1////// CHECK MOUSE ON SCROLLBAR //////////
2 ScrollRatio = (TestBuffer->h / ScrollArea); //ratio of the entire bitmap's height to the scrollbar area's length
3 ViewRatio = (TestBuffer->h / TestClipHeight); //ratio of the entire bitmap's height to the visible portion
4
5 if (my <= (Scrollbar_Y_Offset+Scrollbar->h) && my >= Scrollbar_Y_Offset && mx <= (Scrollbar_X_Pos+Scrollbar_Width) && mx >= Scrollbar_X_Pos && (mb & 1) && !(old_mb & 1) && Scroll_Active == false) //if left mouse is clicked over the scrollbar
6 {
7 Scroll_Active = true;
8 Scrollbar_Clicked_X = (mx-Scrollbar_X_Pos); //relative X position
9 old_mb = mb; //initialize
10 }
11
12 if (Scroll_Active == true)
13 {
14 if (mb == old_mb) //if the button hasn't been let go
15 {
16 Scrollbar_X_Pos = (mx-Scrollbar_Clicked_X);
17
18 if (Scrollbar_X_Pos < Scrollbar_X_Offset)
19 {
20 Scrollbar_X_Pos = Scrollbar_X_Offset; //don't expand past the left button
21 }
22 if ((Scrollbar_X_Pos + Scrollbar_Width) > (Scrollbar_X_Offset + ScrollArea))
23 {
24 Scrollbar_X_Pos = (Scrollbar_X_Offset + ScrollArea - Scrollbar_Width); //don't expand past the right button
25 }
26 TestClipT = ((Scrollbar_X_Pos - Scrollbar_X_Offset) * ScrollRatio);
27 }
28 else
29 {
30 Scroll_Active = false;
31 }
32 }
33}

void draw_scrollbar() //draws a scrollbar of [in]correct scale
{
    ScrollRatio = (TestBuffer->h / ScrollArea); //ratio of the entire bitmap's height to the scrollbar area's length
    ViewRatio = (TestBuffer->h / TestClipHeight); //ratio of the entire bitmap's height to the visible portion
    Scrollbar_X_Pos = (TestClipT/ViewRatio)+(Scrollbar_X_Offset/ScrollRatio);
    Scrollbar_Width = (TestClipHeight/ViewRatio);

    stretch_sprite(Buffer, Scrollbar, Scrollbar_X_Pos, Scrollbar_Y_Offset, Scrollbar_Width, Scrollbar->h); //having difficulties here
     
}

I used to use just one ratio; big to small. I thought (TestBuffer->h / ScrollArea) was the same as (TestClipHeight / Scrollbar_Width)
gosh why does the code tag stretch the page on my computer...?

Edgar Reynaldo

Don't use integer division. Convert to doubles and get a double type ratio.

Felix-The-Ghost

Would that fix it? So you mean just put
double(int x) * double x ?
I think I had already set the ratios as doubles, but you mean with everything else, right?

Edgar Reynaldo
Quote:

Would that fix it?

It will get rid of the inaccuracy caused by clipping of the fractional part. Is that the only thing wrong? I don't know, but I can try looking over things more tomorrow.

Store the ratios as a double, use temporary doubles or casts to prevent the integer division.

//
int a = 12 , b = 5;
double atob = double(a)/double(b);// using double constructors
double atob2 = (double)a/(double)b;// using casts to double type

int also_a = int(atob*double(b));// may not actually get exactly 'a' back
                                 // due to floating point inaccuracy
//

Please try to be consistent in your formatting schemes, it makes it a lot easier to read code if you do. (Don't mix tab indentation with space indentation, always indent when there is a new block {})

Felix-The-Ghost

?
I use DevCpp. When I indent with the tab button it adds a lot of spaces, or at least it seems so because I often highlight them individually and delete some to make the indents even. Where did I not indent at a new block? I didn't see it, although that new code was just the old one after deleted a lot of stuff. I guess I'll start cleaning up my code before I post it here.
What are atob and atob2?
And when I tried casting doubles it made the scrollbar over-expand in both directions.

Edgar Reynaldo
Quote:

I use DevCpp. When I indent with the tab button it adds a lot of spaces, or at least it seems so because I often highlight them individually and delete some to make the indents even.

DevCpp may have a setting to control the number of spaces that a tab press will indent. CodeBlocks certainly does, but if there are tabs in the source code then you have to look at arrows every place there's a tab so I just replace them all with 2 or 3 spaces depending on what I'm coding for.

Quote:

Where did I not indent at a new block?

Things like this (from your last code posting) :

            if (Scrollbar_X_Pos < Scrollbar_X_Offset)
            {
            Scrollbar_X_Pos = Scrollbar_X_Offset; //don't expand past the left button               
            }

Quote:

I guess I'll start cleaning up my code before I post it here.

If you get in the habit of always doing your formatting consistently, you'll never have to 'clean it up'.

Quote:

What are atob and atob2?

The ratio of a to b and a second method to find the same ratio. Just an example.

Quote:

And when I tried casting doubles it made the scrollbar over-expand in both directions.

Okay, so let's see what your code is now.

Felix-The-Ghost

Yeah, I format my main code consistently, but I mean for stuff like this I usually just throw the required/important things together with minimum editing because I don't plan on reusing it. That's where I forgot to reindent after deleting some other blocks that weren't needed(yeah I copy+pasted if I was typing it it would have looked better :). So does atob stand for something? I'll get the new code on here. I'll fix it up first too. :P

someone972

It goes too far left because you scale the offset, this should remain the same.

Scrollbar_X_Pos = (double(TestClipT)/ViewRatio)+(double(Scrollbar_X_Offset)/ScrollRatio);
//should be 
Scrollbar_X_Pos = (double(TestClipT)/ViewRatio)+double(Scrollbar_X_Offset);

The ViewRatio should be calulated using ScrollArea.

ViewRatio = (double(TestBuffer->h) / double(TestClipHeight));
//should be
ViewRatio = (double(TestBuffer->h) / double(ScrollArea));

This works correctly for me. It should stay where it is supposed to now.

Felix-The-Ghost

Gosh you edited your post... :-/
I was all trying to using the width like you said. :P
But...Edgar said to scale the offset...
wait let me try this.
If you calcuated ViewRatio using ScrollArea, then what did you calculate ScrollRatio with?

someone972

Ya, sorry about that. I was rapidly changing my post as I figured things out, at the end removing all the unnecessary pieces hoping you hadn't seen yet.:-X
EDIT: Hmm, I changed a lot, let me see what the original was and then I tell you what I was sopposed to change.

It appears as though you only need to change ViewRatio to Scroll Ratio in the width area and change the X position as stated above.

ScrollRatio = (double(TestBuffer->h) / double(ScrollArea)); //original
ViewRatio = (double(TestBuffer->h) / double(TestClipHeight)); //original
Scrollbar_X_Pos = (double(TestClipT)/ViewRatio)+double(Scrollbar_X_Offset); //changed this
Scrollbar_Width = (double(TestClipHeight)/ScrollRatio); //and this

EDIT2: sorry again, I'm changing this too.

Felix-The-Ghost

Can you scroll all the way to the right and tell me if the is a little gap there? I edited mine and there is a little pixel gap. It scrolls and clicks the buttons the same now though. I wonder if I misunderstood Edgar. So you're saying that ScrollRatio and ViewRatio are actually the same now? That's what I was saying earlier...

Quote:

I used to use just one ratio; big to small. I thought (TestBuffer->h / ScrollArea) was the same as (TestClipHeight / Scrollbar_Width)

also is this page stretched to you?

Can you post again instead of editing please for clarity?

someone972

Okay this one should work this time:

Scrollbar_X_Pos = (double(TestClipT)/ScrollRatio)+double(Scrollbar_X_Offset);
Scrollbar_Width = (double(TestClipHeight)/ScrollRatio);

The Ratio's are the same as in the original file you posted. The pixel gap is there because ScrollArea is 184 and should be 185 I think.

EDIT: This way seems to continue to work properly when the scroll area is increased.

Felix-The-Ghost

gosh so many edits...
anyways I edited the original file. You can drag the scrollbar correctly...but something you haven't checked is when I calculate TestClipT inside of mouse_logic(the part when you drag the scollbar, not the buttons). Because it is calculated wrong I can click the scroll down button even when it is at the maximum allowed position.

someone972

I guess I don't understand the problem now. Perhaps all my edits got something changed that wasn't supposed to be. Check my binary that's attached and see if it works as desired. If it does I can give you the right source.

Felix-The-Ghost

Huh. Yeah that works as I intended. Perhaps you changed something else I didn't?
Also I edited the original source where it looks like you edited the new one. I'll have to see what's different.

someone972

Ok, sorry it took so long to reply, I've been watching COPS. The only function I changed is the draw_scrollbar, here is the one I am using:

void draw_scrollbar()
{
    ScrollRatio = (double(TestBuffer->h) / double(ScrollArea));
    ViewRatio = (double(TestBuffer->h) / double(TestClipHeight));
    Scrollbar_X_Pos = (double(TestClipT)/ScrollRatio)+double(Scrollbar_X_Offset);
    Scrollbar_Width = (double(TestClipHeight)/ScrollRatio);

    stretch_sprite(Buffer, Scrollbar, Scrollbar_X_Pos, Scrollbar_Y_Offset, Scrollbar_Width, Scrollbar->h);
};

I have also attached the entire source file if changing that doesn't work.

Felix-The-Ghost

Okay thanks. I'll have to try it later though. I don't mind a slow reply. At least I got one :P

edit: Yes, I got it to work! It wasn't exactly copy+paste though :P Also I fixed a standing bug where if you just rapidly clicked on the scrollbar it'd scroll one pixel to the left each time. I bet you editing the timing for the splash screen huh? :P I'll need to code a way to push enter to skip it. :P just like in real games :P

someone972

Ya, I shortened it, mainly to be able to test changes quicker. Glad to see that you got it to work.

Edgar Reynaldo
Quote:

But...Edgar said to scale the offset...

Well, the offset does need to be scaled, at least one of them to the other anyway. The offset for the displayed portion of the view is in a ratio to the offset for the scroll bar handle. Sorry if I took you off track with that.

Quote:

I wonder if I misunderstood Edgar. So you're saying that ScrollRatio and ViewRatio are actually the same now?

Perhaps I wasn't very clear. There are two ratios involved overall, but only one that gives you the position of the scroll bar handle or the viewing offset.

Use of ratio 1 (ObjectLength to ScrollBarAreaLength) :

<math>ViewOffset = ScrollBarHandleOffset*\frac{ObjectLength}{ScrollBarAreaLength}</math>

Use of ratio 2 (ViewLength to ObjectLength) :

<math>ScrollBarHandleLength = ScrollBarAreaLength*\frac{ViewLength}{ObjectLength}</math>

However, the ScrollBarHandleLength can also be expressed using the inverse of ratio 1 :

<math>ScrollBarHandleLength = ViewLength*\frac{ScrollBarAreaLength}{ObjectLength}</math>

So in a sense, there is only one ratio. Sorry if I mixed you up.

I guess the important things to remember are :

<math>ViewOffset*ScrollBarAreaLength = ScrollBarHandleOffset*ObjectLength</math>

and

<math>ScrollBarHandleLength*ObjectLength = ScrollBarAreaLength*ViewLength</math>

In any case, glad you and someone972 have it working now.

Felix-The-Ghost

Thank you Edgar :)
I'm not too advanced yet :)

Edgar Reynaldo

Don't feel bad, I've spent far more hours trying to get this Saturation Value triangle implementation done for karistouf's color picker thread than it should be taking me. We've all got our own stuff to learn.

Your new sig said:

I want to change the world...
...but they won't give me the source code

Gotta reverse engineer it...

Thread #597844. Printed from Allegro.cc