Transform scale relative resizing - resize

Is it possible to let the elements (next to the main element) adjust to the position it's scaling to?
My explanation may be terrible, but here is an image explanation.
So whenever i'm hovering on the main (middle) element. The padding on the left & right side will scale with it. See it as having an "relative" pop up of the image.

Keep track of the original left and right borders, say leftOrig and rightOrig. When you scale up, determine your new borders, leftNew and rightNew. Now all you have to do is shift the left element to the left by abs(leftNew-leftOrig), and do similar thing for the right.

Related

How could I create a horizontal UIPickerView style control?

I want to create a custom UIView that would be equivalent to a horizontal UIPickerView. The data elements, such as "Mountain View, Sunnyvale, Cupertino, Santa Clara, San Jose" would move left to right. The view would be long and thin. 50px in height, 350x in width sort of thing.
I will need to use protocols to obtain my datasource elements likely, but what I'm more interested in figuring out is the visual aspect of this.
How would I animate things left and right? Should I just make one incredibly long view (off screen), and change the frame left and right. This seems like a bad idea, as likely only 3-5 options need to be visible in the control at one time. If the datasource is 100 elements, there is no point in loading the other 95 off screen in a long view.
So perhaps I should load ~9 or something. The 3-5 on screen, plus an additional ~3 left and right. Each time the control is triggered to move left and right, it will load up another element on the view(?).
Is this a good way to achieve this? A long thin view with ~9 UILabel's. As the control moves to the right, I would shift the further left UILabel to move hidden to the far right, and change the UILabel to be the next in the data source.
I also likely want to change the text size based on its position. If it's currently selected, I either want to bold it and possibly increase the font size. How can I gradually achieve this as the view is moved? It would be weird if the text only changed once it was moved perfectly center inside the view. It should likely gradually grow as it gets closer to the middle.
How can I achieve this?
A collection view would do the trick, obviously there's some coding involved.
I'd suggest you to take a look at the code of, or use, the following library.
I've used it once,does almost exactly what you need and works very well:
AKPickerView

How do I expand a window to show more content in cocoa

I'm building an application in Cocoa and I want to be able to let the user click a button, which expands the window size showing content that was previously hidden.
For example, the top 68 pixels of my application show a summary of what is happening (like syncing data to a server) and there's a button off to the right that when clicked expands the window down and let's the user enter more information.
Problems I'm having are.
1) the background image I setup by subclassing NSImageView seems to be originated at the bottom left corner instead of the top left, so my button which should be over the right corner a the top of the background starts off over the right corner at the bottom of the background.
2) The window expands down and the button floats up. So the button starts at the bottom right corner and ends up at the top right corner. I want it to be in the top right corner always.
I think all of this would be solved if I could figure out how to tell the window to start at the top left corner and grow down, but not move controls around, simply hide them if the window isnt big enough.
Thoughts?
If I understand your question right then this should be it:
1) it is so because the coordinate system on mac is with the origin on bottom left. I think you should just move your image view up a little when you're resizing.
2) When you expand the window the buttons frame is based with the origin on the bottom left corner so again you will need to offset it when the view grows.
I think that by using auto layout and setting up the proper constraints things might be a little easier :)

Experimenting with responsive, absolute positioned child div... (eek!)

So,
I have a fairly simple parent div containing two child divs, one is text (floated left), the other contains an image (floated left against the first child)...the float of the second is kind of irrelevant (I just don't want it to drop down below). But what I want to achieve is for the image to sit in the bottom right of the parent and STAY there. At the same time I want it to be part of a fluid grid and for the distance from the bottom/right to also be responsive.
I tried absolute positioning (with an extra parent added around it to position:relative), which just didn't work at all...it could only be left/top positioned which then wouldn't work in %'s.
I then tried adding padding (top, left) instead of using positioning, thinking I could maybe push it into place...which worked great for keeping it to the right (pushing left), but obviously didn't work for the bottom (pushing from the top), as this value needed to increase as the screen decreased rather than the other way around (doh!).
Just wondering if anyone has any ideas or creative solutions?
I know I'm trying to do a number of tricky things all at the same time!!

Rectangles & Parsing in vb.net

This is kinda....a two part question. The first one is much more important than the second one, both of these are in the same project, and in vb.net.
How can I constrain the bounds of a rectangle object, which is controlled by a mouse, so it cannot be drawn outside a PictureBox? It is kindof a standard lasso control, the user can click and drag and it will draw a box from the initial click point to the mouse's current location. The starting point is at (rectX,rectY), and the box is drawn to the bottom right using rectDimX and rectDimY (to set the width and height) to see how much of a change has occurred with the mouse. Basically, its what you get with a click and drag on a Windows desktop. The issue here is that the rectangle is able to be drawn outside the PictureBox it is being drawn on, and the next part of the code attempts to reference this location, and then fails with an OutOfMemory exception. This leads me to my second question:
How can I make the rectangle draw in more than the fourth quadrant, which is only positive numbers? If it goes anywhere else, it does not show the rectangle, though it does still have the correct values. I know i could code this four times based on starting location and mouse location, but that would be a huge hassle and a rewrite of the whole rectangle code.
Is there an easy solution for either of these? The first one is a much bigger hassle, as it will be very time consuming if there is no easy way.
Thanks for the help!
For the first part of your question, even if the user drags the mouse beyond the edge of your picture box, you don't have to use those coordinates for your drawing routine. Simply do something like
If (DrawingPoint.X > PictureBox.Right)
DrawingPoint.X = PictureBox.Right // Right-hand limit of picture box
End If
And similar for the Y direction.
As for the negative numbers while drawing, you want to translate screen coordinates to client area coordinates. Have a look at ScreenToClient and ClientToScreen.

What's the RIGHT way to draw an image in the upper left corner on a mac?

I have an NSView in a ScrollView and I'm trying to draw an image in it. The problem is that I want the upper left corner of the image locked to the upper left corner of the frame, instead of the lower left corner, which is what the View wants me to do. I will need to be able to zoom in and out, and rotate.
currently, I have a kludge of a system where I calculate how much I have to translate my image based on the size of the image and the size of the window. In order to do this, I needed to create an extra view outside the scrollview, so that I could get the size of the window, not including decorations. Then I can calculate the size of the view based on the size of the image and the size of the window, and based on THAT, I can figure out where to translate the image to.
My only other thought was to use the isFlipped: method, but that ends up reversing my image L-R which is bad.
Is there another way I should be doing this?
If you want 0,0 to be in the upper-left corner, then overriding -isFlipped to return YES is the way to go. It should not affect the coordinate systems of any subviews (I think!), but images drawn directly into the flipped view will appear upside-down unless you apply a transform to them.
View Programming Guide for Cocoa: View Geometry