Browse Source

Toggle full screen with F11

tags/v0.6.1
Andrew Belt 6 years ago
parent
commit
98c18acec7
5 changed files with 32 additions and 4 deletions
  1. +1
    -0
      include/events.hpp
  2. +2
    -0
      include/window.hpp
  3. +3
    -0
      src/app/RackScene.cpp
  4. +3
    -4
      src/widgets/Widget.cpp
  5. +23
    -0
      src/window.cpp

+ 1
- 0
include/events.hpp View File

@@ -28,6 +28,7 @@ struct EventMouseDown : EventPosition {
};

struct EventMouseUp : EventPosition {
/** 0 for left mouse button, 1 for right, 2 for middle */
int button;
Widget *target = NULL;
};


+ 2
- 0
include/window.hpp View File

@@ -45,6 +45,8 @@ Vec windowGetWindowPos();
void windowSetWindowPos(Vec pos);
bool windowIsMaximized();
void windowSetTheme(NVGcolor bg, NVGcolor fg);
void windowSetFullScreen(bool fullScreen);
bool windowGetFullScreen();


} // namespace rack

+ 3
- 0
src/app/RackScene.cpp View File

@@ -84,6 +84,9 @@ void RackScene::onHoverKey(EventHoverKey &e) {
appModuleBrowserCreate();
e.consumed = true;
} break;
case GLFW_KEY_F11: {
windowSetFullScreen(!windowGetFullScreen());
}
}
}
}


+ 3
- 4
src/widgets/Widget.cpp View File

@@ -62,10 +62,9 @@ void Widget::addChild(Widget *widget) {
void Widget::removeChild(Widget *widget) {
assert(widget->parent == this);
auto it = std::find(children.begin(), children.end(), widget);
if (it != children.end()) {
children.erase(it);
widget->parent = NULL;
}
assert(it != children.end());
children.erase(it);
widget->parent = NULL;
}

void Widget::clearChildren() {


+ 23
- 0
src/window.cpp View File

@@ -607,6 +607,29 @@ void windowSetTheme(NVGcolor bg, NVGcolor fg) {
bndSetTheme(t);
}

static int windowX = 0;
static int windowY = 0;
static int windowWidth = 0;
static int windowHeight = 0;

void windowSetFullScreen(bool fullScreen) {
if (windowGetFullScreen()) {
glfwSetWindowMonitor(gWindow, NULL, windowX, windowY, windowWidth, windowHeight, GLFW_DONT_CARE);
}
else {
glfwGetWindowPos(gWindow, &windowX, &windowY);
glfwGetWindowSize(gWindow, &windowWidth, &windowHeight);
GLFWmonitor *monitor = glfwGetPrimaryMonitor();
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
glfwSetWindowMonitor(gWindow, monitor, 0, 0, mode->width, mode->height, mode->refreshRate);
}
}

bool windowGetFullScreen() {
GLFWmonitor *monitor = glfwGetWindowMonitor(gWindow);
return monitor != NULL;
}


////////////////////
// resources


Loading…
Cancel
Save