Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/glfw/video-driver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class GLFWVideoDriver : public OpenGlVideoDriver {

virtual Size viewport_size() const { return _viewport_size; }
virtual Size screen_size() const { return _screen_size; }
virtual void set_fullscreen(const bool on);

virtual Point get_mouse();
virtual InputMode input_mode() const;
Expand Down
1 change: 1 addition & 0 deletions include/mac/c/CocoaVideoDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ int32_t antares_window_screen_width(const AntaresWindow* window);
int32_t antares_window_screen_height(const AntaresWindow* window);
int32_t antares_window_viewport_width(const AntaresWindow* window);
int32_t antares_window_viewport_height(const AntaresWindow* window);
void antares_window_toggle_fullscreen(AntaresWindow* window);

void antares_get_mouse_location(AntaresWindow* window, int32_t* x, int32_t* y);

Expand Down
1 change: 1 addition & 0 deletions include/mac/video-driver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class CocoaVideoDriver : public OpenGlVideoDriver {

virtual Size viewport_size() const;
virtual Size screen_size() const;
virtual void set_fullscreen(const bool on);

virtual Point get_mouse();
virtual InputMode input_mode() const;
Expand Down
9 changes: 5 additions & 4 deletions include/video/driver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ class VideoDriver {
VideoDriver& operator=(const VideoDriver&) = delete;

virtual ~VideoDriver();
virtual Point get_mouse() = 0;
virtual InputMode input_mode() const = 0;
virtual int scale() const = 0;
virtual Size screen_size() const = 0;
virtual Point get_mouse() = 0;
virtual InputMode input_mode() const = 0;
virtual int scale() const = 0;
virtual Size screen_size() const = 0;
virtual void set_fullscreen(const bool on) = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const isn’t meaningful in this context (function declaration argument).

I believe you can keep it in the function definition if you really want, but please remove it from the declarations.


virtual bool start_editing(TextReceiver* text) = 0;
virtual void stop_editing(TextReceiver* text) = 0;
Expand Down
1 change: 1 addition & 0 deletions include/video/offscreen-driver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class OffscreenVideoDriver : public OpenGlVideoDriver {
return {_screen_size.width * _scale, _screen_size.height * _scale};
}
virtual Size screen_size() const { return _screen_size; }
virtual void set_fullscreen(const bool on) {};

virtual Point get_mouse() { return _scheduler->get_mouse(); }
virtual InputMode input_mode() const { return _scheduler->input_mode(); }
Expand Down
1 change: 1 addition & 0 deletions include/video/text-driver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class TextVideoDriver : public VideoDriver {
virtual InputMode input_mode() const { return KEYBOARD_MOUSE; }
virtual int scale() const;
virtual Size screen_size() const { return _size; }
virtual void set_fullscreen(const bool on);

virtual bool start_editing(TextReceiver* text);
virtual void stop_editing(TextReceiver* text);
Expand Down
4 changes: 4 additions & 0 deletions src/glfw/video-driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ GLFWVideoDriver::~GLFWVideoDriver() { glfwTerminate(); }

pn::string_view GLFWVideoDriver::glsl_version() const { return _glsl_version; }

void GLFWVideoDriver::set_fullscreen(const bool on) {
window_maximize(on);
}

Point GLFWVideoDriver::get_mouse() {
double x, y;
glfwGetCursorPos(_window, &x, &y);
Expand Down
7 changes: 5 additions & 2 deletions src/mac/c/CocoaVideoDriver.m
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,9 @@ void antares_mouse_show() {
[window.window setContentView:window.view];
[window.window makeKeyAndOrderFront:NSApp];
[window.window makeFirstResponder:window.view];
[window.window center];
if (fullscreen) {
[window.window toggleFullScreen:nil];
} else {
[window.window center];
}
window.window.delegate = window.view;
return memdup(&window, sizeof(AntaresWindow));
Expand Down Expand Up @@ -170,6 +169,10 @@ static bool translate_coords(AntaresView* view, NSEvent* event, NSPoint* p) {
return true;
}

void antares_window_toggle_fullscreen(AntaresWindow* window) {
[window->window toggleFullScreen:nil];
}

void antares_get_mouse_location(AntaresWindow* window, int32_t* x, int32_t* y) {
NSPoint location = [NSEvent mouseLocation];
NSRect r = NSMakeRect(location.x, location.y, 1, 1);
Expand Down
7 changes: 7 additions & 0 deletions src/mac/video-driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ Size CocoaVideoDriver::screen_size() const {
};
}

void CocoaVideoDriver::set_fullscreen(const bool on) {
if (sys.prefs->fullscreen() != on) {
antares_window_toggle_fullscreen(_window);
sys.prefs->set_fullscreen(on);
}
}

Point CocoaVideoDriver::get_mouse() {
Point p;
antares_get_mouse_location(_window, &p.h, &p.v);
Expand Down
2 changes: 1 addition & 1 deletion src/ui/screens/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ VideoControlScreen::VideoControlScreen(OptionsScreen::State* state)
->bind({
[] { return sys.prefs->fullscreen(); },
[](bool on) {
sys.prefs->set_fullscreen(on);
sys.video->set_fullscreen(on);
},
});

Expand Down
4 changes: 4 additions & 0 deletions src/video/text-driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ TextVideoDriver::TextVideoDriver(Size screen_size, const sfz::optional<pn::strin

int TextVideoDriver::scale() const { return 1; }

void TextVideoDriver::set_fullscreen(const bool on) {
log("fullscreen", on);
}

bool TextVideoDriver::start_editing(TextReceiver* text) { return false; }

void TextVideoDriver::stop_editing(TextReceiver* text) {}
Expand Down