Skip to content

Commit 647bde8

Browse files
committed
Merge pull request arrayfire#728 from shehzan10/devel
Added wrapper for setTitle for window
2 parents facdfdc + 526e012 commit 647bde8

3 files changed

Lines changed: 27 additions & 0 deletions

File tree

include/af/graphics.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class AFAPI Window {
4444

4545
af_window get() const { return wnd; }
4646
void setPos(const unsigned x, const unsigned y);
47+
void setTitle(const char* const title);
4748

4849
void image(const array& in, const char* title=NULL);
4950
void plot(const array& X, const array& Y, const char* const title=NULL);
@@ -70,6 +71,8 @@ AFAPI af_err af_create_window(af_window *out, const int width, const int height,
7071

7172
AFAPI af_err af_set_position(const af_window wind, const unsigned x, const unsigned y);
7273

74+
AFAPI af_err af_set_title(const af_window wind, const char* const title);
75+
7376
AFAPI af_err af_draw_image(const af_window wind, const af_array in, const af_cell* const props);
7477

7578
AFAPI af_err af_draw_plot(const af_window wind, const af_array X, const af_array Y, const af_cell* const props);

src/api/c/image.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,25 @@ af_err af_set_position(const af_window wind, const unsigned x, const unsigned y)
143143
#endif
144144
}
145145

146+
af_err af_set_title(const af_window wind, const char* const title)
147+
{
148+
#if defined(WITH_GRAPHICS)
149+
if(wind==0) {
150+
std::cerr<<"Not a valid window"<<std::endl;
151+
return AF_SUCCESS;
152+
}
153+
154+
try {
155+
fg::Window* wnd = reinterpret_cast<fg::Window*>(wind);
156+
wnd->setTitle(title);
157+
}
158+
CATCHALL;
159+
return AF_SUCCESS;
160+
#else
161+
return AF_ERR_NO_GFX;
162+
#endif
163+
}
164+
146165
af_err af_grid(const af_window wind, const int rows, const int cols)
147166
{
148167
#if defined(WITH_GRAPHICS)

src/api/cpp/graphics.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ void Window::setPos(const unsigned x, const unsigned y)
5252
AF_THROW(af_set_position(get(), x, y));
5353
}
5454

55+
void Window::setTitle(const char* const title)
56+
{
57+
AF_THROW(af_set_title(get(), title));
58+
}
59+
5560
void Window::image(const array& in, const char* const title)
5661
{
5762
af_cell temp{_r, _c, title};

0 commit comments

Comments
 (0)