Skip to content

Commit

Permalink
merge in most gui updates from authors source. among others tabs shou…
Browse files Browse the repository at this point in the history
…ld now behave corretcly.
  • Loading branch information
wawa committed Jun 9, 2019
1 parent e52edfe commit 50b0a01
Show file tree
Hide file tree
Showing 16 changed files with 367 additions and 167 deletions.
10 changes: 9 additions & 1 deletion vpdf/VPDF_strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@
#define MSG_SEARCH_END 81
#define MSG_SEARCH_LABEL 82
#define MSG_SLIDER_PAGE 83
#define MSG_MENU_CLOSETAB 84
#define MSG_MENU_SAVEFILE 85

#endif /* CATCOMP_NUMBERS */

Expand Down Expand Up @@ -151,6 +153,7 @@
#define MSG_MENU_NEWWIN_STR "New Window..."
#define MSG_MENU_NEWTAB_STR "New Tab"
#define MSG_MENU_FILE_STR "Open File..."
#define MSG_MENU_FILE_SAVE_STR "Save File..."
#define MSG_MENU_RECENT_STR "Open Recent..."
#define MSG_MENU_PRINT_STR "Print..."
#define MSG_MENU_ABOUT_STR "About..."
Expand Down Expand Up @@ -194,7 +197,7 @@
#define MSG_SEARCH_END_STR "End of Document"
#define MSG_SEARCH_LABEL_STR "Search:"
#define MSG_SLIDER_PAGE_STR "Page %ld"

#define MSG_MENU_CLOSETAB_STR "Close Tab"
#endif /* CATCOMP_STRINGS */


Expand Down Expand Up @@ -292,6 +295,9 @@ static const struct CatCompArrayType CatCompArray[] =
{MSG_SEARCH_END, (STRPTR)MSG_SEARCH_END_STR},
{MSG_SEARCH_LABEL, (STRPTR)MSG_SEARCH_LABEL_STR},
{MSG_SLIDER_PAGE, (STRPTR)MSG_SLIDER_PAGE_STR},
{MSG_MENU_CLOSETAB, (STRPTR)MSG_MENU_CLOSETAB_STR},
{MSG_MENU_SAVEFILE, (STRPTR)MSG_MENU_FILE_SAVE_STR}

};

#endif /* CATCOMP_ARRAY */
Expand Down Expand Up @@ -391,6 +397,8 @@ enum
MSG_SEARCH_END_ID,
MSG_SEARCH_LABEL_ID,
MSG_SLIDER_PAGE_ID,
MSG_MENU_TABCLOSE_ID,
MSG_MENU_SAVEFILE_ID,
NEW_CATCOMP_ARRAY_ID_COUNT
};
#endif /* NEW_CATCOMP_ARRAY_IDS */
Expand Down
65 changes: 64 additions & 1 deletion vpdf/application.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ struct Data
enum
{
MEN_PROJECT = 1,
MEN_ABOUT, MEN_OPEN_FILE, MEN_OPEN_URL, MEN_TAB_NEW, MEN_TAB_CLOSE, MEN_WINDOW_NEW, MEN_WINDOW_CLOSE,
MEN_ABOUT, MEN_OPEN_FILE, MEN_OPEN_URL, MEN_SAVE_FILE, MEN_TAB_NEW, MEN_TAB_CLOSE, MEN_WINDOW_NEW, MEN_WINDOW_CLOSE,
MEN_OPEN_RECENT,
MEN_PRINT,
MEN_QUIT,
Expand Down Expand Up @@ -133,6 +133,7 @@ static const struct MUI_Command rexxcommands[] =
static CONST_STRPTR __credits =
"\33b%p\33n\n"
"\tMichal 'kiero' Wozniak\n\n"
"\tAROS port: Craig 'Watto' Watson\n\n"
"\33b%W\33n\n"
"\twozniak_m@interia.pl\n\n"
"\33b%P\33n\n"
Expand Down Expand Up @@ -193,6 +194,12 @@ DEFNEW
CreateMenuitem(LOCSTR(MSG_MENU_FILE), 0)),
MUIA_Family_Child, (IPTR) (menu[MEN_OPEN_RECENT] =
CreateMenuitem(LOCSTR(MSG_MENU_RECENT), 0)),
MUIA_Family_Child, (IPTR) CreateMenuitem(NM_BARLABEL, NULL),
MUIA_Family_Child, (IPTR) (menu[MEN_SAVE_FILE] =
CreateMenuitem(LOCSTR(MSG_MENU_SAVEFILE), "S")),

MUIA_Family_Child, (IPTR) (menu[MEN_TAB_CLOSE] =
CreateMenuitem(LOCSTR(MSG_MENU_TABCLOSE), "X")),
MUIA_Family_Child, (IPTR) (menu[MEN_PRINT] =
CreateMenuitem(LOCSTR(MSG_MENU_PRINT), "P")),
MUIA_Family_Child, (IPTR) CreateMenuitem(NM_BARLABEL, NULL),
Expand Down Expand Up @@ -266,8 +273,10 @@ DEFNEW
DoMethod((Object *)menu[MEN_ABOUT], MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, obj, 1, MUIM_VPDF_About);
DoMethod((Object *)menu[MEN_QUIT], MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, obj, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
DoMethod((Object *)menu[MEN_TAB_NEW], MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, obj, 2, MUIM_VPDF_CreateTab, 0);
DoMethod((Object *)menu[MEN_TAB_CLOSE], MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, obj, 2, MUIM_VPDF_CloseTab, 0);
DoMethod((Object *)menu[MEN_WINDOW_NEW], MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, obj, 1, MUIM_VPDF_CreateWindow);
DoMethod((Object *)menu[MEN_OPEN_FILE], MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, obj, 4, MUIM_VPDF_OpenFile, 0, NULL, MUIV_VPDFWindow_OpenFile_CurrentTabIfEmpty);
DoMethod((Object *)menu[MEN_SAVE_FILE], MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, obj, 2, MUIM_VPDF_SaveFile, 0);
DoMethod((Object *)menu[MEN_SETTINGS_SETTINGS], MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime,settingswin, 3, MUIM_Set, MUIA_Window_Open, TRUE);
DoMethod((Object *)menu[MEN_SETTINGS_SAVESETTINGS], MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime,settingswin, 1, MUIM_VPDFSettings_Save);
DoMethod((Object *)menu[MEN_SETTINGS_MUI], MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, obj, 2, MUIM_Application_OpenConfigWindow, 0);
Expand Down Expand Up @@ -405,6 +414,18 @@ DEFMMETHOD(VPDF_CreateTab)
return (ULONG)-1;
}

DEFMMETHOD(VPDF_CloseTab)
{
Object *window = (Object*)DoMethod(obj, MUIM_VPDF_FindWindowByID, msg->windowid == 0 ? MUIV_VPDF_FindWindowByID_Active : msg->windowid);

if (window != NULL)
{
return DoMethod(window, MUIM_VPDFWindow_CloseTab);
}

return (ULONG)-1;
}

DEFMMETHOD(VPDF_CreateWindow)
{
GETDATA;
Expand Down Expand Up @@ -1019,6 +1040,46 @@ DEFMMETHOD(VPDF_SelectionCopy)

return TRUE;
}


DEFMMETHOD(VPDF_SaveFile)
{
GETDATA;
char *filename = msg->filename;
int mode = msg->mode;
Object *window = (Object*)DoMethod(obj, MUIM_VPDF_FindWindowByID, msg->windowid == 0 ? MUIV_VPDF_FindWindowByID_Active : msg->windowid);

/* if (window == NULL)
{
window = (Object*)DoMethod(obj, MUIM_VPDF_CreateWindow);
mode = MUIV_VPDFWindow_OpenFile_CurrentTabIfEmpty;
}
*/

if (filename == NULL)
{
filename = (char*)DoMethod(_app(obj), MUIM_VPDF_RequestFile,
MUIV_VPDF_RequestFile_Save,
NULL,
NULL,
NULL);

if (filename == NULL)
return FALSE;
}

if (window != NULL)
{
if (DoMethod(window, MUIM_VPDFWindow_SaveFile, filename, mode))
{

}

}

return TRUE;
}

/* */

BEGINMTABLE
Expand All @@ -1030,7 +1091,9 @@ BEGINMTABLE
DECMMETHOD(Export)
DECMMETHOD(DragDrop)
DECMMETHOD(VPDF_OpenFile)
DECMMETHOD(VPDF_SaveFile)
DECMMETHOD(VPDF_CreateTab)
DECMMETHOD(VPDF_CloseTab)
DECMMETHOD(VPDF_CreateWindow)
DECMMETHOD(VPDF_HandleAppMessage)
DECMMETHOD(VPDF_RequestFile)
Expand Down
10 changes: 8 additions & 2 deletions vpdf/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#define MUIA_VPDF_Renderer (MUIA_VPDF_TagBase + 1)
#define MUIA_VPDF_Locked (MUIA_VPDF_TagBase + 2)

#define MUIM_VPDF_OpenFile (MUIM_VPDF_Dummy + 1)
#define MUIM_VPDF_CreateTab (MUIM_VPDF_Dummy + 2)
#define MUIM_VPDF_OpenFile (MUIM_VPDF_Dummy + 1)
#define MUIM_VPDF_CreateTab (MUIM_VPDF_Dummy + 2)
#define MUIM_VPDF_CreateWindow (MUIM_VPDF_Dummy + 3)
#define MUIM_VPDF_HandleAppMessage (MUIM_VPDF_Dummy + 4)
#define MUIM_VPDF_RequestFile (MUIM_VPDF_Dummy + 5)
Expand All @@ -24,11 +24,17 @@
#define MUIM_VPDF_About (MUIM_VPDF_Dummy + 16)
#define MUIM_VPDF_PrintDocument (MUIM_VPDF_Dummy + 17)
#define MUIM_VPDF_SelectionCopy (MUIM_VPDF_Dummy + 18)
#define MUIM_VPDF_SaveFile (MUIM_VPDF_Dummy + 19)
#define MUIM_VPDF_CloseTab (MUIM_VPDF_Dummy + 20)

struct MUIP_VPDF_OpenFile{ULONG MethodID; int windowid; char *filename; int mode;}; // mode is MUIV_VPDFWindow_OpenFile_XXX
struct MUIP_VPDF_SaveFile{ULONG MethodID; int windowid; char *filename; int mode;}; // mode is MUIV_VPDFWindow_OpenFile_XXX
struct MUIP_VPDF_CreateTab{ULONG MethodID; int windowid;};
struct MUIP_VPDF_CreateWindow{ULONG MethodID;};

struct MUIP_VPDF_CloseTab{ULONG MethodID; int windowid;};


struct MUIP_VPDF_RequestFile{ULONG MethodID; int mode; char *initialfile; char *initialdir; char *initialpath;};
struct MUIP_VPDF_OpenRecentFile{ULONG MethodID; int windowid; int idx;};
struct MUIP_VPDF_FindWindowByID{ULONG MethodID; int windowid;};
Expand Down
4 changes: 2 additions & 2 deletions vpdf/fontcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -1415,7 +1415,7 @@ static char *fcSfntNameTranscode(FT_SfntName *sname)
if (!strcmp (fromcode, FC_ENCODING_MAC_ROMAN))
{
FcChar8 *u8;
const FcCharMap *map = FcFreeTypeGetPrivateMap (ft_encoding_apple_roman);
const FcCharMap *map = IntFcFreeTypeGetPrivateMap (ft_encoding_apple_roman);
FcChar8 *src = (FcChar8 *) sname->string;
int src_len = sname->string_len;

Expand Down Expand Up @@ -1733,7 +1733,7 @@ struct fontpattern *fcQueryFace(const FT_Face face, char *fname, int id)
exclusiveLang = 0;
break;
}
exclusiveLang = FcCodePageRange[i].lang;
exclusiveLang = (char*)FcCodePageRange[i].lang;
}
}
}
Expand Down
48 changes: 31 additions & 17 deletions vpdf/mcc/continuouslayout_class.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
#include "system/functions.h"
#include "system/gentexture.h"

#define DEBUG 1
#include <aros/debug.h>


struct Data
{
void *doc;
Expand All @@ -62,7 +66,7 @@ struct Data
struct MUI_EventHandlerNode eh;
int clicky;
int clickx;
int page;
LONG page;
int columns;
int scaling;
float zoom;
Expand Down Expand Up @@ -103,7 +107,7 @@ DEFNEW

data->views = malloc(sizeof(Object*) * pdfGetPagesNum(data->doc));
#warning TODO: handle failure

LONG top=0;
for(i=0; i<pdfGetPagesNum(data->doc); i++)
{
float mediawidth = pdfGetPageMediaWidth(data->doc, i + 1);
Expand All @@ -117,6 +121,7 @@ DEFNEW
MUIA_PageView_MediaHeight, (int)mediaheight,
MUIA_PageView_Information, information,
MUIA_PageView_IsPreview, data->ispreview,
MUIA_PageView_TopEdge, top,
//MUIA_FixWidth , 128,
//MUIA_FixHeight , 128,
End;
Expand All @@ -129,6 +134,7 @@ DEFNEW
//DoMethod(obj, OM_ADDMEMBER, RectangleObject, End);

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

/* only notify about new 'focused' page if this is not previews view (outlines) */
Expand Down Expand Up @@ -214,7 +220,6 @@ DEFSET
}
//set(obj, MUIA_Virtgroup_Top, (LONG)xget(pageview, MUIA_PageView_LayoutTop));
}

MUI_Redraw(data->views[prevpage], MADF_DRAWOBJECT);
MUI_Redraw(data->views[newpage], MADF_DRAWOBJECT);

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

METHOD continuouslayoutIsPageVisible(struct IClass *cl, Object *obj, struct MUIP_DocumentLayout_IsPageVisible *msg)
{
GETDATA;
GETDATA;
Object *pageview = data->views[msg->page - 1];

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

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

LONG topedge = ((long)xget(pageview, MUIA_PageView_TopEdge)*(float)((float)height / xget(obj, MUIA_PageView_MediaHeight) )) -(long)xget(obj, MUIA_Virtgroup_Top);

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));
/* check constraints for object and group */
top = topedge; //- (long)_addtop(obj);
LONG nTop = top - _top(obj);
LONG nBottom = nTop + height;
LONG gBottom = _height(obj) + 5; /* 5 is a margin */
LONG gTop = -5;

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



if (nBottom < gTop)
{
/* bottom is invisible */
D(kprintf("no page %d borders:%ld %ld, borders:%ld,%ld\n", msg->page, nTop, nBottom, gTop, gBottom));
/* bottom is invisible */
return FALSE;
}

if (nTop > gBottom)
{
/* top is invisible */
D(kprintf("no page %d borders:%ld %ld, borders:%ld,%ld\n", msg->page, nTop, nBottom, gTop, gBottom));
/* top is invisible */
return FALSE;
}
D(kprintf("YES page %d borders:%ld %ld, borders:%ld,%ld\n", msg->page, nTop, nBottom, gTop, gBottom));

return TRUE;
return TRUE;
}

METHOD continuouslayoutClippedPageOffset(struct IClass *cl, Object *obj, struct MUIP_ContinuousLayout_ClippedPageOffset *msg)
{
GETDATA;
GETDATA;
Object *pageview = data->views[msg->page - 1];

LONG top = xget(pageview, MUIA_TopEdge) - (LONG)_addtop(obj);
LONG height = xget(pageview, MUIA_Height);

LONG top = (LONG)xget(pageview, MUIA_TopEdge) - (LONG)_addtop(obj);
LONG height = (LONG)xget(pageview, MUIA_Height);
/* check constraints for object and group */
LONG topedge = ((LONG)xget(pageview, MUIA_PageView_TopEdge)*(float)((float)height / xget(obj, MUIA_PageView_MediaHeight) )) -(LONG)xget(obj, MUIA_Virtgroup_Top);

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

return nTop - oldnTop;
return nTop - oldnTop;
}

METHOD continuouslayoutShow(struct IClass *cl, Object *obj, struct MUIP_Show *msg)
Expand Down
Loading

0 comments on commit 50b0a01

Please sign in to comment.