void centerPixmaps(QPixmap &from, QPixmap &to) { if (from.size() == to.size() && from.hasAlphaChannel() && to.hasAlphaChannel()) { return; } QRect fromRect(from.rect()); QRect toRect(to.rect()); QRect actualRect = QRect(QPoint(0,0), fromRect.size().expandedTo(toRect.size())); fromRect.moveCenter(actualRect.center()); toRect.moveCenter(actualRect.center()); if (from.size() != actualRect.size() || !from.hasAlphaChannel()) { QPixmap result(actualRect.size()); result.fill(Qt::transparent); QPainter p(&result); p.setCompositionMode(QPainter::CompositionMode_Source); p.drawPixmap(fromRect.topLeft(), from); p.end(); from = result; } if (to.size() != actualRect.size() || !to.hasAlphaChannel()) { QPixmap result(actualRect.size()); result.fill(Qt::transparent); QPainter p(&result); p.setCompositionMode(QPainter::CompositionMode_Source); p.drawPixmap(toRect.topLeft(), to); p.end(); to = result; } }
/** * When reading menu config files, we use this to set common variables */ bool Menu::parseMenuKey(const std::string &key, const std::string &val) { // @CLASS Menu|Description of menus in menus/ std::string value = val; if (key == "pos") { // @ATTR pos|x (integer), y (integer), w (integer), h (integer)|Menu position and dimensions value = value + ','; window_area = toRect(value); } else if (key == "align") { // @ATTR align|alignment|Position relative to screen edges alignment = value; } else if (key == "soundfx_open") { // @ATTR soundfx_open|string|Filename of a sound to play when opening this menu. sfx_open = snd->load(value, "Menu open tab"); } else if (key == "soundfx_close") { // @ATTR soundfx_close|string|Filename of a sound to play when closing this menu. sfx_close = snd->load(value, "Menu close tab"); } else { //not a common key return false; } return true; }
QRect LauncherPlacer::getCoordinates() const { auto rect = _getCoordinatesForStandardWall(); if (_launcherIsTooHigh(rect)) _centerVertically(rect); return rect.toRect(); }
MenuDevConsole::MenuDevConsole() : Menu() { button_close = new WidgetButton("images/menus/buttons/button_x.png"); tablist.add(button_close); input_box = new WidgetInput("images/menus/input_console.png"); tablist.add(input_box); button_confirm = new WidgetButton(); button_confirm->label = msg->get("Execute"); tablist.add(button_confirm); // Load config settings FileParser infile; // @CLASS MenuDevConsole|Description of menus/devconsole.txt if(infile.open("menus/devconsole.txt")) { while(infile.next()) { if (parseMenuKey(infile.key, infile.val)) continue; // @ATTR close|x (integer), y (integer)|Position of the close button. if(infile.key == "close") { Point pos = toPoint(infile.val); button_close->setBasePos(pos.x, pos.y); } // @ATTR label_title|label|Position of the "Developer Console" label. else if(infile.key == "label_title") title = eatLabelInfo(infile.val); // @ATTR confirm|x (integer), y (integer)|Position of the "Execute" button. else if(infile.key == "confirm") { Point pos = toPoint(infile.val); button_confirm->setBasePos(pos.x, pos.y); } // @ATTR input|x (integer), y (integer)|Position of the command entry widget. else if(infile.key == "input") { Point pos = toPoint(infile.val); input_box->setBasePos(pos.x, pos.y); } // @ATTR history|x (integer), y (integer), w (integer), h (integer)|Position and dimensions of the command history. else if(infile.key == "history") history_area = toRect(infile.val); else infile.error("MenuDevConsole: '%s' is not a valid key.", infile.key.c_str()); } infile.close(); } log_history = new WidgetLog(history_area.w, history_area.h); log_history->setBasePos(history_area.x, history_area.y); tablist.add(log_history->getWidget()); setBackground("images/menus/dev_console.png"); color_echo = font->getColor("widget_disabled"); color_error = font->getColor("menu_penalty"); align(); input_box->inFocus = true; }
MenuLog::MenuLog() { visible = false; closeButton = new WidgetButton("images/menus/buttons/button_x.png"); // Load config settings FileParser infile; // @CLASS MenuLog|Description of menus/log.txt if(infile.open("menus/log.txt")) { while(infile.next()) { if (parseMenuKey(infile.key, infile.val)) continue; // @ATTR label_title|label|Position of the "Log" text. if(infile.key == "label_title") { title = eatLabelInfo(infile.val); } // @ATTR close|point|Position of the close button. else if(infile.key == "close") { Point pos = toPoint(infile.val); closeButton->setBasePos(pos.x, pos.y); } // @ATTR tab_area|rectangle|The position of the row of tabs, followed by the dimensions of the log text area. else if(infile.key == "tab_area") { tab_area = toRect(infile.val); } else { infile.error("MenuLog: '%s' is not a valid key.", infile.key.c_str()); } } infile.close(); } // Initialize the tab control. tabControl = new WidgetTabControl(); tablist.add(tabControl); // Store the amount of displayed log messages on each log, and the maximum. tablist_log.resize(LOG_TYPE_COUNT); for (unsigned i=0; i<LOG_TYPE_COUNT; i++) { log[i] = new WidgetLog(tab_area.w,tab_area.h); log[i]->setBasePos(tab_area.x, tab_area.y + tabControl->getTabHeight()); tablist_log[i].add(log[i]->getWidget()); tablist_log[i].setPrevTabList(&tablist); tablist_log[i].lock(); } // Define the header. tabControl->setTabTitle(LOG_TYPE_MESSAGES, msg->get("Notes")); tabControl->setTabTitle(LOG_TYPE_QUESTS, msg->get("Quests")); setBackground("images/menus/log.png"); align(); }
/** * @brief Relation::recalculateLine */ void Relation::recalculateLine() { QPolygonF fromRect(m_From->mapToScene(m_From->frameRect())); QPolygonF toRect(m_To->mapToScene(m_To->frameRect())); setVisible(fromRect.intersected(toRect).isEmpty()); if (isVisible()) { setP1(intersection(fromRect, QLineF(m_From->pos(), line().p2()))); setP2(intersection(toRect, QLineF(line().p1(), m_To->pos()))); } }
bool rspfDrect::loadState(const rspfKeywordlist& kwl, const char* prefix) { const char* rect = kwl.find(prefix, "rect"); makeNan(); if(rect) { toRect(rect); } return true; }
std::vector<cv::Rect> MxArray::toVector() const { if (isNumeric()) { std::vector<cv::Rect> vr; if (numel() == 4) vr.push_back(toRect()); else toMat(CV_32S).reshape(4, 0).copyTo(vr); return vr; } else { return toVector( std::const_mem_fun_ref_t<cv::Rect, MxArray>(&MxArray::toRect)); } }
MenuPowers::MenuPowers(StatBlock *_stats, MenuActionBar *_action_bar) : stats(_stats) , action_bar(_action_bar) , skip_section(false) , powers_unlock(NULL) , overlay_disabled(NULL) , points_left(0) , default_background("") , tab_control(NULL) , tree_loaded(false) , prev_powers_list_size(0) , newPowerNotification(false) { closeButton = new WidgetButton("images/menus/buttons/button_x.png"); // Read powers data from config file FileParser infile; // @CLASS MenuPowers: Menu layout|Description of menus/powers.txt if (infile.open("menus/powers.txt")) { while (infile.next()) { if (parseMenuKey(infile.key, infile.val)) continue; // @ATTR label_title|label|Position of the "Powers" text. if (infile.key == "label_title") title = eatLabelInfo(infile.val); // @ATTR unspent_points|label|Position of the text that displays the amount of unused power points. else if (infile.key == "unspent_points") unspent_points = eatLabelInfo(infile.val); // @ATTR close|point|Position of the close button. else if (infile.key == "close") close_pos = toPoint(infile.val); // @ATTR tab_area|rectangle|Position and dimensions of the tree pages. else if (infile.key == "tab_area") tab_area = toRect(infile.val); else infile.error("MenuPowers: '%s' is not a valid key.", infile.key.c_str()); } infile.close(); } loadGraphics(); menu_powers = this; color_bonus = font->getColor("menu_bonus"); color_penalty = font->getColor("menu_penalty"); color_flavor = font->getColor("item_flavor"); align(); }
TEST(AffineTransform, MakeMapBetweenRects) { WebCore::AffineTransform transform; WebCore::FloatRect fromRect(10.0f, 10.0f, 100.0f, 100.0f); WebCore::FloatRect toRect(70.0f, 70.0f, 200.0f, 50.0f); auto mapBetween = WebCore::makeMapBetweenRects(fromRect, toRect); EXPECT_DOUBLE_EQ(2.0, mapBetween.a()); EXPECT_DOUBLE_EQ(0.0, mapBetween.b()); EXPECT_DOUBLE_EQ(0.0, mapBetween.c()); EXPECT_DOUBLE_EQ(0.5, mapBetween.d()); EXPECT_DOUBLE_EQ(60.0, mapBetween.e()); EXPECT_DOUBLE_EQ(60.0, mapBetween.f()); }
MenuEnemy::MenuEnemy() : bar_hp(NULL) , custom_text_pos(false) , enemy(NULL) , timeout(0) { // Load config settings FileParser infile; // @CLASS MenuEnemy|Description of menus/enemy.txt if(infile.open("menus/enemy.txt")) { while(infile.next()) { if (parseMenuKey(infile.key, infile.val)) continue; infile.val = infile.val + ','; // @ATTR bar_pos|rectangle|Position and dimensions of the health bar. if(infile.key == "bar_pos") { bar_pos = toRect(infile.val); } // @ATTR text_pos|label|Position of the text displaying the enemy's name and level. else if(infile.key == "text_pos") { custom_text_pos = true; text_pos = eatLabelInfo(infile.val); } else { infile.error("MenuEnemy: '%s' is not a valid key.", infile.key.c_str()); } } infile.close(); } loadGraphics(); color_normal = font->getColor("menu_normal"); align(); }
MenuInventory::MenuInventory(StatBlock *_stats) { stats = _stats; MAX_EQUIPPED = 4; MAX_CARRIED = 64; visible = false; setBackground("images/menus/inventory.png"); currency = 0; carried_cols = 4; // default to 4 if menus/inventory.txt::carried_cols not set carried_rows = 4; // default to 4 if menus/inventory.txt::carried_rows not set drag_prev_src = -1; changed_equipment = true; log_msg = ""; show_book = ""; closeButton = new WidgetButton("images/menus/buttons/button_x.png"); // Load config settings FileParser infile; // @CLASS MenuInventory|Description of menus/inventory.txt if (infile.open("menus/inventory.txt")) { while(infile.next()) { if (parseMenuKey(infile.key, infile.val)) continue; // @ATTR close|x (integer), y (integer)|Position of the close button. if(infile.key == "close") { Point pos = toPoint(infile.val); closeButton->setBasePos(pos.x, pos.y); } // @ATTR equipment_slot|x (integer), y (integer), size (integer), slot_type (string)|Position and item type of an equipment slot. else if(infile.key == "equipment_slot") { Rect area; Point pos; pos.x = area.x = popFirstInt(infile.val); pos.y = area.y = popFirstInt(infile.val); area.w = area.h = popFirstInt(infile.val); equipped_area.push_back(area); equipped_pos.push_back(pos); slot_type.push_back(popFirstString(infile.val)); } // @ATTR slot_name|string|The displayed name of the last defined equipment slot. else if(infile.key == "slot_name") slot_desc.push_back(infile.val); // @ATTR carried_area|x (integer), y (integer)|Position of the first normal inventory slot. else if(infile.key == "carried_area") { Point pos; carried_pos.x = carried_area.x = popFirstInt(infile.val); carried_pos.y = carried_area.y = popFirstInt(infile.val); } // @ATTR carried_cols|integer|The number of columns for the normal inventory. else if (infile.key == "carried_cols") carried_cols = std::max(1, toInt(infile.val)); // @ATTR carried_rows|integer|The number of rows for the normal inventory. else if (infile.key == "carried_rows") carried_rows = std::max(1, toInt(infile.val)); // @ATTR label_title|label|Position of the "Inventory" label. else if (infile.key == "label_title") title = eatLabelInfo(infile.val); // @ATTR currency|label|Position of the label that displays the total currency being carried. else if (infile.key == "currency") currency_lbl = eatLabelInfo(infile.val); // @ATTR help|x (integer), y (integer), w (integer), h (integer)|A mouse-over area that displays some help text for inventory shortcuts. else if (infile.key == "help") help_pos = toRect(infile.val); else infile.error("MenuInventory: '%s' is not a valid key.", infile.key.c_str()); } infile.close(); } MAX_EQUIPPED = equipped_area.size(); MAX_CARRIED = carried_cols * carried_rows; carried_area.w = carried_cols*ICON_SIZE; carried_area.h = carried_rows*ICON_SIZE; color_normal = font->getColor("menu_normal"); color_high = font->getColor("menu_bonus"); inventory[EQUIPMENT].init(MAX_EQUIPPED, equipped_area, slot_type); inventory[CARRIED].init(MAX_CARRIED, carried_area, ICON_SIZE, carried_cols); for (int i = 0; i < MAX_EQUIPPED; i++) { tablist.add(inventory[EQUIPMENT].slots[i]); } for (int i = 0; i < MAX_CARRIED; i++) { tablist.add(inventory[CARRIED].slots[i]); } align(); }
MenuExit::MenuExit() : Menu() { buttonExit = new WidgetButton(); buttonClose = new WidgetButton(); // widgets for game options music_volume_sl = new WidgetSlider(); sound_volume_sl = new WidgetSlider(); // Load config settings FileParser infile; // @CLASS MenuExit|Description of menus/exit.txt if(infile.open("menus/exit.txt")) { while(infile.next()) { if (parseMenuKey(infile.key, infile.val)) continue; else if (infile.key == "title") { // @ATTR title|label|Position of the "Paused" text. title = eatLabelInfo(infile.val); } else if (infile.key == "exit") { // @ATTR exit|point|Position of the "Save and Exit" button. Point p = toPoint(infile.val); buttonExit->setBasePos(p.x, p.y); } else if (infile.key == "continue") { // @ATTR continue|point|Position of the "Continue" button. Point p = toPoint(infile.val); buttonClose->setBasePos(p.x, p.y); } else if (infile.key == "music_volume") { // @ATTR music_volume|int, int, int, int : Label X, Label Y, Widget X, Widget Y|Position of the "Music Volume" slider relative to the frame. Rect r = toRect(infile.val); placeOptionWidgets(&music_volume_lb, music_volume_sl, r.x, r.y, r.w, r.h, msg->get("Music Volume")); } else if (infile.key == "sound_volume") { // @ATTR sound_volume|int, int, int, int : Label X, Label Y, Widget X, Widget Y|Position of the "Sound Volume" slider relative to the frame. Rect r = toRect(infile.val); placeOptionWidgets(&sound_volume_lb, sound_volume_sl, r.x, r.y, r.w, r.h, msg->get("Sound Volume")); } else infile.error("MenuExit: '%s' is not a valid key.", infile.key.c_str()); } infile.close(); } exitClicked = false; reload_music = false; if (SAVE_ONEXIT) buttonExit->label = msg->get("Save & Exit"); else buttonExit->label = msg->get("Exit"); buttonClose->label = msg->get("Continue"); setBackground("images/menus/pause_menu.png"); if (AUDIO) { music_volume_sl->set(0, 128, MUSIC_VOLUME); sound_volume_sl->set(0, 128, SOUND_VOLUME); } else { music_volume_sl->set(0, 128, 0); sound_volume_sl->set(0, 128, 0); } tablist.add(buttonClose); tablist.add(buttonExit); tablist.add(music_volume_sl); tablist.add(sound_volume_sl); align(); }
MenuInventory::MenuInventory(StatBlock *_stats) : stats(_stats) , MAX_EQUIPPED(4) , MAX_CARRIED(64) , carried_cols(4) , carried_rows(4) , tap_to_activate_ticks(0) , currency(0) , drag_prev_src(-1) , changed_equipment(true) , inv_ctrl(INV_CTRL_NONE) , show_book("") { visible = false; setBackground("images/menus/inventory.png"); closeButton = new WidgetButton("images/menus/buttons/button_x.png"); // Load config settings FileParser infile; // @CLASS MenuInventory|Description of menus/inventory.txt if (infile.open("menus/inventory.txt")) { while(infile.next()) { if (parseMenuKey(infile.key, infile.val)) continue; // @ATTR close|point|Position of the close button. if(infile.key == "close") { Point pos = toPoint(infile.val); closeButton->setBasePos(pos.x, pos.y); } // @ATTR equipment_slot|repeatable(int, int, string) : X, Y, Slot Type|Position and item type of an equipment slot. else if(infile.key == "equipment_slot") { Rect area; Point pos; pos.x = area.x = popFirstInt(infile.val); pos.y = area.y = popFirstInt(infile.val); area.w = area.h = ICON_SIZE; equipped_area.push_back(area); equipped_pos.push_back(pos); slot_type.push_back(popFirstString(infile.val)); } // @ATTR carried_area|point|Position of the first normal inventory slot. else if(infile.key == "carried_area") { Point pos; carried_pos.x = carried_area.x = popFirstInt(infile.val); carried_pos.y = carried_area.y = popFirstInt(infile.val); } // @ATTR carried_cols|int|The number of columns for the normal inventory. else if (infile.key == "carried_cols") carried_cols = std::max(1, toInt(infile.val)); // @ATTR carried_rows|int|The number of rows for the normal inventory. else if (infile.key == "carried_rows") carried_rows = std::max(1, toInt(infile.val)); // @ATTR label_title|label|Position of the "Inventory" label. else if (infile.key == "label_title") title = eatLabelInfo(infile.val); // @ATTR currency|label|Position of the label that displays the total currency being carried. else if (infile.key == "currency") currency_lbl = eatLabelInfo(infile.val); // @ATTR help|rectangle|A mouse-over area that displays some help text for inventory shortcuts. else if (infile.key == "help") help_pos = toRect(infile.val); else infile.error("MenuInventory: '%s' is not a valid key.", infile.key.c_str()); } infile.close(); } MAX_EQUIPPED = static_cast<int>(equipped_area.size()); MAX_CARRIED = carried_cols * carried_rows; carried_area.w = carried_cols*ICON_SIZE; carried_area.h = carried_rows*ICON_SIZE; color_normal = font->getColor("menu_normal"); color_high = font->getColor("menu_bonus"); inventory[EQUIPMENT].initFromList(MAX_EQUIPPED, equipped_area, slot_type); inventory[CARRIED].initGrid(MAX_CARRIED, carried_area, carried_cols); for (int i = 0; i < MAX_EQUIPPED; i++) { tablist.add(inventory[EQUIPMENT].slots[i]); } for (int i = 0; i < MAX_CARRIED; i++) { tablist.add(inventory[CARRIED].slots[i]); } align(); }
QRect toRect(QPolygonF polygon) { return toRect(polygon.toPolygon()); }
void dtkComposerCompass::paintEvent(QPaintEvent *event) { if(!d->view) return; if(event->rect().width() < 20 || event->rect().height() < 20) return; bool fit = false; if (d->s_rect != d->view->sceneRect().toRect()) { d->s_rect = d->view->sceneRect().toRect(); fit = true; } if (d->t_rect != event->rect()) { d->t_rect = event->rect(); fit = true; } if(fit && (d->s_rect.width() > d->t_rect.width() || d->s_rect.height() > d->t_rect.height())) this->fitInView(this->scene()->sceneRect(), Qt::KeepAspectRatio); // -- QGraphicsView::paintEvent(event); // -- Map source view to target view through scene d->c_rect = toRect(d->view->mapToScene(d->view->rect())); d->c_rect = toRect(this->mapFromScene(d->c_rect)); // -- if(d->c_rect.contains(d->t_rect)) return; // -- QPainterPath cropPath; cropPath.addRect(d->c_rect); QPainterPath windowPath; windowPath.addRect(d->t_rect); windowPath -= cropPath; QPainter painter(this->viewport()); painter.setRenderHints(QPainter::Antialiasing); // Draw Alpha-Black Background. painter.fillPath(windowPath, QColor(0x83, 0x83, 0x83, 0x77)); // Draw Crop Rect painter.setPen(QPen(QColor(0xdd, 0xdd, 0xdd), 1)); painter.drawPath(cropPath); // -- int topRightX = d->c_rect.x() + d->c_rect.width(); int bottomY = d->c_rect.y() + d->c_rect.height(); qreal f = 1.0f / CROP_GRID_SIZE; qreal hsize = d->c_rect.height() * f; qreal wsize = d->c_rect.width() * f; QPainterPath gridPath; for (uint i = 1; i < CROP_GRID_SIZE; ++i) { qreal y = d->c_rect.y() + i * hsize; gridPath.moveTo(d->c_rect.x(), y); gridPath.lineTo(topRightX, y); for (uint j = 1; j < CROP_GRID_SIZE; ++j) { qreal x = d->c_rect.x() + j * wsize; gridPath.moveTo(x, d->c_rect.y()); gridPath.lineTo(x, bottomY); } } // Draw Grid Path painter.setPen(QPen(QColor(0x99, 0x99, 0x99, 0x80), 1)); painter.drawPath(gridPath); // -- QPainterPath borderPath; // Top-Left Corner borderPath.moveTo(d->c_rect.x(), d->c_rect.y()); borderPath.lineTo(d->c_rect.x() + CROP_BORDER_LINE, d->c_rect.y()); borderPath.moveTo(d->c_rect.x(), d->c_rect.y()); borderPath.lineTo(d->c_rect.x(), d->c_rect.y() + CROP_BORDER_LINE); // Top-Right Corner borderPath.moveTo(topRightX - CROP_BORDER_LINE, d->c_rect.y()); borderPath.lineTo(topRightX, d->c_rect.y()); borderPath.moveTo(topRightX, d->c_rect.y()); borderPath.lineTo(topRightX, d->c_rect.y() + CROP_BORDER_LINE); // Bottom-Left Corner borderPath.moveTo(d->c_rect.x(), bottomY); borderPath.lineTo(d->c_rect.x() + CROP_BORDER_LINE, bottomY); borderPath.moveTo(d->c_rect.x(), bottomY - CROP_BORDER_LINE); borderPath.lineTo(d->c_rect.x(), bottomY); // Bottom-Left Corner borderPath.moveTo(topRightX, bottomY); borderPath.lineTo(topRightX - CROP_BORDER_LINE, bottomY); borderPath.moveTo(topRightX, bottomY - CROP_BORDER_LINE); borderPath.lineTo(topRightX, bottomY); // Draw Border Path painter.setPen(QPen(QColor(0xee, 0xee, 0xee), 3)); painter.drawPath(borderPath); }
void Image::drawTiled(GraphicsContext& ctxt, const FloatRect& destRect, const FloatPoint& srcPoint, const FloatSize& scaledTileSize, const FloatSize& spacing, CompositeOperator op, BlendMode blendMode) { if (mayFillWithSolidColor()) { fillWithSolidColor(ctxt, destRect, solidColor(), op); return; } ASSERT(!isBitmapImage() || notSolidColor()); #if PLATFORM(IOS) FloatSize intrinsicTileSize = originalSize(); #else FloatSize intrinsicTileSize = size(); #endif if (hasRelativeWidth()) intrinsicTileSize.setWidth(scaledTileSize.width()); if (hasRelativeHeight()) intrinsicTileSize.setHeight(scaledTileSize.height()); FloatSize scale(scaledTileSize.width() / intrinsicTileSize.width(), scaledTileSize.height() / intrinsicTileSize.height()); FloatRect oneTileRect; FloatSize actualTileSize(scaledTileSize.width() + spacing.width(), scaledTileSize.height() + spacing.height()); oneTileRect.setX(destRect.x() + fmodf(fmodf(-srcPoint.x(), actualTileSize.width()) - actualTileSize.width(), actualTileSize.width())); oneTileRect.setY(destRect.y() + fmodf(fmodf(-srcPoint.y(), actualTileSize.height()) - actualTileSize.height(), actualTileSize.height())); oneTileRect.setSize(scaledTileSize); // Check and see if a single draw of the image can cover the entire area we are supposed to tile. if (oneTileRect.contains(destRect) && !ctxt.drawLuminanceMask()) { FloatRect visibleSrcRect; visibleSrcRect.setX((destRect.x() - oneTileRect.x()) / scale.width()); visibleSrcRect.setY((destRect.y() - oneTileRect.y()) / scale.height()); visibleSrcRect.setWidth(destRect.width() / scale.width()); visibleSrcRect.setHeight(destRect.height() / scale.height()); draw(ctxt, destRect, visibleSrcRect, op, blendMode, ImageOrientationDescription()); return; } #if PLATFORM(IOS) // When using accelerated drawing on iOS, it's faster to stretch an image than to tile it. if (ctxt.isAcceleratedContext()) { if (size().width() == 1 && intersection(oneTileRect, destRect).height() == destRect.height()) { FloatRect visibleSrcRect; visibleSrcRect.setX(0); visibleSrcRect.setY((destRect.y() - oneTileRect.y()) / scale.height()); visibleSrcRect.setWidth(1); visibleSrcRect.setHeight(destRect.height() / scale.height()); draw(ctxt, destRect, visibleSrcRect, op, BlendModeNormal, ImageOrientationDescription()); return; } if (size().height() == 1 && intersection(oneTileRect, destRect).width() == destRect.width()) { FloatRect visibleSrcRect; visibleSrcRect.setX((destRect.x() - oneTileRect.x()) / scale.width()); visibleSrcRect.setY(0); visibleSrcRect.setWidth(destRect.width() / scale.width()); visibleSrcRect.setHeight(1); draw(ctxt, destRect, visibleSrcRect, op, BlendModeNormal, ImageOrientationDescription()); return; } } #endif // Patterned images and gradients can use lots of memory for caching when the // tile size is large (<rdar://problem/4691859>, <rdar://problem/6239505>). // Memory consumption depends on the transformed tile size which can get // larger than the original tile if user zooms in enough. #if PLATFORM(IOS) const float maxPatternTilePixels = 512 * 512; #else const float maxPatternTilePixels = 2048 * 2048; #endif FloatRect transformedTileSize = ctxt.getCTM().mapRect(FloatRect(FloatPoint(), scaledTileSize)); float transformedTileSizePixels = transformedTileSize.width() * transformedTileSize.height(); FloatRect currentTileRect = oneTileRect; if (transformedTileSizePixels > maxPatternTilePixels) { GraphicsContextStateSaver stateSaver(ctxt); ctxt.clip(destRect); currentTileRect.shiftYEdgeTo(destRect.y()); float toY = currentTileRect.y(); while (toY < destRect.maxY()) { currentTileRect.shiftXEdgeTo(destRect.x()); float toX = currentTileRect.x(); while (toX < destRect.maxX()) { FloatRect toRect(toX, toY, currentTileRect.width(), currentTileRect.height()); FloatRect fromRect(toFloatPoint(currentTileRect.location() - oneTileRect.location()), currentTileRect.size()); fromRect.scale(1 / scale.width(), 1 / scale.height()); draw(ctxt, toRect, fromRect, op, BlendModeNormal, ImageOrientationDescription()); toX += currentTileRect.width(); currentTileRect.shiftXEdgeTo(oneTileRect.x()); } toY += currentTileRect.height(); currentTileRect.shiftYEdgeTo(oneTileRect.y()); } return; } AffineTransform patternTransform = AffineTransform().scaleNonUniform(scale.width(), scale.height()); FloatRect tileRect(FloatPoint(), intrinsicTileSize); drawPattern(ctxt, tileRect, patternTransform, oneTileRect.location(), spacing, op, destRect, blendMode); #if PLATFORM(IOS) startAnimation(DoNotCatchUp); #else startAnimation(); #endif }
MenuTalker::MenuTalker(MenuManager *_menu) : Menu() , menu(_menu) , portrait(NULL) , dialog_node(0) , event_cursor(0) , font_who("font_regular") , font_dialog("font_regular") , color_normal(font->getColor("menu_normal")) , npc(NULL) , advanceButton(new WidgetButton("images/menus/buttons/right.png")) , closeButton(new WidgetButton("images/menus/buttons/button_x.png")) { setBackground("images/menus/dialog_box.png"); // Load config settings FileParser infile; // @CLASS MenuTalker|Description of menus/talker.txt if(infile.open("menus/talker.txt")) { while(infile.next()) { if (parseMenuKey(infile.key, infile.val)) continue; // @ATTR close|x (integer), y (integer)|Position of the close button. if(infile.key == "close") { Point pos = toPoint(infile.val); closeButton->setBasePos(pos.x, pos.y); } // @ATTR advance|x (integer), y (integer)|Position of the button to advance dialog. else if(infile.key == "advance") { Point pos = toPoint(infile.val); advanceButton->setBasePos(pos.x, pos.y); } // @ATTR dialogbox|x (integer), y (integer), w (integer), h (integer)|Position and dimensions of the text box graphics. else if (infile.key == "dialogbox") dialog_pos = toRect(infile.val); // @ATTR dialogtext|x (integer), y (integer), w (integer), h (integer)|Rectangle where the dialog text is placed. else if (infile.key == "dialogtext") text_pos = toRect(infile.val); // @ATTR text_offset|x (integer), y (integer)|Margins for the left/right and top/bottom of the dialog text. else if (infile.key == "text_offset") text_offset = toPoint(infile.val); // @ATTR portrait_he|x (integer), y (integer), w (integer), h (integer)|Position and dimensions of the NPC portrait graphics. else if (infile.key == "portrait_he") portrait_he = toRect(infile.val); // @ATTR portrait_you|x (integer), y (integer), w (integer), h (integer)|Position and dimensions of the player's portrait graphics. else if (infile.key == "portrait_you") portrait_you = toRect(infile.val); // @ATTR font_who|string|Font style to use for the name of the currently talking person. else if (infile.key == "font_who") font_who = infile.val; // @ATTR font_dialog|string|Font style to use for the dialog text. else if (infile.key == "font_dialog") font_dialog = infile.val; else infile.error("MenuTalker: '%s' is not a valid key.", infile.key.c_str()); } infile.close(); } label_name = new WidgetLabel(); label_name->setBasePos(text_pos.x + text_offset.x, text_pos.y + text_offset.y); textbox = new WidgetScrollBox(text_pos.w, text_pos.h-(text_offset.y*2)); textbox->setBasePos(text_pos.x, text_pos.y + text_offset.y); tablist.add(advanceButton); tablist.add(closeButton); tablist.add(textbox); align(); }
void QAlphaPaintEnginePrivate::addAlphaRect(const QRectF &rect) { m_alphargn |= toRect(rect); }
bool QAlphaPaintEnginePrivate::fullyContained(const QRectF &rect) const { QRegion r(toRect(rect)); return (m_cliprgn.intersected(r) == r); }
GameStateLoad::GameStateLoad() : GameState() , background(NULL) , selection(NULL) , portrait_border(NULL) , portrait(NULL) , loading_requested(false) , loading(false) , loaded(false) , delete_items(true) , selected_slot(-1) , visible_slots(0) , scroll_offset(0) , has_scroll_bar(false) , game_slot_max(4) , text_trim_boundary(0) { if (items == NULL) items = new ItemManager(); label_loading = new WidgetLabel(); // Confirmation box to confirm deleting confirm = new MenuConfirm(msg->get("Delete Save"), msg->get("Delete this save?")); button_exit = new WidgetButton(); button_exit->label = msg->get("Exit to Title"); button_new = new WidgetButton(); button_new->label = msg->get("New Game"); button_new->enabled = true; button_load = new WidgetButton(); button_load->label = msg->get("Choose a Slot"); button_load->enabled = false; button_delete = new WidgetButton(); button_delete->label = msg->get("Delete Save"); button_delete->enabled = false; scrollbar = new WidgetScrollBar(); // Set up tab list tablist = TabList(HORIZONTAL); tablist.add(button_exit); tablist.add(button_new); // Read positions from config file FileParser infile; // @CLASS GameStateLoad|Description of menus/gameload.txt if (infile.open("menus/gameload.txt")) { while (infile.next()) { // @ATTR button_new|int, int, alignment : X, Y, Alignment|Position of the "New Game" button. if (infile.key == "button_new") { int x = popFirstInt(infile.val); int y = popFirstInt(infile.val); ALIGNMENT a = parse_alignment(popFirstString(infile.val)); button_new->setBasePos(x, y, a); } // @ATTR button_load|int, int, alignment : X, Y, Alignment|Position of the "Load Game" button. else if (infile.key == "button_load") { int x = popFirstInt(infile.val); int y = popFirstInt(infile.val); ALIGNMENT a = parse_alignment(popFirstString(infile.val)); button_load->setBasePos(x, y, a); } // @ATTR button_delete|int, int, alignment : X, Y, Alignment|Position of the "Delete Save" button. else if (infile.key == "button_delete") { int x = popFirstInt(infile.val); int y = popFirstInt(infile.val); ALIGNMENT a = parse_alignment(popFirstString(infile.val)); button_delete->setBasePos(x, y, a); } // @ATTR button_exit|int, int, alignment : X, Y, Alignment|Position of the "Exit to Title" button. else if (infile.key == "button_exit") { int x = popFirstInt(infile.val); int y = popFirstInt(infile.val); ALIGNMENT a = parse_alignment(popFirstString(infile.val)); button_exit->setBasePos(x, y, a); } // @ATTR portrait|rectangle|Position and dimensions of the portrait image. else if (infile.key == "portrait") { portrait_dest = toRect(infile.val); } // @ATTR gameslot|rectangle|Position and dimensions of the first game slot. else if (infile.key == "gameslot") { gameslot_pos = toRect(infile.val); } // @ATTR name|label|The label for the hero's name. Position is relative to game slot position. else if (infile.key == "name") { name_pos = eatLabelInfo(infile.val); } // @ATTR level|label|The label for the hero's level. Position is relative to game slot position. else if (infile.key == "level") { level_pos = eatLabelInfo(infile.val); } // @ATTR class|label|The label for the hero's class. Position is relative to game slot position. else if (infile.key == "class") { class_pos = eatLabelInfo(infile.val); } // @ATTR map|label|The label for the hero's current location. Position is relative to game slot position. else if (infile.key == "map") { map_pos = eatLabelInfo(infile.val); } // @ATTR slot_number|label|The label for the save slot index. Position is relative to game slot position. else if (infile.key == "slot_number") { slot_number_pos = eatLabelInfo(infile.val); } // @ATTR loading_label|label|The label for the "Entering game world..."/"Loading saved game..." text. else if (infile.key == "loading_label") { loading_pos = eatLabelInfo(infile.val); } // @ATTR sprite|point|Position for the avatar preview image in each slot else if (infile.key == "sprite") { sprites_pos = toPoint(infile.val); } // @ATTR visible_slots|int|The maximum numbers of visible save slots. else if (infile.key == "visible_slots") { game_slot_max = toInt(infile.val); // can't have less than 1 game slot visible game_slot_max = std::max(game_slot_max, 1); } // @ATTR text_trim_boundary|int|The position of the right-side boundary where text will be shortened with an ellipsis. Position is relative to game slot position. else if (infile.key == "text_trim_boundary") { text_trim_boundary = toInt(infile.val); } else { infile.error("GameStateLoad: '%s' is not a valid key.", infile.key.c_str()); } } infile.close(); } // prevent text from overflowing on the right edge of game slots if (text_trim_boundary == 0 || text_trim_boundary > gameslot_pos.w) text_trim_boundary = gameslot_pos.w; button_new->refresh(); button_load->refresh(); button_delete->refresh(); loadGraphics(); readGameSlots(); color_normal = font->getColor("menu_normal"); refreshWidgets(); updateButtons(); // if we specified a slot to load at launch, load it now if (!LOAD_SLOT.empty()) { size_t load_slot_id = toInt(LOAD_SLOT) - 1; LOAD_SLOT.clear(); if (load_slot_id < game_slots.size()) { setSelectedSlot(static_cast<int>(load_slot_id)); loading_requested = true; } } render_device->setBackgroundColor(Color(0,0,0,0)); }
void Vector::visualize(SDL_Surface *dst) { SDL_Rect r = toRect(); SDL_FillRect(dst, &r, SDL_MapRGB(dst->format, 0xFF, 0x00, 0x00)); }