Skip to content

Commit 50b0a01

Browse files
author
wawa
committed
merge in most gui updates from authors source. among others tabs should now behave corretcly.
1 parent e52edfe commit 50b0a01

16 files changed

+367
-167
lines changed

Diff for: vpdf/VPDF_strings.h

+9-1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@
104104
#define MSG_SEARCH_END 81
105105
#define MSG_SEARCH_LABEL 82
106106
#define MSG_SLIDER_PAGE 83
107+
#define MSG_MENU_CLOSETAB 84
108+
#define MSG_MENU_SAVEFILE 85
107109

108110
#endif /* CATCOMP_NUMBERS */
109111

@@ -151,6 +153,7 @@
151153
#define MSG_MENU_NEWWIN_STR "New Window..."
152154
#define MSG_MENU_NEWTAB_STR "New Tab"
153155
#define MSG_MENU_FILE_STR "Open File..."
156+
#define MSG_MENU_FILE_SAVE_STR "Save File..."
154157
#define MSG_MENU_RECENT_STR "Open Recent..."
155158
#define MSG_MENU_PRINT_STR "Print..."
156159
#define MSG_MENU_ABOUT_STR "About..."
@@ -194,7 +197,7 @@
194197
#define MSG_SEARCH_END_STR "End of Document"
195198
#define MSG_SEARCH_LABEL_STR "Search:"
196199
#define MSG_SLIDER_PAGE_STR "Page %ld"
197-
200+
#define MSG_MENU_CLOSETAB_STR "Close Tab"
198201
#endif /* CATCOMP_STRINGS */
199202

200203

@@ -292,6 +295,9 @@ static const struct CatCompArrayType CatCompArray[] =
292295
{MSG_SEARCH_END, (STRPTR)MSG_SEARCH_END_STR},
293296
{MSG_SEARCH_LABEL, (STRPTR)MSG_SEARCH_LABEL_STR},
294297
{MSG_SLIDER_PAGE, (STRPTR)MSG_SLIDER_PAGE_STR},
298+
{MSG_MENU_CLOSETAB, (STRPTR)MSG_MENU_CLOSETAB_STR},
299+
{MSG_MENU_SAVEFILE, (STRPTR)MSG_MENU_FILE_SAVE_STR}
300+
295301
};
296302

297303
#endif /* CATCOMP_ARRAY */
@@ -391,6 +397,8 @@ enum
391397
MSG_SEARCH_END_ID,
392398
MSG_SEARCH_LABEL_ID,
393399
MSG_SLIDER_PAGE_ID,
400+
MSG_MENU_TABCLOSE_ID,
401+
MSG_MENU_SAVEFILE_ID,
394402
NEW_CATCOMP_ARRAY_ID_COUNT
395403
};
396404
#endif /* NEW_CATCOMP_ARRAY_IDS */

Diff for: vpdf/application.c

+64-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ struct Data
8585
enum
8686
{
8787
MEN_PROJECT = 1,
88-
MEN_ABOUT, MEN_OPEN_FILE, MEN_OPEN_URL, MEN_TAB_NEW, MEN_TAB_CLOSE, MEN_WINDOW_NEW, MEN_WINDOW_CLOSE,
88+
MEN_ABOUT, MEN_OPEN_FILE, MEN_OPEN_URL, MEN_SAVE_FILE, MEN_TAB_NEW, MEN_TAB_CLOSE, MEN_WINDOW_NEW, MEN_WINDOW_CLOSE,
8989
MEN_OPEN_RECENT,
9090
MEN_PRINT,
9191
MEN_QUIT,
@@ -133,6 +133,7 @@ static const struct MUI_Command rexxcommands[] =
133133
static CONST_STRPTR __credits =
134134
"\33b%p\33n\n"
135135
"\tMichal 'kiero' Wozniak\n\n"
136+
"\tAROS port: Craig 'Watto' Watson\n\n"
136137
"\33b%W\33n\n"
137138
138139
"\33b%P\33n\n"
@@ -193,6 +194,12 @@ DEFNEW
193194
CreateMenuitem(LOCSTR(MSG_MENU_FILE), 0)),
194195
MUIA_Family_Child, (IPTR) (menu[MEN_OPEN_RECENT] =
195196
CreateMenuitem(LOCSTR(MSG_MENU_RECENT), 0)),
197+
MUIA_Family_Child, (IPTR) CreateMenuitem(NM_BARLABEL, NULL),
198+
MUIA_Family_Child, (IPTR) (menu[MEN_SAVE_FILE] =
199+
CreateMenuitem(LOCSTR(MSG_MENU_SAVEFILE), "S")),
200+
201+
MUIA_Family_Child, (IPTR) (menu[MEN_TAB_CLOSE] =
202+
CreateMenuitem(LOCSTR(MSG_MENU_TABCLOSE), "X")),
196203
MUIA_Family_Child, (IPTR) (menu[MEN_PRINT] =
197204
CreateMenuitem(LOCSTR(MSG_MENU_PRINT), "P")),
198205
MUIA_Family_Child, (IPTR) CreateMenuitem(NM_BARLABEL, NULL),
@@ -266,8 +273,10 @@ DEFNEW
266273
DoMethod((Object *)menu[MEN_ABOUT], MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, obj, 1, MUIM_VPDF_About);
267274
DoMethod((Object *)menu[MEN_QUIT], MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, obj, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
268275
DoMethod((Object *)menu[MEN_TAB_NEW], MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, obj, 2, MUIM_VPDF_CreateTab, 0);
276+
DoMethod((Object *)menu[MEN_TAB_CLOSE], MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, obj, 2, MUIM_VPDF_CloseTab, 0);
269277
DoMethod((Object *)menu[MEN_WINDOW_NEW], MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, obj, 1, MUIM_VPDF_CreateWindow);
270278
DoMethod((Object *)menu[MEN_OPEN_FILE], MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, obj, 4, MUIM_VPDF_OpenFile, 0, NULL, MUIV_VPDFWindow_OpenFile_CurrentTabIfEmpty);
279+
DoMethod((Object *)menu[MEN_SAVE_FILE], MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, obj, 2, MUIM_VPDF_SaveFile, 0);
271280
DoMethod((Object *)menu[MEN_SETTINGS_SETTINGS], MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime,settingswin, 3, MUIM_Set, MUIA_Window_Open, TRUE);
272281
DoMethod((Object *)menu[MEN_SETTINGS_SAVESETTINGS], MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime,settingswin, 1, MUIM_VPDFSettings_Save);
273282
DoMethod((Object *)menu[MEN_SETTINGS_MUI], MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, obj, 2, MUIM_Application_OpenConfigWindow, 0);
@@ -405,6 +414,18 @@ DEFMMETHOD(VPDF_CreateTab)
405414
return (ULONG)-1;
406415
}
407416

417+
DEFMMETHOD(VPDF_CloseTab)
418+
{
419+
Object *window = (Object*)DoMethod(obj, MUIM_VPDF_FindWindowByID, msg->windowid == 0 ? MUIV_VPDF_FindWindowByID_Active : msg->windowid);
420+
421+
if (window != NULL)
422+
{
423+
return DoMethod(window, MUIM_VPDFWindow_CloseTab);
424+
}
425+
426+
return (ULONG)-1;
427+
}
428+
408429
DEFMMETHOD(VPDF_CreateWindow)
409430
{
410431
GETDATA;
@@ -1019,6 +1040,46 @@ DEFMMETHOD(VPDF_SelectionCopy)
10191040

10201041
return TRUE;
10211042
}
1043+
1044+
1045+
DEFMMETHOD(VPDF_SaveFile)
1046+
{
1047+
GETDATA;
1048+
char *filename = msg->filename;
1049+
int mode = msg->mode;
1050+
Object *window = (Object*)DoMethod(obj, MUIM_VPDF_FindWindowByID, msg->windowid == 0 ? MUIV_VPDF_FindWindowByID_Active : msg->windowid);
1051+
1052+
/* if (window == NULL)
1053+
{
1054+
window = (Object*)DoMethod(obj, MUIM_VPDF_CreateWindow);
1055+
mode = MUIV_VPDFWindow_OpenFile_CurrentTabIfEmpty;
1056+
}
1057+
*/
1058+
1059+
if (filename == NULL)
1060+
{
1061+
filename = (char*)DoMethod(_app(obj), MUIM_VPDF_RequestFile,
1062+
MUIV_VPDF_RequestFile_Save,
1063+
NULL,
1064+
NULL,
1065+
NULL);
1066+
1067+
if (filename == NULL)
1068+
return FALSE;
1069+
}
1070+
1071+
if (window != NULL)
1072+
{
1073+
if (DoMethod(window, MUIM_VPDFWindow_SaveFile, filename, mode))
1074+
{
1075+
1076+
}
1077+
1078+
}
1079+
1080+
return TRUE;
1081+
}
1082+
10221083
/* */
10231084

10241085
BEGINMTABLE
@@ -1030,7 +1091,9 @@ BEGINMTABLE
10301091
DECMMETHOD(Export)
10311092
DECMMETHOD(DragDrop)
10321093
DECMMETHOD(VPDF_OpenFile)
1094+
DECMMETHOD(VPDF_SaveFile)
10331095
DECMMETHOD(VPDF_CreateTab)
1096+
DECMMETHOD(VPDF_CloseTab)
10341097
DECMMETHOD(VPDF_CreateWindow)
10351098
DECMMETHOD(VPDF_HandleAppMessage)
10361099
DECMMETHOD(VPDF_RequestFile)

Diff for: vpdf/application.h

+8-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
#define MUIA_VPDF_Renderer (MUIA_VPDF_TagBase + 1)
77
#define MUIA_VPDF_Locked (MUIA_VPDF_TagBase + 2)
88

9-
#define MUIM_VPDF_OpenFile (MUIM_VPDF_Dummy + 1)
10-
#define MUIM_VPDF_CreateTab (MUIM_VPDF_Dummy + 2)
9+
#define MUIM_VPDF_OpenFile (MUIM_VPDF_Dummy + 1)
10+
#define MUIM_VPDF_CreateTab (MUIM_VPDF_Dummy + 2)
1111
#define MUIM_VPDF_CreateWindow (MUIM_VPDF_Dummy + 3)
1212
#define MUIM_VPDF_HandleAppMessage (MUIM_VPDF_Dummy + 4)
1313
#define MUIM_VPDF_RequestFile (MUIM_VPDF_Dummy + 5)
@@ -24,11 +24,17 @@
2424
#define MUIM_VPDF_About (MUIM_VPDF_Dummy + 16)
2525
#define MUIM_VPDF_PrintDocument (MUIM_VPDF_Dummy + 17)
2626
#define MUIM_VPDF_SelectionCopy (MUIM_VPDF_Dummy + 18)
27+
#define MUIM_VPDF_SaveFile (MUIM_VPDF_Dummy + 19)
28+
#define MUIM_VPDF_CloseTab (MUIM_VPDF_Dummy + 20)
2729

2830
struct MUIP_VPDF_OpenFile{ULONG MethodID; int windowid; char *filename; int mode;}; // mode is MUIV_VPDFWindow_OpenFile_XXX
31+
struct MUIP_VPDF_SaveFile{ULONG MethodID; int windowid; char *filename; int mode;}; // mode is MUIV_VPDFWindow_OpenFile_XXX
2932
struct MUIP_VPDF_CreateTab{ULONG MethodID; int windowid;};
3033
struct MUIP_VPDF_CreateWindow{ULONG MethodID;};
3134

35+
struct MUIP_VPDF_CloseTab{ULONG MethodID; int windowid;};
36+
37+
3238
struct MUIP_VPDF_RequestFile{ULONG MethodID; int mode; char *initialfile; char *initialdir; char *initialpath;};
3339
struct MUIP_VPDF_OpenRecentFile{ULONG MethodID; int windowid; int idx;};
3440
struct MUIP_VPDF_FindWindowByID{ULONG MethodID; int windowid;};

Diff for: vpdf/fontcache.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1415,7 +1415,7 @@ static char *fcSfntNameTranscode(FT_SfntName *sname)
14151415
if (!strcmp (fromcode, FC_ENCODING_MAC_ROMAN))
14161416
{
14171417
FcChar8 *u8;
1418-
const FcCharMap *map = FcFreeTypeGetPrivateMap (ft_encoding_apple_roman);
1418+
const FcCharMap *map = IntFcFreeTypeGetPrivateMap (ft_encoding_apple_roman);
14191419
FcChar8 *src = (FcChar8 *) sname->string;
14201420
int src_len = sname->string_len;
14211421

@@ -1733,7 +1733,7 @@ struct fontpattern *fcQueryFace(const FT_Face face, char *fname, int id)
17331733
exclusiveLang = 0;
17341734
break;
17351735
}
1736-
exclusiveLang = FcCodePageRange[i].lang;
1736+
exclusiveLang = (char*)FcCodePageRange[i].lang;
17371737
}
17381738
}
17391739
}

Diff for: vpdf/mcc/continuouslayout_class.c

+31-17
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@
5353
#include "system/functions.h"
5454
#include "system/gentexture.h"
5555

56+
#define DEBUG 1
57+
#include <aros/debug.h>
58+
59+
5660
struct Data
5761
{
5862
void *doc;
@@ -62,7 +66,7 @@ struct Data
6266
struct MUI_EventHandlerNode eh;
6367
int clicky;
6468
int clickx;
65-
int page;
69+
LONG page;
6670
int columns;
6771
int scaling;
6872
float zoom;
@@ -103,7 +107,7 @@ DEFNEW
103107

104108
data->views = malloc(sizeof(Object*) * pdfGetPagesNum(data->doc));
105109
#warning TODO: handle failure
106-
110+
LONG top=0;
107111
for(i=0; i<pdfGetPagesNum(data->doc); i++)
108112
{
109113
float mediawidth = pdfGetPageMediaWidth(data->doc, i + 1);
@@ -117,6 +121,7 @@ DEFNEW
117121
MUIA_PageView_MediaHeight, (int)mediaheight,
118122
MUIA_PageView_Information, information,
119123
MUIA_PageView_IsPreview, data->ispreview,
124+
MUIA_PageView_TopEdge, top,
120125
//MUIA_FixWidth , 128,
121126
//MUIA_FixHeight , 128,
122127
End;
@@ -129,6 +134,7 @@ DEFNEW
129134
//DoMethod(obj, OM_ADDMEMBER, RectangleObject, End);
130135

131136
data->views[i] = pageview;
137+
top +=(int)mediaheight;
132138
}
133139

134140
/* only notify about new 'focused' page if this is not previews view (outlines) */
@@ -214,7 +220,6 @@ DEFSET
214220
}
215221
//set(obj, MUIA_Virtgroup_Top, (LONG)xget(pageview, MUIA_PageView_LayoutTop));
216222
}
217-
218223
MUI_Redraw(data->views[prevpage], MADF_DRAWOBJECT);
219224
MUI_Redraw(data->views[newpage], MADF_DRAWOBJECT);
220225

@@ -362,47 +367,56 @@ METHOD continuouslayoutFindViewForPage(struct IClass *cl, Object *obj, struct MU
362367

363368
METHOD continuouslayoutIsPageVisible(struct IClass *cl, Object *obj, struct MUIP_DocumentLayout_IsPageVisible *msg)
364369
{
365-
GETDATA;
370+
GETDATA;
366371
Object *pageview = data->views[msg->page - 1];
367372

368-
LONG top = xget(pageview, MUIA_TopEdge) - (LONG)_addtop(obj);
369-
LONG height = xget(pageview, MUIA_Height);
373+
//work around overflow in TopEdge... why is this happening, it's meant to be a long?
370374

371-
/* check constraints for object and group */
375+
LONG top = (LONG)xget(pageview, MUIA_TopEdge) - (LONG)_addtop(obj);
376+
LONG height = (LONG)xget(pageview, MUIA_Height);
372377

378+
LONG topedge = ((long)xget(pageview, MUIA_PageView_TopEdge)*(float)((float)height / xget(obj, MUIA_PageView_MediaHeight) )) -(long)xget(obj, MUIA_Virtgroup_Top);
379+
380+
D(kprintf("topedge: %ld, virttop %ld, mediaheight: %ld, height: %ld\n",topedge,(long)xget(obj, MUIA_Virtgroup_Top), (long)xget(obj, MUIA_PageView_MediaHeight), height));
381+
/* check constraints for object and group */
382+
top = topedge; //- (long)_addtop(obj);
373383
LONG nTop = top - _top(obj);
374384
LONG nBottom = nTop + height;
375385
LONG gBottom = _height(obj) + 5; /* 5 is a margin */
376386
LONG gTop = -5;
377387

378-
//printf("page %d borders:%d %d, borders:%d,%d\n", msg->page, nTop, nBottom, gTop, gBottom);
388+
389+
379390

380391
if (nBottom < gTop)
381392
{
382-
/* bottom is invisible */
393+
D(kprintf("no page %d borders:%ld %ld, borders:%ld,%ld\n", msg->page, nTop, nBottom, gTop, gBottom));
394+
/* bottom is invisible */
383395
return FALSE;
384396
}
385397

386398
if (nTop > gBottom)
387399
{
388-
/* top is invisible */
400+
D(kprintf("no page %d borders:%ld %ld, borders:%ld,%ld\n", msg->page, nTop, nBottom, gTop, gBottom));
401+
/* top is invisible */
389402
return FALSE;
390403
}
404+
D(kprintf("YES page %d borders:%ld %ld, borders:%ld,%ld\n", msg->page, nTop, nBottom, gTop, gBottom));
391405

392-
return TRUE;
406+
return TRUE;
393407
}
394408

395409
METHOD continuouslayoutClippedPageOffset(struct IClass *cl, Object *obj, struct MUIP_ContinuousLayout_ClippedPageOffset *msg)
396410
{
397-
GETDATA;
411+
GETDATA;
398412
Object *pageview = data->views[msg->page - 1];
399413

400-
LONG top = xget(pageview, MUIA_TopEdge) - (LONG)_addtop(obj);
401-
LONG height = xget(pageview, MUIA_Height);
402-
414+
LONG top = (LONG)xget(pageview, MUIA_TopEdge) - (LONG)_addtop(obj);
415+
LONG height = (LONG)xget(pageview, MUIA_Height);
403416
/* check constraints for object and group */
417+
LONG topedge = ((LONG)xget(pageview, MUIA_PageView_TopEdge)*(float)((float)height / xget(obj, MUIA_PageView_MediaHeight) )) -(LONG)xget(obj, MUIA_Virtgroup_Top);
404418

405-
LONG nTop = top - _top(obj);
419+
LONG nTop = topedge - _top(obj);
406420
LONG nBottom = nTop + height;
407421
LONG gBottom = _height(obj) + 5; /* 5 is a margin */
408422
LONG gTop = -5;
@@ -419,7 +433,7 @@ METHOD continuouslayoutClippedPageOffset(struct IClass *cl, Object *obj, struct
419433
if (nTop < gTop && nTop + height > gTop) /* partialy clipped outside the top edge. scroll to the bottom */
420434
nTop = gTop;
421435

422-
return nTop - oldnTop;
436+
return nTop - oldnTop;
423437
}
424438

425439
METHOD continuouslayoutShow(struct IClass *cl, Object *obj, struct MUIP_Show *msg)

0 commit comments

Comments
 (0)