Skip to content
This repository has been archived by the owner on Nov 5, 2022. It is now read-only.

Container for image #95

Closed
DoctorovEV opened this issue Apr 6, 2015 · 8 comments
Closed

Container for image #95

DoctorovEV opened this issue Apr 6, 2015 · 8 comments

Comments

@DoctorovEV
Copy link

There is a need to realize the similarity of the graphic editor. Need a container for images, but not the main window. What realties like Canvas. What do you advise?

@ben-clayton
Copy link
Contributor

I'm not sure I entirely understand the question. Are you asking for a control that can be used to draw a Canvas? If so, I could add a Canvas getter / setter to Image without much difficulty.

@DoctorovEV
Copy link
Author

There is an example Polygon.
All images are placed in a container Window. But it is inconvenient. I would like to have a container is to control. Let's call it like DrawCanvas. This control can be placed in any area, such as PanelHolder. This makes it possible to put into it is full of controls Image and other types of imaging.
Have a similar class in C ++, - TCanvas, for outputting and storing graphic objects.
For example: https://msdn.microsoft.com/ru-ru/library/system.windows.controls.canvas(v=vs.110).aspx

@DoctorovEV
Copy link
Author

Ben, tell me, I made it clear to you a question?

@ben-clayton
Copy link
Contributor

All images are placed in a container Window. But it is inconvenient. I would like to have a container is to control.

Yes, in the Polygon sample, all child Image controls are added as children to the Window, but there's nothing stopping the Images from being placed into other Containers such as a LinearLayout.

It's still not completely clear to me what you're asking. If you'd like more control over what's displayed in an Image, then I think it's not too hard to add:

   Canvas() Canvas
   SetCanvas(Cavas)

to the Image interface. These would probably replace the existing Polygon properties.

I hope I'm closer to answering your question.

@DoctorovEV
Copy link
Author

LinearLayout is a Container that lays out its child Controls into a column or row.
LinearLayout does not allow to place items on top of each other as in a container Window.
How to make a simple graphical vector editor? What use container for imaging?

@DoctorovEV
Copy link
Author

Ben, I made the following changes.These changes gave the desired result.

  1. gxui\direction.go
    1.1 const (
    TopToBottom Direction = iota
    LeftToRight
    BottomToTop
    RightToLeft
    TopToTop
    )
    1.2 func (d Direction) TopToTop() bool { return d == TopToTop }
    1.3 func (d Direction) Orientation() Orientation {
    switch d {
    case TopToBottom, BottomToTop, TopToTop:
    return Vertical
    case LeftToRight, RightToLeft:
    return Horizontal
    default:
    panic(fmt.Errorf("Unknown direction %d", d))
    }
    }
  2. parts\linear_layout
    2.1 section Perfom layout
    case gxui.TopToTop:
    c.Layout(c.DesiredSize(math.ZeroSize, s).Rect().Offset(o))

@ben-clayton
Copy link
Contributor

Okay, I think I'm finally understanding exactly what you're asking for. This does kind of layout does not belong in LinearLayout, instead it should probably be a new AbsoluteLayout.

Regardless, I still believe what you're wanting is a SetCanvas method on Image. Stacking Image controls is an inefficient way to layer polygons. If you had Image.SetCanvas, you would be able to draw layered polygons, rects and fonts all into one canvas, then pass that composed image on to one Image control.

I'm crazy busy with work at the moment, but if this gives you what you need, I'll try and implement this for you soon.

@ben-clayton
Copy link
Contributor

Please take a look at the new polygon sample code. This should show you how you can layer polygons by drawing them to a Canvas, completing the canvas, then passing the complete Canvas to the Image.

Let me know if this still doesn't solve your issues.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants