void LLToastNotifyPanel::updateButtonsLayout(const std::vector<index_button_pair_t>& buttons, S32 h_pad) { S32 left = 0; //reserve place for ignore button S32 bottom_offset = mIsScriptDialog ? (BTN_HEIGHT + IGNORE_BTN_TOP_DELTA + BOTTOM_PAD) : BOTTOM_PAD; S32 max_width = mControlPanel->getRect().getWidth(); LLButton* ignore_btn = NULL; LLButton* mute_btn = NULL; for (std::vector<index_button_pair_t>::const_iterator it = buttons.begin(); it != buttons.end(); it++) { if (-2 == it->first) { mute_btn = it->second; continue; } if (it->first == -1) { ignore_btn = it->second; continue; } LLButton* btn = it->second; LLRect btn_rect(btn->getRect()); if (left + btn_rect.getWidth() > max_width)// whether there is still some place for button+h_pad in the mControlPanel { // looks like we need to add button to the next row left = 0; bottom_offset += (BTN_HEIGHT + VPAD); } //we arrange buttons from bottom to top for backward support of old script btn_rect.setOriginAndSize(left, bottom_offset, btn_rect.getWidth(), btn_rect.getHeight()); btn->setRect(btn_rect); left = btn_rect.mLeft + btn_rect.getWidth() + h_pad; mControlPanel->addChild(btn, -1); } U32 ignore_btn_width = 0; U32 mute_btn_pad = 0; if (mIsScriptDialog && ignore_btn != NULL) { LLRect ignore_btn_rect(ignore_btn->getRect()); S32 ignore_btn_left = max_width - ignore_btn_rect.getWidth(); ignore_btn_rect.setOriginAndSize(ignore_btn_left, BOTTOM_PAD,// always move ignore button at the bottom ignore_btn_rect.getWidth(), ignore_btn_rect.getHeight()); ignore_btn->setRect(ignore_btn_rect); ignore_btn_width = ignore_btn_rect.getWidth(); mControlPanel->addChild(ignore_btn, -1); mute_btn_pad = 4 * HPAD; //only use a 4 * HPAD padding if an ignore button exists } if (mIsScriptDialog && mute_btn != NULL) { LLRect mute_btn_rect(mute_btn->getRect()); // Place mute (Block) button to the left of the ignore button. S32 mute_btn_left = max_width - mute_btn_rect.getWidth() - ignore_btn_width - mute_btn_pad; mute_btn_rect.setOriginAndSize(mute_btn_left, BOTTOM_PAD,// always move mute button at the bottom mute_btn_rect.getWidth(), mute_btn_rect.getHeight()); mute_btn->setRect(mute_btn_rect); mControlPanel->addChild(mute_btn); } }
void LLToastNotifyPanel::updateButtonsLayout(const std::vector<index_button_pair_t>& buttons, S32 h_pad) { S32 left = 0; //reserve place for ignore button S32 bottom_offset = mIsScriptDialog ? (BTN_HEIGHT + IGNORE_BTN_TOP_DELTA + BOTTOM_PAD) : BOTTOM_PAD; S32 max_width = mControlPanel->getRect().getWidth(); LLButton* ignore_btn = NULL; for (std::vector<index_button_pair_t>::const_iterator it = buttons.begin(); it != buttons.end(); it++) { if (it->first == -1) { ignore_btn = it->second; continue; } LLButton* btn = it->second; LLRect btn_rect(btn->getRect()); if (left + btn_rect.getWidth() > max_width)// whether there is still some place for button+h_pad in the mControlPanel { // looks like we need to add button to the next row left = 0; bottom_offset += (BTN_HEIGHT + VPAD); } //we arrange buttons from bottom to top for backward support of old script btn_rect.setOriginAndSize(left, bottom_offset, btn_rect.getWidth(), btn_rect.getHeight()); btn->setRect(btn_rect); left = btn_rect.mLeft + btn_rect.getWidth() + h_pad; mControlPanel->addChild(btn, -1); } if (mIsScriptDialog && ignore_btn != NULL) { LLRect ignore_btn_rect(ignore_btn->getRect()); S32 buttons_per_row = max_width / BUTTON_WIDTH; //assume that h_pad far less than BUTTON_WIDTH S32 ignore_btn_left = buttons_per_row * BUTTON_WIDTH + (buttons_per_row - 1) * h_pad - ignore_btn_rect.getWidth(); if (ignore_btn_left + ignore_btn_rect.getWidth() > max_width)// make sure that the ignore button is in panel { ignore_btn_left = max_width - ignore_btn_rect.getWidth() - 2 * HPAD; } ignore_btn_rect.setOriginAndSize(ignore_btn_left, BOTTOM_PAD,// always move ignore button at the bottom ignore_btn_rect.getWidth(), ignore_btn_rect.getHeight()); ignore_btn->setRect(ignore_btn_rect); mControlPanel->addChild(ignore_btn, -1); } }
void ComboBox::Draw() { int x = 0; int y = 0; int w = rect.w; int h = rect.h; if (w < 1 || h < 1 || !shown) return; Rect btn_rect(x,y,w,h); // draw the bevel: DrawRectSimple(btn_rect, button_state); // draw the border: if (border) DrawRect(0,0,w-1,h-1,border_color); // draw the arrow: POINT arrow[3]; double h3 = (double)h/3.0; arrow[0].x = (int) (w-2*h3); arrow[0].y = (int) (h3); arrow[1].x = (int) (w-h3); arrow[1].y = (int) (h3); arrow[2].x = (int) ((arrow[1].x + arrow[0].x)/2); arrow[2].y = (int) (2*h3); FillPoly(3, arrow, border_color); // draw text here: Text caption = text; if (GetSelectedIndex() >= 0) caption = GetSelectedItem(); if (font && caption.length()) { int border_size = 4; if (style & WIN_RAISED_FRAME && style & WIN_SUNK_FRAME) border_size = 8; Rect label_rect = CalcLabelRect(); int vert_space = label_rect.h; int horz_space = label_rect.w; DrawText(caption.data(), 0, label_rect, DT_CALCRECT | DT_WORDBREAK | text_align); vert_space = (vert_space - label_rect.h)/2; label_rect.w = horz_space; if (vert_space > 0) label_rect.y += vert_space; if (animated && button_state > 0) { label_rect.x += button_state; label_rect.y += button_state; } font->SetColor(fore_color); DrawText(caption.data(), 0, label_rect, DT_WORDBREAK | text_align); } }
eos::StatusBar::StatusBar(const ax::Rect& rect) : _font(0) , _fullscreen_frame(false, "") , _is_down(false) { win = ax::Window::Create(rect); win->event.OnMouseLeftDown = ax::WFunc<ax::Point>([&](const ax::Point& pos) { win->Update(); }); // win->event.OnBeforeDrawing = ax::WFunc<int>([&](const int& nothing) { // if (win->state.Get(ax::Window::StateOption::NeedUpdate)) { // unsigned char* bg_data = nullptr; // ax::Rect d_rect = win->GetWindowPixelData(bg_data); // _bg_img = std::shared_ptr<ax::Image>(new ax::Image( // bg_data, d_rect.size, ax::Image::ColorType::RGBA)); // delete bg_data; // } // }); win->event.OnMouseEnter = ax::WBind<ax::Point>(this, &StatusBar::OnMouseEnter); win->event.OnMouseLeave = ax::WBind<ax::Point>(this, &StatusBar::OnMouseLeave); win->event.OnPaint = ax::WBind<ax::GC>(this, &StatusBar::OnPaint); _user_name = "Alexandre Arsenault"; //_system->GetUser()->GetFullName(); _clock = std::shared_ptr<eos::Clock>( new eos::Clock(ax::Rect(rect.size.x - 140, 0, 140, rect.size.y))); win->node.Add(_clock); // Transparent button. ax::Button::Info btn_info; btn_info.normal = ax::Color(0.0, 0.0); btn_info.hover = ax::Color(0.0, 0.0); btn_info.clicking = ax::Color(0.0, 0.0); btn_info.selected = ax::Color(0.0, 0.0); btn_info.contour = ax::Color(0.0, 0.0); btn_info.font_color = ax::Color(0.0, 0.0); btn_info.round_corner_radius = 0; #if EOS_PLATFORM_TYPE == EOS_TABLET const ax::Size btn_size(35, 35); #else const ax::Size btn_size(20, 20); #endif // Volume. win->node.Add(ax::Button::Ptr( new ax::Button(ax::Rect(ax::Point(rect.size.x - 310, 3), btn_size), ax::Button::Events(), btn_info, "resources/volume51.png", "", ax::Button::Flags::SINGLE_IMG))); using AppInfo = std::pair<std::string, ax::Event::Function>; #define APP_INFO(path, fct_name) AppInfo(path, ax::Event::Bind(this, &StatusBar::fct_name)) // Status bar icons info. std::vector<AppInfo> app_info = { APP_INFO("resources/home.png", OnHome), APP_INFO("resources/sort52.png", OnNotificationMode), APP_INFO("resources/view.png", OnAppViewer), APP_INFO("resources/terminal_mode.png", OnTerminalMode), APP_INFO("resources/setting.png", OnSettings), APP_INFO("resources/list88.png", OnTraceMode), APP_INFO("resources/circles23.png", OnApp3D), APP_INFO("resources/elipse.png", OnView) }; #undef APP_INFO ax::Rect btn_rect(ax::Point(6, 3), btn_size); ax::Window::Ptr btn; // Create all status bar icons. for (auto& n : app_info) { btn = win->node.Add(ax::Button::Ptr(new ax::Button(btn_rect, n.second, btn_info, n.first, "", ax::Button::Flags::SINGLE_IMG))); btn_rect.position = btn->dimension.GetRect().GetNextPosRight(5); } eos::sys::proxy::ConnectToAppManager(eos::sys::AppManager::FRAME_FULL_SCREEN, ax::Event::Bind(this, &eos::StatusBar::OnFrameFullScreen)); eos::sys::proxy::ConnectToAppManager(eos::sys::AppManager::UN_FULLSCREEN_FRAME, ax::Event::Bind(this, &eos::StatusBar::OnFrameUnFullScreen)); }
void engine::runner(int i){ device->getTimer()->tick(); unsigned int timerv = (unsigned int)clock(); static bool lbutton_rb = false; static int rb_x = 0; static int rb_y = 0; static int rb_mx = 0; static int rb_my = 0; static bool lbutton_clicking = false; driver->beginScene(true, true, 0, videodata); if(c_x < 200){ if(lbutton){ if(!lbutton_clicking) lbutton_clicking = true; }else{ if(lbutton_clicking){ int whichone = -1; int whichfound = -1; vector<irr::core::rect<irr::s32> >::iterator itr; for(itr = sprite_buttons.begin(); itr!=sprite_buttons.end(); itr++){ whichone++; if(itr->isPointInside(irr::core::vector2d<irr::s32>(c_x, c_y))){ whichfound = whichone; break; } } sprite_selected = whichfound; } lbutton_clicking = false; } } if(sprite_selected > -1){ driver->draw2DRectangle(irr::video::SColor(255,255,255,255), sprite_buttons[sprite_selected]); } for(vector<camera>::iterator camitr = cam.begin(); camitr != cam.end(); camitr++){ camitr->render(); } int sticky_x = 80; int sticky_y = 80; if(c_x > 200){ if(lbutton){ if(!lbutton_clicking) lbutton_clicking = true; }else{ int place_x_at = (c_x) - (c_x % sticky_x) - (cam[0].x % sticky_x) - (sticky_x /2); int place_y_at = c_y - (c_y % sticky_y) + (cam[0].y % sticky_y); int rel_x = c_x + cam[0].x; int rel_y = cam[0].y - c_y; int p_rel_x = place_x_at + cam[0].x; int p_rel_y = cam[0].y - place_y_at; int prtc_x = rel_x - cam[0].sx; // Position Relative to Camera int prtc_y = cam[0].sy+cam[0].h+rel_y; int p_prtc_x = p_rel_x - cam[0].sx; int p_prtc_y = cam[0].sy+cam[0].h+p_rel_y; if(lbutton_clicking){ if(sprite_selected == -1){ for(vector<boost::shared_ptr<map_object> >::iterator itr = app.eng.gd.map_objects.begin(); itr != app.eng.gd.map_objects.end();itr++){ irr::core::rect<irr::s32> mo_rect((*itr)->x, (*itr)->y1, (*itr)->x1, (*itr)->y); if(mo_rect.isPointInside(irr::core::vector2d<irr::s32>(prtc_x, prtc_y))){ (*itr)->to_remove = true; } } }else{ string found_sprite_class = ""; map<string, sprite_class>::iterator sc_itr; int cnt = -1; for(sc_itr = gd.sprite_classes.begin(); sc_itr != gd.sprite_classes.end(); sc_itr++){ if(++cnt == sprite_selected){ found_sprite_class = sc_itr->first; break; } } boost::shared_ptr<map_object> new_object(new map_object()); new_object->sprite_class = found_sprite_class; new_object->object_name = ""; new_object->x = p_prtc_x; new_object->y = p_prtc_y; new_object->x1 = new_object->x+80; new_object->y1 = new_object->y-80; for(int i=0; i<50; i++){ new_object->active_layer_frames.push_back(0); new_object->rotations.push_back(0); } md.map_objects.push_back(new_object); } } lbutton_clicking = false; } if(rbutton){ if(!lbutton_rb){ lbutton_rb = true; rb_x = cam[0].x; rb_y = cam[0].y; rb_mx = c_x; rb_my = c_y; }else{ cam[0].x = rb_x - (c_x - rb_mx); cam[0].y = (c_y - rb_my) + rb_y; int cam_width = cam[0].w; int cam_height =cam[0].h; int avg_px = 0; int avg_py = 0; int total_px = 0; int total_py = 0; int total_players = 0; int x = cam[0].x - (cam_width/2); int y = cam[0].y - (cam_height/2); if(x < 0){x = 0;} if(y < 0){y = 0;} int center_x = x; int center_y = y; if(cam_width > 0 && cam_height > 0){ if((center_x - md.c_x) > cam[0].w/2 || (center_y - md.c_y) > cam[0].h/2 || (md.c_x - center_x) > cam[0].w/2 || (md.c_y - center_y) > cam[0].h/2){ #ifdef _DEBUG static int map_load_count = 0; string obj_count = boost::lexical_cast<string>((int)md.map_objects.size()); string out_str = "Map load " + boost::lexical_cast<string>(map_load_count++) + " map objects: " + obj_count + "\n"; ::OutputDebugStringA(out_str.data()); #endif //app.eng.gd.cull_map(md, md.loaded_x, md.loaded_y, md.loaded_x1, md.loaded_y1); int l_x = x - (cam[0].w+LOAD_REGION); int l_y = y - (cam[0].h+LOAD_REGION); int l_x1 = x + ((2*cam[0].w)+LOAD_REGION); int l_y1 = y + ((2*cam[0].h)+LOAD_REGION); md.c_x = center_x; md.c_y = center_y; app.eng.gd.load_map_from_coordinates(md, l_x, l_y, l_x1, l_y1); app.eng.gd.cull_map(md, l_x, l_y, l_x1, l_y1); } } } }else{ lbutton_rb = false; } if(sprite_selected > -1){ map<string, sprite_class>::iterator sc_itr; int cnt = -1; for(sc_itr = gd.sprite_classes.begin(); sc_itr != gd.sprite_classes.end(); sc_itr++){ if(++cnt == sprite_selected){ int x_at = (c_x) - (c_x % sticky_x) - (cam[0].x % sticky_x) - (sticky_x /2); int y_at = c_y - (c_y % sticky_y) + (cam[0].y % sticky_y); int width = 80; int height = 80; if(sc_itr->second.layers[0].images[0]){ driver->draw2DImage(sc_itr->second.layers[0].images[0], irr::core::vector2d<irr::s32>(x_at, y_at), irr::core::rect<irr::s32>(0,0,width,height), 0,irr::video::SColor(255,255,255,255),true); } } } } } if(cam[0].x < 0){ irr::core::vector2d<irr::s32> a_point; a_point.X = 0 - cam[0].x + cam[0].sx; a_point.Y = 0; irr::core::vector2d<irr::s32> b_point; b_point.X = 0 - cam[0].x + cam[0].sx; b_point.Y = cam[0].h; driver->draw2DLine(a_point, b_point); } if(cam[0].y < 0){ irr::core::vector2d<irr::s32> a_point; a_point.X = cam[0].sx; a_point.Y = cam[0].y + cam[0].h; irr::core::vector2d<irr::s32> b_point; b_point.X = cam[0].w + cam[0].sx; b_point.Y = cam[0].y + cam[0].h; driver->draw2DLine(a_point, b_point); } if(cam[0].y + cam[0].h > app.eng.map_height){ irr::core::vector2d<irr::s32> a_point; a_point.X = cam[0].sx; a_point.Y = cam[0].y + cam[0].h - app.eng.map_height; irr::core::vector2d<irr::s32> b_point; b_point.X = cam[0].w + cam[0].sx; b_point.Y = cam[0].y + cam[0].h - app.eng.map_height; driver->draw2DLine(a_point, b_point); } if(cam[0].x + cam[0].w > app.eng.map_width){ irr::core::vector2d<irr::s32> a_point; a_point.X = app.eng.map_width - cam[0].x + cam[0].w + cam[0].sx; a_point.Y = 0; irr::core::vector2d<irr::s32> b_point; b_point.X = app.eng.map_width - cam[0].x + cam[0].w + cam[0].sx; b_point.Y = cam[0].h; driver->draw2DLine(a_point, b_point); } map<string, sprite_class>::iterator sc_itr; int cnt = -1; int y_at = 10; int x_at = 10; for(sc_itr = gd.sprite_classes.begin(); sc_itr != gd.sprite_classes.end(); sc_itr++){ cnt++; int width = sc_itr->second.w; int height = sc_itr->second.h; if(width == 0) width = 80; if(height == 0){ height = 80; } irr::core::rect<irr::s32> btn_rect(x_at, y_at, x_at + width, y_at + height); sprite_buttons.push_back(btn_rect); if(sc_itr->second.layers[0].images[0]){ driver->draw2DImage(sc_itr->second.layers[0].images[0], irr::core::vector2d<irr::s32>(x_at, y_at), irr::core::rect<irr::s32>(0,0,width,height), 0,irr::video::SColor(255,255,255,255),true); } if(cnt % 2 == 0){ x_at = width + 30; }else{ x_at = 10; y_at += height + 20; } } smgr->drawAll(); driver->endScene(); }
void Button::Draw() { if (!IsShown()) return; int x = 0; int y = 0; int w = rect.w; int h = rect.h; int img_w = picture.Width(); int img_h = picture.Height(); float old_alpha = alpha; if (!enabled) SetAlpha(0.35); Rect btn_rect(x,y,w,h); if (!transparent) { if (standard_image) { if (!enabled) { texture = standard_image; } else { switch (button_state) { case -1: texture = activated_image; break; default: case 0: texture = standard_image; break; case 1: if (sticky) texture = activated_image; else texture = transition_image; break; case 2: texture = transition_image; break; } } if (!texture) texture = standard_image; DrawTextureGrid(); } else { FillRect(0, 0, w, h, ShadeColor(back_color, 1.0)); DrawStyleRect(0, 0, w, h, style); } } // draw the picture (if any) if (picture.Width()) { Rect irect = CalcPictureRect(); DrawImage(&picture, irect); } // draw text here: if (font && text.length()) { Rect label_rect = CalcLabelRect(img_w,img_h); int vert_space = label_rect.h; int horz_space = label_rect.w; int align = DT_WORDBREAK | text_align; DrawText(text.data(), 0, label_rect, DT_CALCRECT | align); vert_space = (vert_space - label_rect.h)/2; label_rect.w = horz_space; if (vert_space > 0) label_rect.y += vert_space; if (animated && button_state > 0) { label_rect.x += button_state; label_rect.y += button_state; } if (drop_shadow) { label_rect.x++; label_rect.y++; font->SetColor(back_color); DrawText(text.data(), text.length(), label_rect, align); label_rect.x--; label_rect.y--; } font->SetColor(fore_color); DrawText(text.data(), text.length(), label_rect, align); } if (!enabled) SetAlpha(old_alpha); }