Button::Button(ButtonType _type) { type = _type; alignment = ButtonAlignment::TopRight; button_text = std::make_shared<GUIText>(); button_text->set_width(1.0f); button_text->set_height(1.0f); button_text->set_x_offset(0.3f); button_text->set_y_offset(0.1f); set_text(""); is_highlighted = false; add(button_text); picture_name = "gui/black-tile"; if(type == ButtonType::Board){ set_width(1.0f); set_height(0.85f); } else if(type == ButtonType::Single){ set_width(0.5f); set_height(0.5f); } else if(type == ButtonType::NoPicture){ set_width(0.5f); set_height(0.5f); button_text->set_x_offset(0.2f); button_text->set_y_offset(0.5f); } this->set_visible(false); this->set_clickable(false); }
void button::calculate_size() { if (type_ == TYPE_IMAGE){ SDL_Rect loc_image = location(); loc_image.h = image_->h; loc_image.w = image_->w; set_location(loc_image); return; } SDL_Rect const &loc = location(); bool change_size = loc.h == 0 || loc.w == 0; if (!change_size) { unsigned w = loc.w - (type_ == TYPE_PRESS ? horizontal_padding : checkbox_horizontal_padding + base_width_); if (type_ != TYPE_IMAGE) { int fs = font_size; int style = TTF_STYLE_NORMAL; std::string::const_iterator i_beg = label_.begin(), i_end = label_.end(), i = font::parse_markup(i_beg, i_end, &fs, NULL, &style); if (i != i_end) { std::string tmp(i, i_end); label_.erase(i - i_beg, i_end - i_beg); label_ += font::make_text_ellipsis(tmp, fs, w, style); } } } if (type_ != TYPE_IMAGE){ textRect_ = font::draw_text(NULL, screen_area(), font_size, font::BUTTON_COLOR, label_, 0, 0); } if (!change_size) return; #ifdef USE_TINY_GUI set_height(textRect_.h+vertical_padding); #else set_height(std::max(textRect_.h+vertical_padding,base_height_)); #endif if(type_ == TYPE_PRESS) { #ifdef USE_TINY_GUI set_width(textRect_.w + horizontal_padding); #else if(spacing_ == MINIMUM_SPACE) { set_width(textRect_.w + horizontal_padding); } else { set_width(std::max(textRect_.w+horizontal_padding,base_width_)); } #endif } else { if(label_.empty()) { set_width(base_width_); } else { set_width(checkbox_horizontal_padding + textRect_.w + base_width_); } } }
void GuiPicture::set_picture(TileGraphic *graphic) { this->graphic = graphic; if (graphic) { set_width(graphic->get_width()); set_height(graphic->get_height()); } else { set_width(0); set_height(0); } }
void button::calculate_size() { if (type_ == TYPE_IMAGE){ SDL_Rect loc_image = location(); loc_image.h = image_->h; loc_image.w = image_->w; set_location(loc_image); return; } SDL_Rect const &loc = location(); bool change_size = loc.h == 0 || loc.w == 0; if (!change_size) { unsigned w = loc.w - (type_ == TYPE_PRESS ? horizontal_padding : checkbox_horizontal_padding + base_width_); if (type_ != TYPE_IMAGE){ label_ = font::make_text_ellipsis(label_, font_size, w, false); } } if (type_ != TYPE_IMAGE){ textRect_ = font::draw_text(NULL, screen_area(), font_size, font::BUTTON_COLOUR, label_, 0, 0); } if (!change_size) return; #ifdef USE_TINY_GUI set_height(textRect_.h+vertical_padding); #else set_height(std::max(textRect_.h+vertical_padding,base_height_)); #endif if(type_ == TYPE_PRESS) { #ifdef USE_TINY_GUI set_width(textRect_.w + horizontal_padding); #else if(spacing_ == MINIMUM_SPACE) { set_width(textRect_.w + horizontal_padding); } else { set_width(std::max(textRect_.w+horizontal_padding,base_width_)); } #endif } else { if(label_.empty()) { set_width(base_width_); } else { set_width(checkbox_horizontal_padding + textRect_.w + base_width_); } } }
int print_octal(char *str, va_list ap, t_ptf_format *format) { t_print_elem elem; unsigned int nbr; int cp; int res_set_prec; char *s; char *s2; elem.buff[1] = 0; nbr = va_arg(ap, unsigned int); set_width(&elem.width, format, ap); res_set_prec = set_prec_len(&elem.len_precision, format, ap); s2 = printf_my_itoa(nbr); s = printf_convert_base(s2, BASE_DECIMAL, BASE_OCTAL); cp = printf_my_strlen(s); if (!res_set_prec || elem.len_precision < cp) elem.len_precision = 0; elem.width = (elem.width > cp) ? elem.width : 0; cp = printf_my_strlen(s); check_width_and_precision2(&elem, s, format); if (getchar_pos(format->flags, '-') != -1) cp = cp + prt_cond(&elem, s, str, format); else cp = cp + prt_cond2(&elem, s, str, format); return (free(s2), cp); }
void macosx_resize_window(int *lines_per_page, int *chars_per_line) { int new_lines_per_page = UINT_MAX; int new_chars_per_line = UINT_MAX; int ret; if (isatty(fileno(stdout))) { struct winsize window_size; ret = ioctl(fileno(stdout), TIOCGWINSZ, &window_size); if (ret == 0) { new_lines_per_page = window_size.ws_row; new_chars_per_line = window_size.ws_col; } } if (((unsigned int)*lines_per_page != UINT_MAX) && (*lines_per_page != 0)) { *lines_per_page = new_lines_per_page; } if (((unsigned int)*chars_per_line != UINT_MAX) && (*chars_per_line != 0)) { *chars_per_line = new_chars_per_line; } set_screen_size(); set_width(); }
Rectangle::Rectangle(float Width, float Height) { set_left ( 0 ); set_bottom ( 0 ); set_width ( Width ); set_height ( Height ); }
Rect& Rect::operator=(const RECT& r) { origin_.SetPoint(r.left, r.top); set_width(r.right - r.left); set_height(r.bottom - r.top); return *this; }
YCbCrInput::YCbCrInput(const ImageFormat &image_format, const YCbCrFormat &ycbcr_format, unsigned width, unsigned height, YCbCrInputSplitting ycbcr_input_splitting) : image_format(image_format), ycbcr_format(ycbcr_format), ycbcr_input_splitting(ycbcr_input_splitting), width(width), height(height), resource_pool(NULL) { pbos[0] = pbos[1] = pbos[2] = 0; texture_num[0] = texture_num[1] = texture_num[2] = 0; set_width(width); set_height(height); pixel_data[0] = pixel_data[1] = pixel_data[2] = NULL; owns_texture[0] = owns_texture[1] = owns_texture[2] = false; register_uniform_sampler2d("tex_y", &uniform_tex_y); if (ycbcr_input_splitting == YCBCR_INPUT_SPLIT_Y_AND_CBCR) { num_channels = 2; register_uniform_sampler2d("tex_cbcr", &uniform_tex_cb); } else { assert(ycbcr_input_splitting == YCBCR_INPUT_PLANAR); num_channels = 3; register_uniform_sampler2d("tex_cb", &uniform_tex_cb); register_uniform_sampler2d("tex_cr", &uniform_tex_cr); } }
scrollbar::scrollbar(CVideo &video) : widget(video) , mid_scaled_(NULL) , groove_scaled_(NULL) , uparrow_(video, "", button::TYPE_TURBO, "button_square/button_square_25" , gui::button::DEFAULT_SPACE, true,"icons/arrows/arrows_ornate_up_25") , downarrow_(video, "", button::TYPE_TURBO, "button_square/button_square_25" , gui::button::DEFAULT_SPACE, true,"icons/arrows/arrows_ornate_down_25") , state_(NORMAL) , minimum_grip_height_(0) , mousey_on_grip_(0) , grip_position_(0) , grip_height_(0) , full_height_(0) , scroll_rate_(1) { uparrow_.enable(false); downarrow_.enable(false); static const surface img(image::get_image(scrollbar_mid)); if (img != NULL) { set_width(img->w); // this is a bit rough maybe minimum_grip_height_ = 2 * img->h; } }
//Find the width of cluster in units of pixels in a column void Cluster::find_width(){ //Sort by col hits.sort(compare_cols); //Then take the difference of the first and last values set_width(hits.back().get_col() - hits.front().get_col() + 1); }
ship_selection_button::ship_selection_button(ui_container* parent) : ui_button(parent) { set_width(16.f); set_height(16.f); set_halign(horizontal_alignment::left); set_valign(vertical_alignment::top); set_margin(10.f); selection_state = ship_selection_button_state::unknown; }
/* COPY CONSTRUCTOR */ DrawingObject::DrawingObject(const DrawingObject& o) { set_type(o.type()); set_left(o.left()); set_bottom(o.bottom()); set_width(o.width()); set_height(o.height()); }
/* DEFAULT CONSTRUCTOR */ DrawingObject::DrawingObject() { set_type("OBJECT"); set_left(0); set_bottom(0); set_width(0); set_height(0); }
Exit::Exit() { set_type("EXIT"); set_left(EXIT_LEFT); set_bottom(EXIT_BOTTOM); set_width(EXIT_WIDTH); set_height(EXIT_HEIGHT); add_input(CircuitObject()); close(); }
//======================================================================================= // GmoBoxControl //======================================================================================= GmoBoxControl::GmoBoxControl(Control* ctrl, const UPoint& origin, LUnits width, LUnits height, ImoStyle* style) : GmoBox(GmoObj::k_box_control, ctrl->get_owner_imo() ) , m_pStyle(style) , m_pControl(ctrl) { set_origin(origin); set_width(width); set_height(height); }
FractalProto * Fractal::serialize() { auto fp = new FractalProto(); fp->set_bottom(bottom); fp->set_height(height); fp->set_left(left); fp->set_right(right); fp->set_width(width); fp->set_top(top); fp->set_maxiter(maxiter); return fp; }
static int main_pwm(int argc, char **argv) { if (argc != 2) { printf("%s <usecs>\n", argv[0]); return 1; } unsigned int w = strtoul(argv[1], NULL, 0); set_width(w); return 0; }
/** * \brief Set the width in the image resource. * \param width The new value. */ void bf::sprite::set_clip_width( const unsigned int width ) { if ( m_clip_width != width ) { m_clip_width = width; m_spritepos_entry.clear(); if ( get_auto_size() ) set_width(width); } } // sprite::set_clip_width()
Shelf::Shelf(int x, int y, int width, int height, GuiDimension dimension) : GuiContext(x,y), dimension(dimension), isIn(true) { set_width(width); set_height(height); edgeVisible = 0; background = new GuiColorRect(0,0,width,height); background->set_rgba(0.0,0.0,0.0,0.75); add(background); this->className = "Shelf"; }
/* CONSTRUCTOR */ Bit::Bit(int value) { if(value == 0) set_type("0"); else if(value == 1) set_type("1"); else set_type("BIT"); set_width(BIT_WIDTH); set_height(BIT_HEIGHT); }
CircuitObject::CircuitObject(string type) { set_type(type); set_left(0); set_bottom(0); set_width(0); set_height(0); set_input1(NULL); set_input2(NULL); set_output(NULL); set_output_value(0); }
Exit::Exit(const Exit& e) { set_type(e.type()); set_left(e.left()); set_bottom(e.bottom()); set_width(e.width()); set_height(e.height()); add_input(e.input()); if(e.is_open()) open(); else close(); }
bsaheaderdfa& bsaheaderdfa::operator =(const bsaheaderdfa& other) { if (this != &other) { set_width(other.get_width()); set_height(other.get_height()); set_compressed_size(other.compressed_size); set_u2(other.u2); set_u3(other.u3); set_frame_count(other.frame_count); } return *this; }
void GDICanvas::BeginDraw(void* p, int w, int h) { if (m_pD2DContext2D == nullptr) { m_pD2DContext2D = new GdiContext2D((HDC) p); } RECT rc; GetClientRect((HWND) p, &rc); set_width((rc.right - rc.left)); set_height((rc.bottom - rc.top)); m_pD2DContext2D->BeginDraw((HDC)p); }
CircuitObject::CircuitObject(const CircuitObject& o) { set_type(o.type()); set_left(o.left()); set_bottom(o.bottom()); set_width(o.width()); set_height(o.height()); set_input1(o.input1()); set_input2(o.input2()); set_output(o.output()); set_output_value(o.output_value()); if(o.has_button()) give_button(); }
css_error css__compose_width(const css_computed_style *parent, const css_computed_style *child, css_computed_style *result) { css_fixed length = 0; css_unit unit = CSS_UNIT_PX; uint8_t type = get_width(child, &length, &unit); if (type == CSS_WIDTH_INHERIT) { type = get_width(parent, &length, &unit); } return set_width(result, type, length, unit); }
void deinit() { set_is_loaded(false); if(_texture==0) return; _tex_width = 0; _tex_height = 0; set_width(0.f); set_height(0.f); glDeleteTextures(1, &_texture); _texture = 0; }
void ImageMessage::MergeFrom(const ImageMessage& from) { GOOGLE_CHECK_NE(&from, this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_width()) { set_width(from.width()); } if (from.has_height()) { set_height(from.height()); } if (from.has_data()) { set_data(from.data()); } } mutable_unknown_fields()->MergeFrom(from.unknown_fields()); }
GuiEventLog::GuiEventLog(GLfloat width, GLfloat height) : GuiContext(0, 0) { // Set dimensions set_width(width); set_height(height); // Set default font font = FontManager::font("small"); // Set initial empty log clear(); // Poor man's reflection className = "GuiEventLog"; }