Preliminary changes for FLTK support
* Added "Show Menu Bar" and "Full Screen" menu items, which will be implemented in the FLTK interface. These are currently prevented from appearing in the Win32 interface by the HAVE_FLTK and HAVE_FLTK_FULLSCREEN macros. * Moved the "Show Text Window" down below the "Show Toolbar" item, so that "Show Menu Bar", "Show Toolbar" and "Show Text Window" are in the same vertical order as their corresponding UI elements typically take on * Added new platform-dependent routines to back the new menu items: void ToggleMenuBar(void); bool MenuBarIsVisible(void); void ToggleFullScreen(void); bool FullScreenIsActive(void); These are stubs in the Win32 code. * Fleshed out the system header #includes in solvespace.h, and moved them to the top of the file per convention * Rewrote the file dialog selection patterns in terms of macros that allow them to expand to either the FLTK or Windows formats * Don't use __stdcall in SSGL_CALLBACK, and make SSGL_CALLBACK 'extern "C"' as OpenGL usually expects function pointers to point to C functionspull/3/head
parent
c6203678e1
commit
873811d865
|
@ -70,11 +70,18 @@ const GraphicsWindow::MenuEntry GraphicsWindow::menu[] = {
|
|||
{ 1, "Show Snap &Grid", MNU_SHOW_GRID, '>', mView },
|
||||
{ 1, "Use &Perspective Projection", MNU_PERSPECTIVE_PROJ,'`', mView },
|
||||
{ 1, NULL, 0, 0, NULL },
|
||||
{ 1, "Show Text &Window", MNU_SHOW_TEXT_WND, '\t', mView },
|
||||
#ifdef HAVE_FLTK
|
||||
{ 1, "Show Menu &Bar", MNU_SHOW_MENU_BAR, F(12), mView },
|
||||
#endif
|
||||
{ 1, "Show &Toolbar", MNU_SHOW_TOOLBAR, 0, mView },
|
||||
{ 1, "Show Text &Window", MNU_SHOW_TEXT_WND, '\t', mView },
|
||||
{ 1, NULL, 0, 0, NULL },
|
||||
{ 1, "Dimensions in &Inches", MNU_UNITS_INCHES, 0, mView },
|
||||
{ 1, "Dimensions in &Millimeters", MNU_UNITS_MM, 0, mView },
|
||||
#ifdef HAVE_FLTK_FULLSCREEN
|
||||
{ 1, NULL, 0, 0, NULL },
|
||||
{ 1, "&Full Screen", MNU_FULL_SCREEN, F(11), mView },
|
||||
#endif
|
||||
|
||||
{ 0, "&New Group", 0, 0, NULL },
|
||||
{ 1, "Sketch In &3d", MNU_GROUP_3D, S|'3', mGrp },
|
||||
|
@ -504,9 +511,10 @@ void GraphicsWindow::MenuView(int id) {
|
|||
}
|
||||
break;
|
||||
|
||||
case MNU_SHOW_TEXT_WND:
|
||||
SS.GW.showTextWindow = !SS.GW.showTextWindow;
|
||||
case MNU_SHOW_MENU_BAR:
|
||||
ToggleMenuBar();
|
||||
SS.GW.EnsureValidActives();
|
||||
InvalidateGraphics();
|
||||
break;
|
||||
|
||||
case MNU_SHOW_TOOLBAR:
|
||||
|
@ -515,9 +523,8 @@ void GraphicsWindow::MenuView(int id) {
|
|||
InvalidateGraphics();
|
||||
break;
|
||||
|
||||
case MNU_UNITS_MM:
|
||||
SS.viewUnits = SolveSpace::UNIT_MM;
|
||||
SS.later.showTW = true;
|
||||
case MNU_SHOW_TEXT_WND:
|
||||
SS.GW.showTextWindow = !SS.GW.showTextWindow;
|
||||
SS.GW.EnsureValidActives();
|
||||
break;
|
||||
|
||||
|
@ -527,6 +534,17 @@ void GraphicsWindow::MenuView(int id) {
|
|||
SS.GW.EnsureValidActives();
|
||||
break;
|
||||
|
||||
case MNU_UNITS_MM:
|
||||
SS.viewUnits = SolveSpace::UNIT_MM;
|
||||
SS.later.showTW = true;
|
||||
SS.GW.EnsureValidActives();
|
||||
break;
|
||||
|
||||
case MNU_FULL_SCREEN:
|
||||
ToggleFullScreen();
|
||||
SS.GW.EnsureValidActives();
|
||||
break;
|
||||
|
||||
default: oops();
|
||||
}
|
||||
InvalidateGraphics();
|
||||
|
@ -596,9 +614,15 @@ void GraphicsWindow::EnsureValidActives(void) {
|
|||
ShowTextWindow(SS.GW.showTextWindow);
|
||||
CheckMenuById(MNU_SHOW_TEXT_WND, SS.GW.showTextWindow);
|
||||
|
||||
#ifdef HAVE_FLTK
|
||||
CheckMenuById(MNU_SHOW_MENU_BAR, MenuBarIsVisible());
|
||||
#endif
|
||||
CheckMenuById(MNU_SHOW_TOOLBAR, SS.showToolbar);
|
||||
CheckMenuById(MNU_PERSPECTIVE_PROJ, SS.usePerspectiveProj);
|
||||
CheckMenuById(MNU_SHOW_GRID, SS.GW.showSnapGrid);
|
||||
#ifdef HAVE_FLTK_FULLSCREEN
|
||||
CheckMenuById(MNU_FULL_SCREEN, FullScreenIsActive());
|
||||
#endif
|
||||
|
||||
if(change) SS.later.showTW = true;
|
||||
}
|
||||
|
|
102
solvespace.h
102
solvespace.h
|
@ -7,6 +7,25 @@
|
|||
#ifndef __SOLVESPACE_H
|
||||
#define __SOLVESPACE_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
#ifdef HAVE_STDINT_H
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
#ifdef WIN32
|
||||
# include <windows.h> // required by GL headers
|
||||
#endif
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
|
||||
// The few floating-point equality comparisons in SolveSpace have been
|
||||
// carefully considered, so we disable the -Wfloat-equal warning for them
|
||||
#ifdef __clang__
|
||||
|
@ -22,6 +41,7 @@
|
|||
// Debugging functions
|
||||
#define oops() do { dbp("oops at line %d, file %s\n", __LINE__, __FILE__); \
|
||||
if(0) *(char *)0 = 1; exit(-1); } while(0)
|
||||
|
||||
#ifndef min
|
||||
# define min(x, y) ((x) < (y) ? (x) : (y))
|
||||
#endif
|
||||
|
@ -65,18 +85,6 @@ inline double ffabs(double v) { return (v > 0) ? v : (-v); }
|
|||
|
||||
#define isforname(c) (isalnum(c) || (c) == '_' || (c) == '-' || (c) == '#')
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
#ifdef WIN32
|
||||
# include <windows.h> // required by GL headers
|
||||
#endif
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
|
||||
#ifdef WIN32
|
||||
// Define some useful C99 integer types.
|
||||
typedef UINT64 uint64_t;
|
||||
|
@ -112,38 +120,58 @@ void RefreshRecentMenus(void);
|
|||
#define SAVE_CANCEL (0)
|
||||
int SaveFileYesNoCancel(void);
|
||||
|
||||
#ifdef HAVE_FLTK
|
||||
// Selection pattern format for FLTK's file chooser classes:
|
||||
// "PNG File\t*.png\n"
|
||||
// "JPEG File\t*.{jpg,jpeg}\n"
|
||||
// "All Files\t*"
|
||||
# define PAT1(desc,e1) desc "\t*." e1 "\n"
|
||||
# define PAT2(desc,e1,e2) desc "\t*.{" e1 "," e2 "}\n"
|
||||
# define ENDPAT "All Files\t*"
|
||||
#else
|
||||
// Selection pattern format for Win32's OPENFILENAME.lpstrFilter:
|
||||
// "PNG File (*.png)\0*.png\0"
|
||||
// "JPEG File (*.jpg;*.jpeg)\0*.jpg;*.jpeg\0"
|
||||
// "All Files (*)\0*\0\0"
|
||||
# define PAT1(desc,e1) desc " (*." e1 ")\0*." e1 "\0"
|
||||
# define PAT2(desc,e1,e2) desc " (*." e1 ";*." e2 ")\0*." e1 ";*." e2 "\0"
|
||||
# define ENDPAT "All Files (*)\0*\0\0"
|
||||
#endif
|
||||
|
||||
// SolveSpace native file format
|
||||
#define SLVS_PATTERN "SolveSpace Models (*.slvs)\0*.slvs\0All Files (*)\0*\0\0"
|
||||
#define SLVS_PATTERN PAT1("SolveSpace Models", "slvs") ENDPAT
|
||||
#define SLVS_EXT "slvs"
|
||||
// PNG format bitmap
|
||||
#define PNG_PATTERN "PNG (*.png)\0*.png\0All Files (*)\0*\0\0"
|
||||
#define PNG_PATTERN PAT1("PNG", "png") ENDPAT
|
||||
#define PNG_EXT "png"
|
||||
// Triangle mesh
|
||||
#define MESH_PATTERN "STL Mesh (*.stl)\0*.stl\0" \
|
||||
"Wavefront OBJ Mesh (*.obj)\0*.obj\0" \
|
||||
"All Files (*)\0*\0\0"
|
||||
#define MESH_PATTERN \
|
||||
PAT1("STL Mesh", "stl") \
|
||||
PAT1("Wavefront OBJ Mesh", "obj") \
|
||||
ENDPAT
|
||||
#define MESH_EXT "stl"
|
||||
// NURBS surfaces
|
||||
#define SRF_PATTERN "STEP File (*.step;*.stp)\0*.step;*.stp\0" \
|
||||
"All Files(*)\0*\0\0"
|
||||
#define SRF_PATTERN PAT2("STEP File", "step", "stp") ENDPAT
|
||||
#define SRF_EXT "step"
|
||||
// 2d vector (lines and curves) format
|
||||
#define VEC_PATTERN "PDF File (*.pdf)\0*.pdf\0" \
|
||||
"Encapsulated PostScript (*.eps;*.ps)\0*.eps;*.ps\0" \
|
||||
"Scalable Vector Graphics (*.svg)\0*.svg\0" \
|
||||
"STEP File (*.step;*.stp)\0*.step;*.stp\0" \
|
||||
"DXF File (*.dxf)\0*.dxf\0" \
|
||||
"HPGL File (*.plt;*.hpgl)\0*.plt;*.hpgl\0" \
|
||||
"G Code (*.txt)\0*.txt\0" \
|
||||
"All Files (*)\0*\0\0"
|
||||
#define VEC_PATTERN \
|
||||
PAT1("PDF File", "pdf") \
|
||||
PAT2("Encapsulated PostScript", "eps", "ps") \
|
||||
PAT1("Scalable Vector Graphics", "svg") \
|
||||
PAT2("STEP File", "step", "stp") \
|
||||
PAT1("DXF File", "dxf") \
|
||||
PAT2("HPGL File", "plt", "hpgl") \
|
||||
PAT1("G Code", "txt") \
|
||||
ENDPAT
|
||||
#define VEC_EXT "pdf"
|
||||
// 3d vector (wireframe lines and curves) format
|
||||
#define V3D_PATTERN "STEP File (*.step;*.stp)\0*.step;*.stp\0" \
|
||||
"DXF File (*.dxf)\0*.dxf\0" \
|
||||
"All Files (*)\0*\0\0"
|
||||
#define V3D_PATTERN \
|
||||
PAT2("STEP File", "step", "stp") \
|
||||
PAT1("DXF File", "dxf") \
|
||||
ENDPAT
|
||||
#define V3D_EXT "step"
|
||||
// Comma-separated value, like a spreadsheet would use
|
||||
#define CSV_PATTERN "CSV File (*.csv)\0*.csv\0All Files (*)\0*\0\0"
|
||||
#define CSV_PATTERN PAT1("CSV File", "csv") ENDPAT
|
||||
#define CSV_EXT "csv"
|
||||
bool GetSaveFile(char *file, const char *defExtension, const char *selPattern);
|
||||
bool GetOpenFile(char *file, const char *defExtension, const char *selPattern);
|
||||
|
@ -170,10 +198,14 @@ void AddContextMenuItem(const char *legend, int id);
|
|||
void CreateContextSubmenu(void);
|
||||
int ShowContextMenu(void);
|
||||
|
||||
void ToggleMenuBar(void);
|
||||
bool MenuBarIsVisible(void);
|
||||
void ShowTextWindow(bool visible);
|
||||
void InvalidateText(void);
|
||||
void InvalidateGraphics(void);
|
||||
void PaintGraphics(void);
|
||||
void ToggleFullScreen(void);
|
||||
bool FullScreenIsActive(void);
|
||||
void GetGraphicsWindowSize(int *w, int *h);
|
||||
void GetTextWindowSize(int *w, int *h);
|
||||
int32_t GetMilliseconds(void);
|
||||
|
@ -232,8 +264,12 @@ void ssglVertex3v(Vector u);
|
|||
void ssglAxisAlignedQuad(double l, double r, double t, double b, bool lone = true);
|
||||
void ssglAxisAlignedLineLoop(double l, double r, double t, double b);
|
||||
#define DEFAULT_TEXT_HEIGHT (11.5)
|
||||
#define SSGL_CALLBACK __stdcall
|
||||
typedef void SSGL_CALLBACK ssglCallbackFptr(void);
|
||||
#ifdef WIN32
|
||||
# define SSGL_CALLBACK __stdcall
|
||||
#else
|
||||
# define SSGL_CALLBACK
|
||||
#endif
|
||||
extern "C" { typedef void SSGL_CALLBACK ssglCallbackFptr(void); }
|
||||
void ssglTesselatePolygon(GLUtesselator *gt, SPolygon *p);
|
||||
void ssglFillPolygon(SPolygon *p);
|
||||
void ssglFillMesh(RgbColor color, SMesh *m, uint32_t h, uint32_t s1, uint32_t s2);
|
||||
|
|
4
ui.h
4
ui.h
|
@ -344,10 +344,12 @@ public:
|
|||
MNU_NEAREST_ORTHO,
|
||||
MNU_NEAREST_ISO,
|
||||
MNU_CENTER_VIEW,
|
||||
MNU_SHOW_TEXT_WND,
|
||||
MNU_SHOW_MENU_BAR,
|
||||
MNU_SHOW_TOOLBAR,
|
||||
MNU_SHOW_TEXT_WND,
|
||||
MNU_UNITS_INCHES,
|
||||
MNU_UNITS_MM,
|
||||
MNU_FULL_SCREEN,
|
||||
// Edit
|
||||
MNU_UNDO,
|
||||
MNU_REDO,
|
||||
|
|
|
@ -597,6 +597,16 @@ static bool ProcessKeyDown(WPARAM wParam)
|
|||
return false;
|
||||
}
|
||||
|
||||
void ToggleMenuBar(void)
|
||||
{
|
||||
// Implement me
|
||||
}
|
||||
bool MenuBarIsVisible(void)
|
||||
{
|
||||
// Implement me
|
||||
return true;
|
||||
}
|
||||
|
||||
void ShowTextWindow(bool visible)
|
||||
{
|
||||
ShowWindow(TextWnd, visible ? SW_SHOWNOACTIVATE : SW_HIDE);
|
||||
|
@ -640,6 +650,16 @@ void InvalidateGraphics(void)
|
|||
InvalidateRect(GraphicsWnd, NULL, false);
|
||||
}
|
||||
|
||||
void ToggleFullScreen(void)
|
||||
{
|
||||
// Implement me
|
||||
}
|
||||
bool FullScreenIsActive(void)
|
||||
{
|
||||
// Implement me
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t GetMilliseconds(void)
|
||||
{
|
||||
LARGE_INTEGER t, f;
|
||||
|
|
Loading…
Reference in New Issue