| 87 | } |
| 88 | |
| 89 | PuglStatus |
| 90 | puglRealize(PuglView* const view) |
| 91 | { |
| 92 | PuglInternals* const impl = view->impl; |
| 93 | PuglStatus st = PUGL_SUCCESS; |
| 94 | |
| 95 | // Ensure that we're unrealized and that a reasonable backend has been set |
| 96 | if (impl->view) { |
| 97 | return PUGL_FAILURE; |
| 98 | } |
| 99 | if (!view->backend || !view->backend->configure) { |
| 100 | return PUGL_BAD_BACKEND; |
| 101 | } |
| 102 | |
| 103 | // Set the size to the default if it has not already been set |
| 104 | if (view->frame.width <= 0.0 || view->frame.height <= 0.0) { |
| 105 | const PuglViewSize defaultSize = view->sizeHints[PUGL_DEFAULT_SIZE]; |
| 106 | if (!defaultSize.width || !defaultSize.height) { |
| 107 | return PUGL_BAD_CONFIGURATION; |
| 108 | } |
| 109 | |
| 110 | view->frame.width = defaultSize.width; |
| 111 | view->frame.height = defaultSize.height; |
| 112 | } |
| 113 | |
| 114 | // Center top-level windows if a position has not been set |
| 115 | if (!view->parent && !view->frame.x && !view->frame.y) { |
| 116 | // TODO |
| 117 | } |
| 118 | |
| 119 | if (!view->parent) { |
| 120 | impl->window = new PuglHaikuWindow(view); |
| 121 | impl->window->Lock(); |
| 122 | } |
| 123 | |
| 124 | impl->view = new PuglHaikuView(view); |
| 125 | |
| 126 | if (view->parent) { |
| 127 | BView* const pview = (BView*)view->parent; |
| 128 | pview->AddChild(impl->view); |
| 129 | } else { |
| 130 | impl->window->AddChild(impl->view); |
| 131 | } |
| 132 | |
| 133 | // Configure and create the backend |
| 134 | if ((st = view->backend->configure(view)) || (st = view->backend->create(view))) { |
| 135 | view->backend->destroy(view); |
| 136 | return st; |
| 137 | } |
| 138 | |
| 139 | if (view->title) { |
| 140 | puglSetWindowTitle(view, view->title); |
| 141 | } |
| 142 | |
| 143 | if (view->transientParent) { |
| 144 | puglSetTransientParent(view, view->transientParent); |
| 145 | } |
| 146 |
nothing calls this directly
no test coverage detected