More resizing

This commit is contained in:
James Grogan 2022-11-14 15:31:38 +00:00
parent 9ade0e2d4b
commit be94bf0185
11 changed files with 44 additions and 3 deletions

View file

@ -19,6 +19,8 @@ void OpenGlPainter::paint(DrawingContext* context)
const auto width = double(surface->getWidth()); const auto width = double(surface->getWidth());
const auto height = double(surface->getHeight()); const auto height = double(surface->getHeight());
std::cout << "Painting into width " << width << " and height " << height << std::endl;
const auto num_mesh = context->getScene()->getNumMeshes(); const auto num_mesh = context->getScene()->getNumMeshes();
glClearColor(1.0, 1.0, 1.0, 0.0); glClearColor(1.0, 1.0, 1.0, 0.0);
@ -55,6 +57,11 @@ void OpenGlPainter::paint(DrawingContext* context)
glVertex3f(x1, y1, 0); glVertex3f(x1, y1, 0);
glVertex3f(x2, y2, 0); glVertex3f(x2, y2, 0);
// std::cout << "Verts0| " << x0 << " | " << y0 << " | "<< std::endl;
// std::cout << "Verts1| " << x1 << " | " << y1 << " | "<< std::endl;
// std::cout << "Verts2| " << x2 << " | " << y2 << " | "<< std::endl;
// std::cout << "****************" << std::endl;
glEnd(); glEnd();
counter++; counter++;

View file

@ -33,6 +33,8 @@ public:
virtual void clear() = 0; virtual void clear() = 0;
virtual void onResize(unsigned width, unsigned height) = 0;
protected: protected:
mt::Window* mWindow{nullptr}; mt::Window* mWindow{nullptr};
}; };

View file

@ -15,6 +15,8 @@
#include "Screen.h" #include "Screen.h"
#include "Image.h" #include "Image.h"
#include <iostream>
namespace mt namespace mt
{ {
@ -41,6 +43,11 @@ void Window::setSize(unsigned width, unsigned height)
{ {
DrawingSurface::setSize(width, height); DrawingSurface::setSize(width, height);
mWidget->setBounds(width, height); mWidget->setBounds(width, height);
if (mPlatformWindow)
{
mPlatformWindow->onResize(width, height);
}
} }
void Window::clearPlatformWindow() void Window::clearPlatformWindow()

View file

@ -2,8 +2,8 @@
ResizeEvent::ResizeEvent(unsigned width, unsigned height) ResizeEvent::ResizeEvent(unsigned width, unsigned height)
: UiEvent(), : UiEvent(),
mWidth(), mWidth(width),
mHeight() mHeight(height)
{ {
mType = UiEvent::Type::Resize; mType = UiEvent::Type::Resize;
} }

View file

@ -2,6 +2,7 @@
#include <algorithm> #include <algorithm>
#include <numeric> #include <numeric>
#include <iostream>
HorizontalSpacer::HorizontalSpacer() HorizontalSpacer::HorizontalSpacer()
: Widget(), : Widget(),
@ -35,6 +36,7 @@ void HorizontalSpacer::addChildLayers(const PaintEvent* event)
{ {
height = mSize.mMaxHeight; height = mSize.mMaxHeight;
} }
for(std::size_t idx=0; idx<mChildren.size(); idx++) for(std::size_t idx=0; idx<mChildren.size(); idx++)
{ {
auto& child = mChildren[idx]; auto& child = mChildren[idx];

View file

@ -71,7 +71,7 @@ void DesktopManager::onUiEvent(UiEventUPtr eventUPtr)
{ {
auto resize_event = dynamic_cast<const ResizeEvent*>(event); auto resize_event = dynamic_cast<const ResizeEvent*>(event);
mWindowManager->onResizeEvent(resize_event); mWindowManager->onResizeEvent(resize_event);
//mModified = true; mModified = true;
break; break;
} }
case (UiEvent::Type::Mouse): case (UiEvent::Type::Mouse):

View file

@ -34,6 +34,11 @@ public:
void clear(); void clear();
void onResize(unsigned width, unsigned height)
{
}
private: private:
void initialize(); void initialize();

View file

@ -2,6 +2,7 @@
#include "XcbGlInterface.h" #include "XcbGlInterface.h"
#include "FileLogger.h" #include "FileLogger.h"
#include <iostream>
#include <GL/gl.h> #include <GL/gl.h>
@ -56,6 +57,11 @@ bool XcbGlWindowInterface::initialize(xcb_window_t window)
return true; return true;
} }
void XcbGlWindowInterface::resizeViewPort(unsigned width, unsigned height)
{
glViewport(0, 0, width, height);
}
void XcbGlWindowInterface::destroyWindow() void XcbGlWindowInterface::destroyWindow()
{ {
glXDestroyWindow(mGlInterface->getDisplay(), mWindow); glXDestroyWindow(mGlInterface->getDisplay(), mWindow);

View file

@ -16,6 +16,8 @@ public:
void afterPaint(); void afterPaint();
void resizeViewPort(unsigned width, unsigned height);
private: private:
void destroyWindow(); void destroyWindow();
void swapBuffers(); void swapBuffers();

View file

@ -112,3 +112,11 @@ void XcbWindow::map()
xcb_map_window(mConnection, mHandle); xcb_map_window(mConnection, mHandle);
xcb_flush(mConnection); xcb_flush(mConnection);
} }
void XcbWindow::onResize(unsigned width, unsigned height)
{
if (mGlInterface)
{
mGlInterface->resizeViewPort(width, height);
}
}

View file

@ -34,6 +34,8 @@ public:
void map() override; void map() override;
void onResize(unsigned width, unsigned height) override;
private: private:
int mHandle{-1}; int mHandle{-1};
unsigned mGraphicsContext {0}; unsigned mGraphicsContext {0};