Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Helco committed Nov 18, 2018
1 parent 8840650 commit d52a7c4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ set(sources_pcmockup
pcmockup/debugwindowset.c
pcmockup/windowcontainer.c
pcmockup/imagewindow.c
pcmockup/windowgrid.c
)
assign_source_group(${sources_pcmockup})

Expand Down
12 changes: 12 additions & 0 deletions pcmockup/imagewindow.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ struct ImageWindow
float aspect;
SDL_Rect lastContentPos;
bool isOpen, isEssential;
ImVec2 initialPosition;
};

ImageWindow* imageWindow_init(const char* title, GSize initialSize, bool_t isEssential)
Expand Down Expand Up @@ -48,6 +49,7 @@ ImageWindow* imageWindow_init(const char* title, GSize initialSize, bool_t isEss
me->isEssential = isEssential;
me->windowSize = initialSize;
me->aspect = (float)initialSize.w / initialSize.h;
me->initialPosition.x = -1; // undefined initial position
return me;
}

Expand Down Expand Up @@ -95,6 +97,8 @@ void imageWindow_update(ImageWindow* me)
? NULL // essential windows don't get a close button
: &me->isOpen;

if (me->initialPosition.x >= 0 && me->initialPosition.y >= 0)
igSetNextWindowPos(me->initialPosition, ImGuiCond_Once, zero);
igSetNextWindowContentSize(size);
igPushStyleVarVec2(ImGuiStyleVar_WindowPadding, zero); // space between image and window border
igPushStyleVarVec2(ImGuiStyleVar_ItemSpacing, zero); // space between vertical centering dummy and image
Expand Down Expand Up @@ -122,6 +126,14 @@ void imageWindow_update(ImageWindow* me)
};
}

void imageWindow_setInitialPosition(ImageWindow* me, GPoint initialPosition)
{
me->initialPosition = (ImVec2) {
(float)initialPosition.x,
(float)initialPosition.y
};
}

void imageWindow_toggle(ImageWindow* me, bool_t isOpen)
{
me->isOpen = isOpen;
Expand Down
4 changes: 4 additions & 0 deletions pcmockup/pcmockup.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ void imageWindow_free(ImageWindow* me);
void imageWindow_setImageData(ImageWindow* me, GSize size, const SDL_Color* data);
SDL_Rect imageWindow_getContentPos(ImageWindow* me); // in screen coordinates
void imageWindow_update(ImageWindow* me);
void imageWindow_setInitialPosition(ImageWindow* me, GPoint initialPosition);
void imageWindow_toggle(ImageWindow* me, bool_t isOpen);
bool_t imageWindow_isOpen(ImageWindow* me);

Expand All @@ -55,6 +56,9 @@ void debugWindowSet_update(DebugWindowSet* set);
void debugWindowSet_updateMenubar(DebugWindowSet* set);
void debugWindowSet_handleUpdate(DebugWindowSet* set, const SDL_Event* ev);

GSize windowGrid_getSingleSize(int nWindows, GSize totalSize);
GPoint windowGrid_getSinglePos(int nWindows, GSize totalSize, int windowI);

typedef struct PCMockup PCMockup;
PCMockup* pcmockup_init();
void pcmockup_free(PCMockup* me);
Expand Down

0 comments on commit d52a7c4

Please sign in to comment.