Ocean
Loading...
Searching...
No Matches
FrameView.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#ifndef META_OCEAN_PLATFORM_APPLE_MACOS_FRAME_VIEW_H
9#define META_OCEAN_PLATFORM_APPLE_MACOS_FRAME_VIEW_H
10
14
15#include "ocean/base/Frame.h"
16
17#ifndef __OBJC__
18 #error Platform::Apple::MacOS::FrameView.h needs to be included from an ObjectiveC++ file
19#endif
20
21namespace Ocean
22{
23
24namespace Platform
25{
26
27namespace Apple
28{
29
30namespace MacOS
31{
32
33/**
34 * This class implements a view displaying a frame.
35 * In general, the display performance/efficiency is not very good,<br>
36 * use GPU optimized solutions instead whenever performance matters.<br>
37 * @ingroup platformapplemacos
38 */
39class FrameView : public FlippedView
40{
41 public:
42
43 /**
44 * Default constructor creating an invalid media view object.
45 */
46 FrameView() = default;
47
48 /**
49 * Destructs this media view object and releases the medium object.
50 */
51 ~FrameView() override;
52
53 /**
54 * Move constructor.
55 * @param view View object to move
56 */
57 FrameView(FrameView&& view) noexcept;
58
59 /**
60 * Creates a new view object with specified size and dimension.
61 * @param rect The rect defining the size and dimension
62 */
63 explicit FrameView(const NSRect& rect);
64
65 /**
66 * Creates a new view object with specified size and dimension.
67 * @param left The horizontal start position of this view, with range (-infinity, infinity)
68 * @param top The vertical start position of this view in pixel, with range (-infinity, infinity)
69 * @param width The width of the view in pixel, with range [0, infinity)
70 * @param height The height of the view in pixel, with range [0, infinity)
71 */
72 FrameView(const int left, const int top, const unsigned int width, const unsigned int height);
73
74 /**
75 * Sets the new frame to be displayed.
76 * Internally, this function will create a copy of the frame buffer in the internal image object.
77 * @param frame The frame to be displayed, an invalid frame to display no frame
78 */
79 void setFrame(const Frame& frame);
80
81 /**
82 * Sets the new image to be displayed, actually the image will be moved.
83 * @param image The image to be displayed, will be moved, an invalid image to display nothing
84 */
85 void setImage(Image&& image);
86
87 /**
88 * Converts a 2D location defined in the view's coordinate system to a location defined in the coordinate system of the frame.
89 * @param viewPoint The 2D location within this view
90 * @return The corresponding 2D location within the image frame of the medium, a negative coordinate (-1, -1) in case the provided point is outside the frame
91 */
92 Vector2 view2image(const Vector2& viewPoint);
93
94 /**
95 * The draw event function actually displaying this view.
96 */
97 void onDraw() override;
98
99 /**
100 * Move operator.
101 * @param view View object to be moved
102 * @return Reference to this object
103 */
104 FrameView& operator=(FrameView&& view) noexcept;
105
106 protected:
107
108 /**
109 * Determines the location and size of the frame to be displayed best matching with the current size of the view.
110 * @param left The resulting horizontal start location of the frame within this view, with range [0, bounds.size.width)
111 * @param top The resulting vertical start location of the frame within this view, with range [0, bounds.size.height)
112 * @param width The resulting width of the frame within this view, with range [1, bounds.size.width]
113 * @param height The resulting height of the frame within this view, with range [1, bounds.size.height]
114 * @return True, if succeeded
115 */
116 bool determineFrameSize(unsigned int& left, unsigned int& top, unsigned int& width, unsigned int& height);
117
118 protected:
119
120 /// The image that will be displyed.
122
123 /// The lock for this view.
125};
126
127}
128
129}
130
131}
132
133}
134
135#endif // META_OCEAN_PLATFORM_APPLE_MACOS_FRAME_VIEW_H
This class implements Ocean's image class.
Definition Frame.h:1808
This class implements a recursive lock object.
Definition Lock.h:31
This class wrapps an MacOS NSView object and flips the coordinate system.
Definition FlippedView.h:38
This class implements a view displaying a frame.
Definition FrameView.h:40
Image image_
The image that will be displyed.
Definition FrameView.h:121
FrameView(const int left, const int top, const unsigned int width, const unsigned int height)
Creates a new view object with specified size and dimension.
FrameView & operator=(FrameView &&view) noexcept
Move operator.
bool determineFrameSize(unsigned int &left, unsigned int &top, unsigned int &width, unsigned int &height)
Determines the location and size of the frame to be displayed best matching with the current size of ...
~FrameView() override
Destructs this media view object and releases the medium object.
FrameView(FrameView &&view) noexcept
Move constructor.
void setFrame(const Frame &frame)
Sets the new frame to be displayed.
Vector2 view2image(const Vector2 &viewPoint)
Converts a 2D location defined in the view's coordinate system to a location defined in the coordinat...
Lock lock_
The lock for this view.
Definition FrameView.h:124
void setImage(Image &&image)
Sets the new image to be displayed, actually the image will be moved.
void onDraw() override
The draw event function actually displaying this view.
FrameView(const NSRect &rect)
Creates a new view object with specified size and dimension.
FrameView()=default
Default constructor creating an invalid media view object.
This class implements a wrapper for the NSImage object.
Definition platform/apple/macos/Image.h:38
The namespace covering the entire Ocean framework.
Definition Accessor.h:15