OpenCV zGUI
CrossPlatform C++ GUI libarary based on OpenCV
z::Window Class Reference

#include <zgui.h>

Inheritance diagram for z::Window:
Collaboration diagram for z::Window:

Public Member Functions

 Window (std::string title, cv::Rect_< int > r)
 
void show ()
 draw mat_ More...
 
void popup (Window &w, std::function< void(int)> f=[](int){})
 
void popdown (int value)
 
std::string type () const
 
int open (int flag=cv::WINDOW_AUTOSIZE, int x=-1, int y=-1)
 
void quit (int r)
 
void focus (bool v)
 
Windowoperator+ (Widget &w)
 
Windowoperator- (Widget &w)
 
Windowoperator<< (Widget &r)
 
Windowoperator>> (Widget &r)
 
int loop ()
 
std::vector< Widget * >::iterator begin ()
 
std::vector< Widget * >::iterator end ()
 
void close ()
 
void start (int flag=cv::WINDOW_AUTOSIZE|cv::WINDOW_KEEPRATIO)
 
void keyboard_callback (int key, int level=0)
 
std::string title () const
 
void tie (TextInput &t, Button &b, const std::vector< std::string > &v, int font_size)
 
template<class T >
auto tie (TextInput &t, Button &b1, Button &b2, T start, T step)
 
template<class... T>
void tabs (int xpos, int ypos, T &... wins)
 
void organize_accordingto_zindex ()
 
void move_widget (Widget &w, cv::Point2i p)
 
void on_register ()
 will be called when widget is added to a window
 
bool is_window () const
 
template<class... T>
auto tie (T &... checks)
 
template<class... T>
void wrap (const char *title, int font, int N, const T &... widgets)
 
void draw_all_wrapped ()
 
void scroll_to (cv::Rect2i r)
 
void set_ul (cv::Point2i p)
 
void set_br (cv::Point2i p)
 
- Public Member Functions inherited from z::Widget
 Widget (cv::Rect_< int > r)
 
Widgetoperator= (const Widget &r)
 
bool focus () const
 
virtual void event_callback (int event, int x, int y)
 
void resize (cv::Rect2i r)
 
void update ()
 
int zIndex ()
 
void zIndex (int v)
 
void hidden (bool v)
 
void activated (bool v)
 
bool hidden () const
 
bool activated () const
 
void hide ()
 
float alpha () const
 
void alpha (float f)
 
void shade_rect (cv::Rect2i r, int shade=3, cv::Vec3b color=widget_color_, cv::Vec3b upper_left=highlight_color_, cv::Vec3b lower_right=click_color_)
 

Public Attributes

cv::Rect2i scrolled_rect_ = cv::Rect2i{0,0,0,0}
 
std::vector< Widget * > widgets_
 
std::vector< Widget * > backup_
 
- Public Attributes inherited from z::Widget
std::map< int, std::function< void(int, int)> > gui_callback_
 map<int : event, function(x, y)>. library will draw change in widget graphics after gui_callback
 
std::map< int, std::function< void(int, int)> > user_callback_
 
cv::Mat3b mat_
 Matrix that contains widget shape.
 
Windowparent_ = nullptr
 pointer to parent window that is containing this widget
 

Protected Member Functions

void draw_wrapped (const Wrapped &wr)
 

Protected Attributes

std::string title_
 
bool closed_ = false
 
int result_ = -1
 
- Protected Attributes inherited from z::Widget
float alpha_ = 1
 alpha value of widget. Widgets can be overlapped. Alpha value will be calculated in such cases.
 
bool hidden_ = false
 if hidden, a widget will not show on window, but still can react to event.
 
bool activated_ = true
 deactivated widget cannot get focus so that it cannot react to events.
 
bool focus_ = false
 
int zIndex_ = 0
 higher zIndex widget will be in front of lower zIndex widget.
 

Additional Inherited Members

- Static Protected Attributes inherited from z::Widget
static const cv::Vec3b background_color_ = {200, 200, 200}
 
static const cv::Vec3b widget_color_ = {220, 220, 220}
 
static const cv::Vec3b highlight_color_ = {240, 240, 240}
 
static const cv::Vec3b click_color_ = {180, 180, 180}
 
static cv::Ptr< cv::freetype::FreeType2 > ft2_
 freetype2 font. CJK font needed
 

Detailed Description

Window class houses all widgets including other windows

Constructor & Destructor Documentation

◆ Window()

z::Window::Window ( std::string  title,
cv::Rect_< int >  r 
)

create a window with title and position and size of r.

Parameters
titleif window is the top window, this will be the window title. else if window is embedded inside another window, window will be framed and title will be the frame title. In case title == "", no frame will show.
rwindow will occupy this rectangular space. If this window is not embedded inside other window x, y postions is not relevant.

Member Function Documentation

◆ close()

void z::Window::close ( )

close all windows

◆ draw_all_wrapped()

void z::Window::draw_all_wrapped ( )

draw all frames

◆ focus()

void z::Window::focus ( bool  v)
virtual

also unfocus child widgets

Reimplemented from z::Widget.

◆ loop()

int z::Window::loop ( )

get keyboard event by calling cv::waitKey

◆ move_widget()

void z::Window::move_widget ( z::Widget w,
cv::Point2i  p 
)

move a widget that is already mounted. Just change the widget's xy position

◆ open()

int z::Window::open ( int  flag = cv::WINDOW_AUTOSIZE,
int  x = -1,
int  y = -1 
)

Open another window. Call quit to close window that is opened.

Returns
return int value when quit is called.

◆ operator+()

z::Window & z::Window::operator+ ( z::Widget w)

add widget to this window

◆ operator-()

z::Window & z::Window::operator- ( z::Widget w)

remove widget from this window

◆ operator<<()

z::Window & z::Window::operator<< ( z::Widget r)

copy to mat_

◆ operator>>()

z::Window & z::Window::operator>> ( z::Widget r)

remove from mat_. sets hidden_ value to true.

◆ organize_accordingto_zindex()

void z::Window::organize_accordingto_zindex ( )

sort widgets according to zIndex_ and copy all widgets that is not hiddent to window matrix.

for mouse event

◆ popdown()

void z::Window::popdown ( int  value)

close popup window.

Parameters
valuethis value will be handed over to function that is registered with popup function call.

◆ popup()

void z::Window::popup ( z::Window w,
std::function< void(int)>  f = [](int){} 
)

show popup window on window w, and register result function. popdown function will hand over int value to f.

◆ scroll_to()

void z::Window::scroll_to ( cv::Rect2i  r)

use this to scroll or resize window.

◆ show()

void z::Window::show ( )
virtual

draw mat_

show window and its components

Reimplemented from z::Widget.

◆ start()

void z::Window::start ( int  flag = cv::WINDOW_AUTOSIZE | cv::WINDOW_KEEPRATIO)

organize according to zindex -> set mouse callback -> show window

◆ tabs()

template<class... T>
void z::Window::tabs ( int  xpos,
int  ypos,
T &...  wins 
)
inline

create a tab by combining multiple Womdows and will create tab navigation buttons on top

Parameters
xposx position to create tab.
yposy position to create tab. This is the Upper left postion of navigation button.

◆ tie() [1/2]

template<class... T>
auto z::Window::tie ( T &...  checks)
inline

create a radio button by combining multiple CheckBoxes. RadioButton is a widget that allows one CheckBox to be selected at one time.

◆ tie() [2/2]

template<class T >
auto z::Window::tie ( TextInput t,
Button b1,
Button b2,
start,
step 
)
inline

create a numeric spin button by tying a textinput and two buttons.

Parameters
startnumber to begin with
stepstep to increase or decrease when buttons are clicked.

◆ title()

string z::Window::title ( ) const

get title

◆ wrap()

template<class... T>
void z::Window::wrap ( const char *  title,
int  font,
int  N,
const T &...  widgets 
)
inline

@parma N margin.

Parameters
fontfont height

The documentation for this class was generated from the following files: