Commit e4bac0d9 authored by Maciej Suminski's avatar Maciej Suminski

Fixed resize issue (moved GAL panel into pane).

Tidied up event handlers.
parent 9af45c05
...@@ -966,20 +966,23 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable ) ...@@ -966,20 +966,23 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) ); view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) );
m_galCanvas->Show(); // Switch panes
m_galCanvas->Refresh(); m_auimgr.GetPane( wxT( "DrawFrame" ) ).Hide();
m_auimgr.GetPane( wxT( "DrawFrameGal" ) ).Show();
m_auimgr.Update();
} }
else else
{ {
m_galCanvas->Hide();
double zoom = 1 / ( zoomFactor * view->GetScale() ); double zoom = 1 / ( zoomFactor * view->GetScale() );
m_canvas->SetZoom( zoom ); m_canvas->SetZoom( zoom );
VECTOR2D center = view->GetCenter(); VECTOR2D center = view->GetCenter();
RedrawScreen( wxPoint( center.x, center.y ), false ); RedrawScreen( wxPoint( center.x, center.y ), false );
m_canvas->Show(); // Switch panes
m_auimgr.GetPane( wxT( "DrawFrameGal" ) ).Hide();
m_auimgr.GetPane( wxT( "DrawFrame" ) ).Show();
m_auimgr.Update();
} }
m_galCanvasActive = aEnable; m_galCanvasActive = aEnable;
......
...@@ -75,9 +75,6 @@ BEGIN_EVENT_TABLE( EDA_DRAW_PANEL, wxScrolledWindow ) ...@@ -75,9 +75,6 @@ BEGIN_EVENT_TABLE( EDA_DRAW_PANEL, wxScrolledWindow )
EVT_ERASE_BACKGROUND( EDA_DRAW_PANEL::OnEraseBackground ) EVT_ERASE_BACKGROUND( EDA_DRAW_PANEL::OnEraseBackground )
EVT_SCROLLWIN( EDA_DRAW_PANEL::OnScroll ) EVT_SCROLLWIN( EDA_DRAW_PANEL::OnScroll )
EVT_ACTIVATE( EDA_DRAW_PANEL::OnActivate ) EVT_ACTIVATE( EDA_DRAW_PANEL::OnActivate )
#ifdef KICAD_GAL
EVT_SIZE( EDA_DRAW_PANEL::OnSize )
#endif
EVT_MENU_RANGE( ID_PAN_UP, ID_PAN_RIGHT, EDA_DRAW_PANEL::OnPan ) EVT_MENU_RANGE( ID_PAN_UP, ID_PAN_RIGHT, EDA_DRAW_PANEL::OnPan )
END_EVENT_TABLE() END_EVENT_TABLE()
...@@ -1381,18 +1378,6 @@ void EDA_DRAW_PANEL::OnPan( wxCommandEvent& event ) ...@@ -1381,18 +1378,6 @@ void EDA_DRAW_PANEL::OnPan( wxCommandEvent& event )
} }
#ifdef KICAD_GAL
void EDA_DRAW_PANEL::OnSize( wxSizeEvent& SizeEv )
{
if( GetParent()->GetGalCanvas() != NULL )
{
GetParent()->GetGalCanvas()->SetPosition( GetPosition() );
GetParent()->GetGalCanvas()->SetSize( GetSize() );
}
}
#endif
void EDA_DRAW_PANEL::EndMouseCapture( int id, int cursor, const wxString& title, void EDA_DRAW_PANEL::EndMouseCapture( int id, int cursor, const wxString& title,
bool aCallEndFunc ) bool aCallEndFunc )
{ {
......
...@@ -44,8 +44,7 @@ ...@@ -44,8 +44,7 @@
EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWindowId, EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWindowId,
const wxPoint& aPosition, const wxSize& aSize, const wxPoint& aPosition, const wxSize& aSize,
GalType aGalType ) : GalType aGalType ) :
wxWindow( aParentWindow, aWindowId, aPosition, aSize ), wxWindow( aParentWindow, aWindowId, aPosition, aSize )
m_screenSize( aSize.x, aSize.y ), m_parentFrame( aParentWindow )
{ {
m_gal = NULL; m_gal = NULL;
m_view = NULL; m_view = NULL;
...@@ -78,7 +77,7 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin ...@@ -78,7 +77,7 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
m_viewControls = new KiGfx::WX_VIEW_CONTROLS( m_view, this ); m_viewControls = new KiGfx::WX_VIEW_CONTROLS( m_view, this );
Connect( KiGfx::EVT_GAL_REDRAW, wxPaintEventHandler( EDA_DRAW_PANEL_GAL::onPaint ), NULL, this ); Connect( wxEVT_PAINT, wxPaintEventHandler( EDA_DRAW_PANEL_GAL::onPaint ), NULL, this );
Connect( wxEVT_SIZE, wxSizeEventHandler( EDA_DRAW_PANEL_GAL::onSize ), NULL, this ); Connect( wxEVT_SIZE, wxSizeEventHandler( EDA_DRAW_PANEL_GAL::onSize ), NULL, this );
} }
......
...@@ -52,7 +52,6 @@ CAIRO_GAL::CAIRO_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener, ...@@ -52,7 +52,6 @@ CAIRO_GAL::CAIRO_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
SetSize( aParent->GetSize() ); SetSize( aParent->GetSize() );
// Connecting the event handlers // Connecting the event handlers
Connect( wxEVT_SIZE, wxSizeEventHandler( CAIRO_GAL::onSize ) );
Connect( wxEVT_PAINT, wxPaintEventHandler( CAIRO_GAL::onPaint ) ); Connect( wxEVT_PAINT, wxPaintEventHandler( CAIRO_GAL::onPaint ) );
// Mouse events are skipped to the parent // Mouse events are skipped to the parent
...@@ -115,15 +114,6 @@ void CAIRO_GAL::ResizeScreen( int aWidth, int aHeight ) ...@@ -115,15 +114,6 @@ void CAIRO_GAL::ResizeScreen( int aWidth, int aHeight )
allocateBitmaps(); allocateBitmaps();
SetSize( wxSize( aWidth, aHeight ) ); SetSize( wxSize( aWidth, aHeight ) );
PostPaint();
}
void CAIRO_GAL::onSize( wxSizeEvent& aEvent )
{
ResizeScreen( aEvent.GetSize().x, aEvent.GetSize().y );
PostPaint();
} }
...@@ -188,46 +178,6 @@ void CAIRO_GAL::EndDrawing() ...@@ -188,46 +178,6 @@ void CAIRO_GAL::EndDrawing()
// Force remaining objects to be drawn // Force remaining objects to be drawn
Flush(); Flush();
// FIXME Accelerate support for wxWidgets 2.8.10
#if wxCHECK_VERSION( 2, 9, 0 )
// Copy the cairo image contents to the wxBitmap
wxNativePixelData pixelData( *wxBitmap_ );
if( !pixelData )
{
wxLogError( wxString::FromUTF8( "Can't access pixel data!" ) );
return;
}
wxNativePixelData::Iterator pixelIterator( pixelData );
int offset = 0;
// Copy the cairo image to the wxDC bitmap
for( int j = 0; j < screenSize.y; j++ )
{
offset = j * (int) screenSize.x;
for( int column = 0; column < clientRectangle.width; column++ )
{
unsigned int value = bitmapBuffer[offset + column];
pixelIterator.Red() = value >> 16;
pixelIterator.Green() = value >> 8;
pixelIterator.Blue() = value;
pixelIterator++;
}
pixelIterator.MoveTo( pixelData, 0, j );
}
// Blit the contents to the screen
wxClientDC client_dc( this );
wxBufferedDC dc( &client_dc );
dc.DrawBitmap( *wxBitmap_, 0, 0 );
#elif wxCHECK_VERSION( 2, 8, 0 )
// This code was taken from the wxCairo example - it's not the most efficient one // This code was taken from the wxCairo example - it's not the most efficient one
// Here is a good place for optimizations // Here is a good place for optimizations
...@@ -237,12 +187,9 @@ void CAIRO_GAL::EndDrawing() ...@@ -237,12 +187,9 @@ void CAIRO_GAL::EndDrawing()
for( size_t count = 0; count < bufferSize; count++ ) for( size_t count = 0; count < bufferSize; count++ )
{ {
unsigned int value = bitmapBuffer[count]; unsigned int value = bitmapBuffer[count];
// Red pixel *wxOutputPtr++ = (value >> 16) & 0xff; // Red pixel
*wxOutputPtr++ = (value >> 16) & 0xff; *wxOutputPtr++ = (value >> 8) & 0xff; // Green pixel
// Green pixel *wxOutputPtr++ = value & 0xff; // Blue pixel
*wxOutputPtr++ = (value >> 8) & 0xff;
// Blue pixel
*wxOutputPtr++ = (value >> 0) & 0xff;
} }
wxImage img( (int) screenSize.x, (int) screenSize.y, (unsigned char*) wxOutput, true); wxImage img( (int) screenSize.x, (int) screenSize.y, (unsigned char*) wxOutput, true);
...@@ -252,10 +199,6 @@ void CAIRO_GAL::EndDrawing() ...@@ -252,10 +199,6 @@ void CAIRO_GAL::EndDrawing()
// client_dc.DrawBitmap(bmp, 0, 0, false); // client_dc.DrawBitmap(bmp, 0, 0, false);
dc.Init( &client_dc, bmp ); dc.Init( &client_dc, bmp );
#else
#error "need wxWidgets-2.8 as a minimum"
#endif
// Destroy Cairo objects // Destroy Cairo objects
cairo_destroy( cairoImage ); cairo_destroy( cairoImage );
cairo_surface_destroy( cairoSurface ); cairo_surface_destroy( cairoSurface );
...@@ -967,7 +910,6 @@ void CAIRO_GAL::allocateBitmaps() ...@@ -967,7 +910,6 @@ void CAIRO_GAL::allocateBitmaps()
bitmapBuffer = new unsigned int[bufferSize]; bitmapBuffer = new unsigned int[bufferSize];
bitmapBufferBackup = new unsigned int[bufferSize]; bitmapBufferBackup = new unsigned int[bufferSize];
wxOutput = new unsigned char[bufferSize * 4]; wxOutput = new unsigned char[bufferSize * 4];
wxBitmap_ = new wxBitmap( screenSize.x, screenSize.y, SCREEN_DEPTH );
} }
...@@ -976,7 +918,6 @@ void CAIRO_GAL::deleteBitmaps() ...@@ -976,7 +918,6 @@ void CAIRO_GAL::deleteBitmaps()
delete[] bitmapBuffer; delete[] bitmapBuffer;
delete[] bitmapBufferBackup; delete[] bitmapBufferBackup;
delete[] wxOutput; delete[] wxOutput;
delete wxBitmap_;
} }
......
...@@ -33,8 +33,6 @@ ...@@ -33,8 +33,6 @@
using namespace KiGfx; using namespace KiGfx;
const wxEventType KiGfx::EVT_GAL_REDRAW = wxNewEventType();
GAL::GAL() GAL::GAL()
{ {
// Set the default values for the internal variables // Set the default values for the internal variables
......
...@@ -88,7 +88,6 @@ OPENGL_GAL::OPENGL_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener, ...@@ -88,7 +88,6 @@ OPENGL_GAL::OPENGL_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
SetGridLineWidth( 1.0 ); SetGridLineWidth( 1.0 );
// Connecting the event handlers. // Connecting the event handlers.
Connect( wxEVT_SIZE, wxSizeEventHandler( OPENGL_GAL::onSize ) );
Connect( wxEVT_PAINT, wxPaintEventHandler( OPENGL_GAL::onPaint ) ); Connect( wxEVT_PAINT, wxPaintEventHandler( OPENGL_GAL::onPaint ) );
// Mouse events are skipped to the parent // Mouse events are skipped to the parent
...@@ -147,13 +146,6 @@ void OPENGL_GAL::ResizeScreen( int aWidth, int aHeight ) ...@@ -147,13 +146,6 @@ void OPENGL_GAL::ResizeScreen( int aWidth, int aHeight )
} }
void OPENGL_GAL::onSize( wxSizeEvent& aEvent )
{
ResizeScreen( aEvent.GetSize().x, aEvent.GetSize().y );
PostPaint();
}
void OPENGL_GAL::skipMouseEvent( wxMouseEvent& aEvent ) void OPENGL_GAL::skipMouseEvent( wxMouseEvent& aEvent )
{ {
// Post the mouse event to the event listener registered in constructor, if any // Post the mouse event to the event listener registered in constructor, if any
......
...@@ -258,9 +258,6 @@ public: ...@@ -258,9 +258,6 @@ public:
void OnCharHook( wxKeyEvent& event ); void OnCharHook( wxKeyEvent& event );
void OnPan( wxCommandEvent& event ); void OnPan( wxCommandEvent& event );
#ifdef KICAD_GAL
void OnSize( wxSizeEvent& event );
#endif
void EraseScreen( wxDC* DC ); void EraseScreen( wxDC* DC );
void OnScrollWin( wxCommandEvent& event ); void OnScrollWin( wxCommandEvent& event );
......
...@@ -88,9 +88,6 @@ protected: ...@@ -88,9 +88,6 @@ protected:
///< using GAL ///< using GAL
KiGfx::WX_VIEW_CONTROLS* m_viewControls; ///< Control for VIEW (moving, zooming, etc.) KiGfx::WX_VIEW_CONTROLS* m_viewControls; ///< Control for VIEW (moving, zooming, etc.)
VECTOR2D m_screenSize; ///< Stores current screen size
wxWindow* m_parentFrame; ///< Pointer to the parent frame
std::string m_galShaderPath; ///< Path to shader files, used in OpenGL mode std::string m_galShaderPath; ///< Path to shader files, used in OpenGL mode
}; };
......
...@@ -274,7 +274,7 @@ public: ...@@ -274,7 +274,7 @@ public:
{ {
if( paintListener ) if( paintListener )
{ {
wxCommandEvent redrawEvent( EVT_GAL_REDRAW ); wxPaintEvent redrawEvent;
wxPostEvent( paintListener, redrawEvent ); wxPostEvent( paintListener, redrawEvent );
} }
} }
...@@ -361,10 +361,8 @@ private: ...@@ -361,10 +361,8 @@ private:
cairo_surface_t* cairoSurface; ///< Cairo surface cairo_surface_t* cairoSurface; ///< Cairo surface
unsigned int* bitmapBuffer; ///< Storage of the cairo image unsigned int* bitmapBuffer; ///< Storage of the cairo image
unsigned int* bitmapBufferBackup; ///< Backup storage of the cairo image unsigned int* bitmapBufferBackup; ///< Backup storage of the cairo image
wxBitmap* wxBitmap_; ///< Pointer to the wxWidgets bitmap
int stride; ///< Stride value for Cairo int stride; ///< Stride value for Cairo
// wxClientDC* clientDC; ///< Pointer to the clientDC // wxClientDC* clientDC; ///< Pointer to the clientDC
int screenSizeY; ///< Vertical size of the actual surface
// Mapping between Cairo and GAL line attributes // Mapping between Cairo and GAL line attributes
std::map<LineCap, cairo_line_cap_t> lineCapMap; ///< Line cap style mapping std::map<LineCap, cairo_line_cap_t> lineCapMap; ///< Line cap style mapping
...@@ -381,13 +379,6 @@ private: ...@@ -381,13 +379,6 @@ private:
*/ */
void onPaint( wxPaintEvent& aEvent ); void onPaint( wxPaintEvent& aEvent );
/**
* @brief Window resizing event handler.
*
* @param aEvent is the resizing event.
*/
void onSize( wxSizeEvent& aEvent );
/** /**
* @brief Mouse event handler, forwards the event to the child. * @brief Mouse event handler, forwards the event to the child.
* *
......
...@@ -38,8 +38,6 @@ ...@@ -38,8 +38,6 @@
namespace KiGfx namespace KiGfx
{ {
// Event declaration
extern const wxEventType EVT_GAL_REDRAW;
/** /**
* LineCap: Type definition of the line end point style * LineCap: Type definition of the line end point style
......
...@@ -292,7 +292,7 @@ public: ...@@ -292,7 +292,7 @@ public:
{ {
if( paintListener ) if( paintListener )
{ {
wxCommandEvent redrawEvent( EVT_GAL_REDRAW ); wxPaintEvent redrawEvent;
wxPostEvent( paintListener, redrawEvent ); wxPostEvent( paintListener, redrawEvent );
} }
} }
...@@ -411,13 +411,6 @@ private: ...@@ -411,13 +411,6 @@ private:
*/ */
void onPaint( wxPaintEvent& aEvent ); void onPaint( wxPaintEvent& aEvent );
/**
* @brief Window resizing event handler.
*
* @param aEvent is the window resizing event.
*/
void onSize( wxSizeEvent& aEvent );
/** /**
* @brief Skip the mouse event to the parent. * @brief Skip the mouse event to the parent.
* *
......
...@@ -134,7 +134,6 @@ PCB_BASE_FRAME::PCB_BASE_FRAME( wxWindow* aParent, ID_DRAWFRAME_TYPE aFrameType, ...@@ -134,7 +134,6 @@ PCB_BASE_FRAME::PCB_BASE_FRAME( wxWindow* aParent, ID_DRAWFRAME_TYPE aFrameType,
#ifdef KICAD_GAL #ifdef KICAD_GAL
m_galCanvas = new EDA_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize, m_galCanvas = new EDA_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize,
EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ); EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL );
m_galCanvas->Hide();
#endif /* KICAD_GAL */ #endif /* KICAD_GAL */
m_auxiliaryToolBar = NULL; m_auxiliaryToolBar = NULL;
...@@ -242,6 +241,9 @@ void PCB_BASE_FRAME::SetBoard( BOARD* aBoard ) ...@@ -242,6 +241,9 @@ void PCB_BASE_FRAME::SetBoard( BOARD* aBoard )
} }
view->SetTopLayer( m_Pcb->GetLayer() ); view->SetTopLayer( m_Pcb->GetLayer() );
if( m_galCanvasActive )
m_galCanvas->Refresh();
} }
#endif #endif
} }
......
...@@ -416,6 +416,10 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title, ...@@ -416,6 +416,10 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title,
m_auimgr.AddPane( m_canvas, m_auimgr.AddPane( m_canvas,
wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() ); wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() );
if( m_galCanvas )
m_auimgr.AddPane( m_galCanvas,
wxAuiPaneInfo().Name( wxT( "DrawFrameGal" ) ).CentrePane().Hide() );
if( m_messagePanel ) if( m_messagePanel )
m_auimgr.AddPane( m_messagePanel, m_auimgr.AddPane( m_messagePanel,
wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().Layer(10) ); wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().Layer(10) );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment