mirror of
https://github.com/leozide/leocad
synced 2025-01-29 20:34:50 +01:00
Linux fixes.
This commit is contained in:
parent
1d72f82c9b
commit
2e73fdfe71
5 changed files with 274 additions and 311 deletions
|
@ -528,7 +528,7 @@ static int lcGetMinifigSettings(lcMemFile& File)
|
|||
|
||||
do
|
||||
{
|
||||
strm.avail_in = min(sizeof(sDefaultSettings) - pos, CHUNK);
|
||||
strm.avail_in = lcMin(sizeof(sDefaultSettings) - pos, CHUNK);
|
||||
strm.next_in = in;
|
||||
|
||||
if (strm.avail_in == 0)
|
||||
|
|
|
@ -339,10 +339,10 @@ void Piece::InsertTime (unsigned short start, bool animation, unsigned short tim
|
|||
if (animation)
|
||||
{
|
||||
if (m_nFrameShow >= start)
|
||||
m_nFrameShow = min(m_nFrameShow + time, lcGetActiveProject()->GetTotalFrames());
|
||||
m_nFrameShow = lcMin(m_nFrameShow + time, lcGetActiveProject()->GetTotalFrames());
|
||||
|
||||
if (m_nFrameHide >= start)
|
||||
m_nFrameHide = min(m_nFrameHide + time, lcGetActiveProject()->GetTotalFrames());
|
||||
m_nFrameHide = lcMin(m_nFrameHide + time, lcGetActiveProject()->GetTotalFrames());
|
||||
|
||||
if (m_nFrameShow > lcGetActiveProject()->GetCurrentTime())
|
||||
Select (false, false, false);
|
||||
|
@ -350,10 +350,10 @@ void Piece::InsertTime (unsigned short start, bool animation, unsigned short tim
|
|||
else
|
||||
{
|
||||
if (m_nStepShow >= start)
|
||||
m_nStepShow = min(m_nStepShow + time, 255);
|
||||
m_nStepShow = lcMin(m_nStepShow + time, 255);
|
||||
|
||||
if (m_nStepHide >= start)
|
||||
m_nStepHide = min(m_nStepHide + time, 255);
|
||||
m_nStepHide = lcMin(m_nStepHide + time, 255);
|
||||
|
||||
if (m_nStepShow > lcGetActiveProject()->GetCurrentTime ())
|
||||
Select (false, false, false);
|
||||
|
@ -367,12 +367,12 @@ void Piece::RemoveTime (unsigned short start, bool animation, unsigned short tim
|
|||
if (animation)
|
||||
{
|
||||
if (m_nFrameShow >= start)
|
||||
m_nFrameShow = max(m_nFrameShow - time, 1);
|
||||
m_nFrameShow = lcMax(m_nFrameShow - time, 1);
|
||||
|
||||
if (m_nFrameHide == lcGetActiveProject()->GetTotalFrames())
|
||||
m_nFrameHide = lcGetActiveProject()->GetTotalFrames();
|
||||
else
|
||||
m_nFrameHide = max(m_nFrameHide - time, 1);
|
||||
m_nFrameHide = lcMax(m_nFrameHide - time, 1);
|
||||
|
||||
if (m_nFrameHide < lcGetActiveProject()->GetCurrentTime())
|
||||
Select (false, false, false);
|
||||
|
@ -380,10 +380,10 @@ void Piece::RemoveTime (unsigned short start, bool animation, unsigned short tim
|
|||
else
|
||||
{
|
||||
if (m_nStepShow >= start)
|
||||
m_nStepShow = max (m_nStepShow - time, 1);
|
||||
m_nStepShow = lcMax(m_nStepShow - time, 1);
|
||||
|
||||
if (m_nStepHide != 255)
|
||||
m_nStepHide = max (m_nStepHide - time, 1);
|
||||
m_nStepHide = lcMax(m_nStepHide - time, 1);
|
||||
|
||||
if (m_nStepHide < lcGetActiveProject()->GetCurrentTime())
|
||||
Select (false, false, false);
|
||||
|
|
|
@ -2566,7 +2566,7 @@ void Project::RenderOverlays(View* view)
|
|||
// Draw circle.
|
||||
glBegin(GL_LINE_LOOP);
|
||||
|
||||
float r = min(w, h) * 0.35f;
|
||||
float r = lcMin(w, h) * 0.35f;
|
||||
float cx = x + w / 2.0f;
|
||||
float cy = y + h / 2.0f;
|
||||
|
||||
|
@ -2580,7 +2580,7 @@ void Project::RenderOverlays(View* view)
|
|||
|
||||
glEnd();
|
||||
|
||||
const float OverlayCameraSquareSize = max(8.0f, (w+h)/200);
|
||||
const float OverlayCameraSquareSize = lcMax(8.0f, (w+h)/200);
|
||||
|
||||
// Draw squares.
|
||||
glBegin(GL_LINE_LOOP);
|
||||
|
@ -3094,7 +3094,7 @@ unsigned char Project::GetLastStep()
|
|||
{
|
||||
unsigned char last = 1;
|
||||
for (Piece* pPiece = m_pPieces; pPiece; pPiece = pPiece->m_pNext)
|
||||
last = max(last, pPiece->GetStepShow());
|
||||
last = lcMax(last, pPiece->GetStepShow());
|
||||
|
||||
return last;
|
||||
}
|
||||
|
@ -3414,10 +3414,10 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam)
|
|||
if (SystemDoDialog(LC_DLG_PICTURE_SAVE, &opts))
|
||||
{
|
||||
if (m_bAnimation)
|
||||
opts.to = min(opts.to, m_nTotalFrames);
|
||||
opts.to = lcMin(opts.to, m_nTotalFrames);
|
||||
else
|
||||
opts.to = min(opts.to, 255);
|
||||
opts.from = max(1, opts.from);
|
||||
opts.to = lcMin(opts.to, 255);
|
||||
opts.from = lcMax(1, opts.from);
|
||||
|
||||
if (opts.multiple)
|
||||
{
|
||||
|
@ -6479,7 +6479,7 @@ bool Project::StopTracking(bool bAccept)
|
|||
// Zoom in/out.
|
||||
float RatioX = (Right - Left) / Viewport[2];
|
||||
float RatioY = (Top - Bottom) / Viewport[3];
|
||||
float ZoomFactor = -max(RatioX, RatioY) + 0.75f;
|
||||
float ZoomFactor = -lcMax(RatioX, RatioY) + 0.75f;
|
||||
|
||||
lcVector3 Dir = Points[1] - Points[2];
|
||||
Eye = Eye + Dir * ZoomFactor;
|
||||
|
@ -6575,8 +6575,8 @@ void Project::GetSnapDistance(float* SnapXY, float* SnapZ) const
|
|||
int SXY, SZ;
|
||||
GetSnapIndex(&SXY, &SZ, NULL);
|
||||
|
||||
SXY = min(SXY, 9);
|
||||
SZ = min(SZ, 9);
|
||||
SXY = lcMin(SXY, 9);
|
||||
SZ = lcMin(SZ, 9);
|
||||
|
||||
*SnapXY = SnapXYTable[SXY];
|
||||
*SnapZ = SnapZTable[SZ];
|
||||
|
@ -6601,8 +6601,8 @@ void Project::GetSnapDistanceText(char* SnapXY, char* SnapZ) const
|
|||
int SXY, SZ;
|
||||
GetSnapIndex(&SXY, &SZ, NULL);
|
||||
|
||||
SXY = min(SXY, 9);
|
||||
SZ = min(SZ, 9);
|
||||
SXY = lcMin(SXY, 9);
|
||||
SZ = lcMin(SZ, 9);
|
||||
|
||||
strcpy(SnapXY, SnapXYText[SXY]);
|
||||
strcpy(SnapZ, SnapZText[SZ]);
|
||||
|
@ -8709,9 +8709,9 @@ void Project::MouseUpdateOverlays(View* view, int x, int y)
|
|||
int cy = vy + vh / 2;
|
||||
|
||||
float d = sqrtf((float)((cx - x) * (cx - x) + (cy - y) * (cy - y)));
|
||||
float r = min(vw, vh) * 0.35f;
|
||||
float r = lcMin(vw, vh) * 0.35f;
|
||||
|
||||
const float SquareSize = max(8.0f, (vw+vh)/200);
|
||||
const float SquareSize = lcMax(8.0f, (vw+vh)/200);
|
||||
|
||||
if ((d < r + SquareSize) && (d > r - SquareSize))
|
||||
{
|
||||
|
|
|
@ -501,12 +501,12 @@ void Terrain::SetControlPoints()
|
|||
m_Patches[i][j].control[(a*4+b)*3+1] = m_pControl[i*(4-1)+a][(j*(4-1)+b)*3+1];
|
||||
m_Patches[i][j].control[(a*4+b)*3+2] = m_pControl[i*(4-1)+a][(j*(4-1)+b)*3+2];
|
||||
|
||||
minX = min(minX, m_Patches[i][j].control[(a*4+b)*3]);
|
||||
maxX = max(maxX, m_Patches[i][j].control[(a*4+b)*3]);
|
||||
minY = min(minY, m_Patches[i][j].control[(a*4+b)*3+1]);
|
||||
maxY = max(maxY, m_Patches[i][j].control[(a*4+b)*3+1]);
|
||||
minZ = min(minZ, m_Patches[i][j].control[(a*4+b)*3+2]);
|
||||
maxZ = max(maxZ, m_Patches[i][j].control[(a*4+b)*3+2]);
|
||||
minX = lcMin(minX, m_Patches[i][j].control[(a*4+b)*3]);
|
||||
maxX = lcMax(maxX, m_Patches[i][j].control[(a*4+b)*3]);
|
||||
minY = lcMin(minY, m_Patches[i][j].control[(a*4+b)*3+1]);
|
||||
maxY = lcMax(maxY, m_Patches[i][j].control[(a*4+b)*3+1]);
|
||||
minZ = lcMin(minZ, m_Patches[i][j].control[(a*4+b)*3+2]);
|
||||
maxZ = lcMax(maxZ, m_Patches[i][j].control[(a*4+b)*3+2]);
|
||||
}
|
||||
m_Patches[i][j].InitBox(minX, maxX, minY, maxY, minZ, maxZ);
|
||||
}
|
||||
|
|
|
@ -36,17 +36,9 @@ struct LC_MINIFIGDLG_STRUCT
|
|||
GtkWidget *angles[LC_MFW_NUMITEMS];
|
||||
GtkWidget *preview;
|
||||
GtkWidget *combo;
|
||||
GtkWidget *dlg;
|
||||
};
|
||||
|
||||
// User wants to add the minifig to the project
|
||||
static void minifigdlg_ok(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
// LC_MINIFIGDLG_STRUCT* s = (LC_MINIFIGDLG_STRUCT*)data;
|
||||
// LC_MINIFIGDLG_OPTS* opts = (LC_MINIFIGDLG_OPTS*)s->data;
|
||||
|
||||
dlg_end (LC_OK);
|
||||
}
|
||||
|
||||
// A new color was selected from the menu
|
||||
static void minifigdlg_color_response(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
|
@ -149,13 +141,12 @@ static void minifigdlg_updateselection (LC_MINIFIGDLG_STRUCT* s)
|
|||
for (int i = 0; i < LC_MFW_NUMITEMS; i++)
|
||||
{
|
||||
int index = s->wizard->GetSelectionIndex(i);
|
||||
GtkCombo* Combo = GTK_COMBO(s->pieces[i]);
|
||||
|
||||
gtk_signal_handler_block_by_func (GTK_OBJECT (GTK_COMBO (s->pieces[i])->entry),
|
||||
GTK_SIGNAL_FUNC (minifigdlg_piece_changed), NULL);
|
||||
gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (s->pieces[i])->entry), s->wizard->mSettings[i][index].Description);
|
||||
gtk_list_select_item (GTK_LIST (GTK_COMBO (s->pieces[i])->list), index);
|
||||
gtk_signal_handler_unblock_by_func (GTK_OBJECT (GTK_COMBO (s->pieces[i])->entry),
|
||||
GTK_SIGNAL_FUNC (minifigdlg_piece_changed), NULL);
|
||||
gtk_signal_handler_block_by_func(GTK_OBJECT(Combo->entry), GTK_SIGNAL_FUNC(minifigdlg_piece_changed), NULL);
|
||||
gtk_entry_set_text(GTK_ENTRY(Combo->entry), s->wizard->mSettings[i][index].Description);
|
||||
gtk_list_select_item(GTK_LIST(Combo->list), index);
|
||||
gtk_signal_handler_unblock_by_func(GTK_OBJECT(Combo->entry), GTK_SIGNAL_FUNC(minifigdlg_piece_changed), NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -224,10 +215,8 @@ static void minifigdlg_createpair (LC_MINIFIGDLG_STRUCT* info, int idx, int num,
|
|||
gtk_widget_show(combo);
|
||||
gtk_table_attach(GTK_TABLE(table), combo, 0, 1, idx, idx+1,
|
||||
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) GTK_EXPAND, 0, 0);
|
||||
gtk_widget_set_usize (combo, 60, 25);
|
||||
gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(combo)->entry), FALSE);
|
||||
gtk_signal_connect (GTK_OBJECT (GTK_COMBO (combo)->entry), "changed",
|
||||
GTK_SIGNAL_FUNC (minifigdlg_piece_changed), NULL);
|
||||
gtk_signal_connect(GTK_OBJECT(GTK_COMBO(combo)->entry), "changed", GTK_SIGNAL_FUNC(minifigdlg_piece_changed), NULL);
|
||||
gtk_object_set_data(GTK_OBJECT(GTK_COMBO(combo)->entry), "info", info);
|
||||
|
||||
color = info->colors[num] = gtk_button_new_with_label("");
|
||||
|
@ -236,10 +225,8 @@ static void minifigdlg_createpair (LC_MINIFIGDLG_STRUCT* info, int idx, int num,
|
|||
gtk_object_set_data(GTK_OBJECT(color), "color", &info->wizard->m_Colors[num]);
|
||||
gtk_object_set_data(GTK_OBJECT(color), "info", info);
|
||||
gtk_widget_set_usize(color, 40, 25);
|
||||
gtk_signal_connect (GTK_OBJECT (color), "clicked",
|
||||
GTK_SIGNAL_FUNC (minifigdlg_color_clicked), info);
|
||||
gtk_table_attach (GTK_TABLE (table), color, 1, 2, idx, idx+1,
|
||||
(GtkAttachOptions) GTK_FILL, (GtkAttachOptions) GTK_EXPAND, 0, 0);
|
||||
gtk_signal_connect(GTK_OBJECT(color), "clicked", GTK_SIGNAL_FUNC(minifigdlg_color_clicked), info);
|
||||
gtk_table_attach(GTK_TABLE(table), color, 1, 2, idx, idx+1, (GtkAttachOptions) GTK_FILL, (GtkAttachOptions) GTK_EXPAND, 0, 0);
|
||||
|
||||
if ((num == LC_MFW_TORSO) || (num == LC_MFW_HIPS))
|
||||
{
|
||||
|
@ -253,10 +240,10 @@ static void minifigdlg_createpair (LC_MINIFIGDLG_STRUCT* info, int idx, int num,
|
|||
spin = info->angles[num] = gtk_spin_button_new(GTK_ADJUSTMENT(adj), 1, 0);
|
||||
gtk_widget_show(spin);
|
||||
gtk_object_set_data(GTK_OBJECT(color), "info", info);
|
||||
// gtk_widget_set_usize (spin, 40, -1);
|
||||
gtk_table_attach (GTK_TABLE (table), spin, 2, 3, idx, idx+1,
|
||||
(GtkAttachOptions) GTK_FILL, (GtkAttachOptions) GTK_EXPAND, 0, 0);
|
||||
gtk_table_attach(GTK_TABLE(table), spin, 2, 3, idx, idx+1, (GtkAttachOptions) GTK_FILL, (GtkAttachOptions) GTK_EXPAND, 0, 0);
|
||||
gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(spin), TRUE);
|
||||
gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(spin), TRUE);
|
||||
gtk_entry_set_width_chars(GTK_ENTRY(spin), 4);
|
||||
}
|
||||
|
||||
int minifigdlg_execute(void* param)
|
||||
|
@ -265,25 +252,20 @@ int minifigdlg_execute (void* param)
|
|||
GtkWidget *dlg, *button;
|
||||
LC_MINIFIGDLG_STRUCT s;
|
||||
int i;
|
||||
int ret;
|
||||
|
||||
memset(&s, 0, sizeof(s));
|
||||
s.wizard = (MinifigWizard*)param;
|
||||
|
||||
dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_transient_for (GTK_WINDOW (dlg), GTK_WINDOW (((GtkWidget*)(*main_window))));
|
||||
gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
|
||||
GTK_SIGNAL_FUNC (dlg_delete_callback), NULL);
|
||||
gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
|
||||
GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
|
||||
gtk_widget_set_usize (dlg, 600, 360);
|
||||
gtk_window_set_title (GTK_WINDOW (dlg), "Minifig Wizard");
|
||||
// gtk_window_set_policy (GTK_WINDOW (dlg), FALSE, FALSE, FALSE);
|
||||
dlg = gtk_dialog_new_with_buttons("Minifig Wizard", GTK_WINDOW(((GtkWidget*)(*main_window))),
|
||||
(GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
|
||||
GTK_STOCK_OK, GTK_RESPONSE_OK, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(dlg), 5);
|
||||
gtk_widget_realize(dlg);
|
||||
s.dlg = dlg;
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 10);
|
||||
gtk_widget_show (vbox);
|
||||
gtk_container_add (GTK_CONTAINER (dlg), vbox);
|
||||
gtk_container_border_width (GTK_CONTAINER (vbox), 5);
|
||||
vbox = GTK_DIALOG(dlg)->vbox;
|
||||
gtk_box_set_spacing(GTK_BOX(vbox), 10);
|
||||
|
||||
hbox = gtk_hbox_new(FALSE, 5);
|
||||
gtk_widget_show(hbox);
|
||||
|
@ -338,42 +320,17 @@ int minifigdlg_execute (void* param)
|
|||
s.combo = gtk_combo_new();
|
||||
gtk_widget_show(s.combo);
|
||||
gtk_box_pack_start(GTK_BOX(hbox), s.combo, FALSE, TRUE, 0);
|
||||
gtk_signal_connect (GTK_OBJECT (GTK_COMBO (s.combo)->entry), "changed",
|
||||
GTK_SIGNAL_FUNC (minifigdlg_load), &s);
|
||||
gtk_signal_connect(GTK_OBJECT(GTK_COMBO(s.combo)->entry), "changed", GTK_SIGNAL_FUNC(minifigdlg_load), &s);
|
||||
|
||||
button = gtk_button_new_with_label("Save");
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
GTK_SIGNAL_FUNC (minifigdlg_save), &s);
|
||||
gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(minifigdlg_save), &s);
|
||||
gtk_widget_show(button);
|
||||
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, TRUE, 0);
|
||||
gtk_widget_set_usize (button, 70, 25);
|
||||
|
||||
button = gtk_button_new_with_label("Delete");
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
GTK_SIGNAL_FUNC (minifigdlg_delete), &s);
|
||||
gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(minifigdlg_delete), &s);
|
||||
gtk_widget_show(button);
|
||||
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, TRUE, 0);
|
||||
gtk_widget_set_usize (button, 70, 25);
|
||||
|
||||
button = gtk_button_new_with_label ("OK");
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
GTK_SIGNAL_FUNC (minifigdlg_ok), &s);
|
||||
gtk_widget_show (button);
|
||||
gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, TRUE, 0);
|
||||
gtk_widget_set_usize (button, 70, 25);
|
||||
GtkAccelGroup *accel_group = gtk_accel_group_new ();
|
||||
gtk_window_add_accel_group (GTK_WINDOW (dlg), accel_group);
|
||||
gtk_widget_add_accelerator (button, "clicked", accel_group,
|
||||
GDK_Return, (GdkModifierType)0, GTK_ACCEL_VISIBLE);
|
||||
|
||||
button = gtk_button_new_with_label ("Cancel");
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
GTK_SIGNAL_FUNC (dlg_default_callback), GINT_TO_POINTER (LC_CANCEL));
|
||||
gtk_widget_show (button);
|
||||
gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, TRUE, 0);
|
||||
gtk_widget_set_usize (button, 70, 25);
|
||||
gtk_widget_add_accelerator (button, "clicked", accel_group,
|
||||
GDK_Escape, (GdkModifierType)0, GTK_ACCEL_VISIBLE);
|
||||
|
||||
// Fill the combo boxes with the available pieces
|
||||
for (i = 0; i < LC_MFW_NUMITEMS; i++)
|
||||
|
@ -386,12 +343,10 @@ int minifigdlg_execute (void* param)
|
|||
|
||||
if (names != NULL)
|
||||
{
|
||||
gtk_signal_handler_block_by_func(GTK_OBJECT(GTK_COMBO(s.pieces[i])->entry),
|
||||
GTK_SIGNAL_FUNC(minifigdlg_piece_changed), NULL);
|
||||
gtk_signal_handler_block_by_func(GTK_OBJECT(GTK_COMBO(s.pieces[i])->entry), GTK_SIGNAL_FUNC(minifigdlg_piece_changed), NULL);
|
||||
gtk_combo_set_popdown_strings(GTK_COMBO(s.pieces[i]), names);
|
||||
g_list_free(names);
|
||||
gtk_signal_handler_unblock_by_func(GTK_OBJECT(GTK_COMBO(s.pieces[i])->entry),
|
||||
GTK_SIGNAL_FUNC(minifigdlg_piece_changed), NULL);
|
||||
gtk_signal_handler_unblock_by_func(GTK_OBJECT(GTK_COMBO(s.pieces[i])->entry), GTK_SIGNAL_FUNC(minifigdlg_piece_changed), NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -401,9 +356,17 @@ int minifigdlg_execute (void* param)
|
|||
gtk_widget_show(dlg);
|
||||
|
||||
for (i = 0; i < LC_MFW_NUMITEMS; i++)
|
||||
{
|
||||
set_button_pixmap2(s.colors[i], gColorList[s.wizard->m_Colors[i]].Value);
|
||||
|
||||
if (gtk_dialog_run(GTK_DIALOG(dlg)) == GTK_RESPONSE_OK)
|
||||
{
|
||||
ret = LC_OK;
|
||||
}
|
||||
else
|
||||
ret = LC_CANCEL;
|
||||
|
||||
gtk_widget_destroy(dlg);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
return dlg_domodal(dlg, LC_CANCEL);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue