Skip to content

Commit

Permalink
Ensure "split" buttons don't create a transparent background
Browse files Browse the repository at this point in the history
Doesn't work either...

Signed-off-by: Geoff Hutchison <[email protected]>
  • Loading branch information
ghutchis committed Nov 22, 2024
1 parent 6694257 commit 6cce7db
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
1 change: 1 addition & 0 deletions avogadro/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ void MainWindow::setupInterface()
m_multiViewWidget->setFactory(m_viewFactory);
setCentralWidget(m_multiViewWidget);
auto* glWidget = new GLWidget(this);
m_viewFactory->setGLWidget(glWidget);

// set the background color (alpha channel default should be opaque)
auto color =
Expand Down
22 changes: 14 additions & 8 deletions avogadro/viewfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@

namespace Avogadro {

ViewFactory::ViewFactory()
{
}
ViewFactory::ViewFactory() {}

ViewFactory::~ViewFactory()
{
}
ViewFactory::~ViewFactory() {}

QStringList ViewFactory::views() const
{
Expand All @@ -32,8 +28,18 @@ QStringList ViewFactory::views() const

QWidget* ViewFactory::createView(const QString& view)
{
if (view == QObject::tr("3D View"))
return new QtOpenGL::GLWidget;
if (view == QObject::tr("3D View")) {
// get the background color, etc.
if (m_glWidget != nullptr) {
auto newWidget = new QtOpenGL::GLWidget(m_glWidget);
newWidget->setMolecule(m_glWidget->molecule());
// set the background color, etc.
auto bgColor = m_glWidget->renderer().scene().backgroundColor();
newWidget->renderer().scene().setBackgroundColor(bgColor);
return newWidget;
} else
return new QtOpenGL::GLWidget;
}
#ifdef AVO_USE_VTK
else if (view == QObject::tr("VTK"))
return new VTK::vtkGLWidget;
Expand Down
8 changes: 8 additions & 0 deletions avogadro/viewfactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
#define AVOGADRO_VIEWFACTORY_H

#include <avogadro/qtgui/viewfactory.h>
#include <avogadro/qtopengl/glwidget.h>
#ifdef AVO_USE_VTK
#include <avogadro/vtk/vtkglwidget.h>
#endif

namespace Avogadro {

Expand All @@ -18,6 +22,10 @@ class ViewFactory : public QtGui::ViewFactory

QStringList views() const;
QWidget* createView(const QString& view);
void setGLWidget(QtOpenGL::GLWidget* glWidget) { m_glWidget = glWidget; }

protected:
QtOpenGL::GLWidget* m_glWidget = nullptr;
};

} // End namespace Avogadro
Expand Down

0 comments on commit 6cce7db

Please sign in to comment.