Ticket #12996: v2-0008-Adjust-GuideGrid-widget-for-the-parent-offsets.patch
File v2-0008-Adjust-GuideGrid-widget-for-the-parent-offsets.patch, 13.8 KB (added by , 4 years ago) |
---|
-
mythtv/libs/libmythui/mythuiguidegrid.cpp
Adjust GuideGrid widget for the parent offsets. This patches the UI GuideGrid widget to translate drawing positions from coordinates that are local to the parent object into global coordinates. The parents xoffset/yoffset values were already being passed into this widget. These offsets just needed to be passed down to the actual drawing functions, and those functions needed to perform the additional translation. The lack of these translations has not been noticed because all GuideGrids are currently embedded in top level windows, so that the parent offsets are always 0/0. --- mythtv/libs/libmythui/mythuiguidegrid.cpp | 153 ++++++++++++++++++++++++++---- mythtv/libs/libmythui/mythuiguidegrid.h | 15 ++- 2 files changed, 146 insertions(+), 22 deletions(-) diff --git a/mythtv/libs/libmythui/mythuiguidegrid.cpp b/mythtv/libs/libmythui/mythuiguidegrid.cpp index 593b5e5..06026e3 100644
a b QColor MythUIGuideGrid::calcColor(const QColor &color, int alphaMod) 294 294 return newColor; 295 295 } 296 296 297 /** \fn MythUIGuideGrid::DrawSelf(MythPainter *, int, int, int, QRect) 298 * \brief Draws an entire GuideGrid. 299 * 300 * Draw the complete contents of a GuideGrid. This function iterates 301 * over all the rows and columns in a guide grid, and calls the 302 * appropriate functions to draw the grid items. This is accomplished 303 * in three stages. First all the item backgrounds are drawn in 304 * appropriate colors for their genre and recoding state, then the 305 * background/decorations for the selected item are drawn, and 306 * finally all the item texts and recording decorators are drawn on 307 * top. 308 * 309 * @note This function does not translate local->global offsets. All 310 * of the drawing functions it calls must perform this translation. 311 * 312 * \param p A pointer to the MythPainter structure that 313 * will be used to render this object onto the screen. 314 * \param xoffset The X offset of the parent. Used to convert local 315 * coordinates to global coordinates. 316 * \param yoffset The Y offset of the parent. Used to convert local 317 * coordinates to global coordinates. 318 * \param alphaMod The alpha (transparency) value for this widget. 319 * \param clipRect Ignored. 320 */ 297 321 void MythUIGuideGrid::DrawSelf(MythPainter *p, int xoffset, int yoffset, 298 322 int alphaMod, QRect clipRect) 299 323 { … … void MythUIGuideGrid::DrawSelf(MythPainter *p, int xoffset, int yoffset, 306 330 UIGTCon *data = *it; 307 331 308 332 if (data->m_recStat == 0) 309 drawBackground(p, data, alphaMod);333 drawBackground(p, xoffset, yoffset, data, alphaMod); 310 334 else if (data->m_recStat == 1) 311 drawBox(p, data, m_recordingColor, alphaMod);335 drawBox(p, xoffset, yoffset, data, m_recordingColor, alphaMod); 312 336 else 313 drawBox(p, data, m_conflictingColor, alphaMod);337 drawBox(p, xoffset, yoffset, data, m_conflictingColor, alphaMod); 314 338 } 315 339 } 316 340 317 drawCurrent(p, &m_selectedItem, alphaMod);341 drawCurrent(p, xoffset, yoffset, &m_selectedItem, alphaMod); 318 342 319 343 for (int i = 0; i < m_rowCount; i++) 320 344 { … … void MythUIGuideGrid::DrawSelf(MythPainter *p, int xoffset, int yoffset, 323 347 for (; it != m_allData[i].end(); ++it) 324 348 { 325 349 UIGTCon *data = *it; 326 drawText(p, data, alphaMod);350 drawText(p, xoffset, yoffset, data, alphaMod); 327 351 328 352 if (data->m_recType != 0 || data->m_arrow != 0) 329 drawRec Type(p, data, alphaMod);353 drawRecDecoration(p, xoffset, yoffset, data, alphaMod); 330 354 } 331 355 } 332 356 } 333 357 334 void MythUIGuideGrid::drawCurrent(MythPainter *p, UIGTCon *data, int alphaMod) 358 /** \fn MythUIGuideGrid::drawCurrent(MythPainter *, int, int, UIGTCon *, int) 359 * \brief Draws selection indication for a GuideGrid item. 360 * 361 * This function is responsible for drawing decoration items that are 362 * unique to the currently selected entry. This may be a highlight 363 * rectangle around the entry, or special colors to indicate the 364 * currently selected entry. The type of decoration drawn depends 365 * upon the setting on the local m_SelType variable. 366 * 367 * \param p A pointer to the MythPainter structure that 368 * will be used to render this object onto the screen. 369 * \param xoffset The X offset of the parent. Used to convert local 370 * coordinates to global coordinates. 371 * \param yoffset The Y offset of the parent. Used to convert local 372 * coordinates to global coordinates. 373 * \param data A pointer to the GuideGrid object to be drawn. 374 * \param alphaMod The alpha (transparency) value for this widget. 375 */ 376 void MythUIGuideGrid::drawCurrent(MythPainter *p, int xoffset, int yoffset, UIGTCon *data, int alphaMod) 335 377 { 336 378 int breakin = 2; 337 379 QRect area = data->m_drawArea; 338 area.translate(m_Area.x(), m_Area.y()); 380 area.translate(m_Area.x(), m_Area.y()); // Adjust within parent 381 area.translate(xoffset, yoffset); // Convert to global coordinates 339 382 area.adjust(breakin, breakin, -breakin, -breakin); 340 383 int status = data->m_recStat; 341 384 … … void MythUIGuideGrid::drawCurrent(MythPainter *p, UIGTCon *data, int alphaMod) 382 425 } 383 426 } 384 427 385 void MythUIGuideGrid::drawRecType(MythPainter *p, UIGTCon *data, int alphaMod) 428 /** \fn MythUIGuideGrid::drawRecDecoration(MythPainter *, int, int, UIGTCon *, int) 429 * \brief Draws decoration items for a GuideGrid item. 430 * 431 * This function is responsible for drawing the decoration items onto 432 * an entry in the GuideGrid. It draws left/right (or up/down) arrows 433 * if the program time extends before or after what's visible in the 434 * window. If a show is scheduled to record, it also draws the badges 435 * that indicates the type of recording. 436 * 437 * \param p A pointer to the MythPainter structure that 438 * will be used to render this object onto the screen. 439 * \param xoffset The X offset of the parent. Used to convert local 440 * coordinates to global coordinates. 441 * \param yoffset The Y offset of the parent. Used to convert local 442 * coordinates to global coordinates. 443 * \param data A pointer to the GuideGrid object to be drawn. 444 * \param alphaMod The alpha (transparency) value for this widget. 445 */ 446 void MythUIGuideGrid::drawRecDecoration(MythPainter *p, int xoffset, int yoffset, UIGTCon *data, int alphaMod) 386 447 { 387 448 int breakin = 1; 388 449 QRect area = data->m_drawArea; 389 area.translate(m_Area.x(), m_Area.y()); 450 area.translate(m_Area.x(), m_Area.y()); // Adjust within parent 451 area.translate(xoffset, yoffset); // Convert to global coordinates 390 452 area.adjust(breakin, breakin, -breakin, -breakin); 391 453 392 454 // draw arrows … … void MythUIGuideGrid::drawRecType(MythPainter *p, UIGTCon *data, int alphaMod) 435 497 } 436 498 } 437 499 438 void MythUIGuideGrid::drawBox(MythPainter *p, UIGTCon *data, const QColor &color, int alphaMod) 500 /** \fn MythUIGuideGrid::drawBox(MythPainter *, int, int, UIGTCon *, int) 501 * \brief Draws the background for a GuideGrid item to be recorded. 502 * 503 * This function is responsible for drawing the background behind all 504 * GuideGrid entries that are marked as being part of a recording 505 * rule. It draws a simple filled in box with no past/future 506 * demarcation. 507 * 508 * \param p A pointer to the MythPainter structure that 509 * will be used to render this object onto the screen. 510 * \param xoffset The X offset of the parent. Used to convert local 511 * coordinates to global coordinates. 512 * \param yoffset The Y offset of the parent. Used to convert local 513 * coordinates to global coordinates. 514 * \param data A pointer to the GuideGrid object to be drawn. 515 * \param alphaMod The alpha (transparency) value for this widget. 516 */ 517 void MythUIGuideGrid::drawBox(MythPainter *p, int xoffset, int yoffset, UIGTCon *data, const QColor &color, int alphaMod) 439 518 { 440 519 int breakin = 1; 441 520 QRect area = data->m_drawArea; 442 area.translate(m_Area.x(), m_Area.y()); 521 area.translate(m_Area.x(), m_Area.y()); // Adjust within parent 522 area.translate(xoffset, yoffset); // Convert to global coordinates 443 523 area.adjust(breakin, breakin, -breakin, -breakin); 444 524 445 525 static const QPen nopen(Qt::NoPen); 446 526 p->DrawRect(area, QBrush(calcColor(color, m_categoryAlpha)), nopen, alphaMod); 447 527 } 448 528 449 void MythUIGuideGrid::drawBackground(MythPainter *p, UIGTCon *data, int alphaMod) 529 /** \fn MythUIGuideGrid::drawBackground(MythPainter *, int, int, UIGTCon *, int) 530 * \brief Draws the background for a GuideGrid item that will not be recorded. 531 * 532 * This function is responsible for drawing the background behind all 533 * GuideGrid entries that are not marked as being part of a recording 534 * rule. It is responsible for drawing the demarcation line in the 535 * grid between past and future times. It also chooses the background 536 * color appropriate to the genre of the show. 537 * 538 * \param p A pointer to the MythPainter structure that 539 * will be used to render this object onto the screen. 540 * \param xoffset The X offset of the parent. Used to convert local 541 * coordinates to global coordinates. 542 * \param yoffset The Y offset of the parent. Used to convert local 543 * coordinates to global coordinates. 544 * \param data A pointer to the GuideGrid object to be drawn. 545 * \param alphaMod The alpha (transparency) value for this widget. 546 */ 547 void MythUIGuideGrid::drawBackground(MythPainter *p, int xoffset, int yoffset, UIGTCon *data, int alphaMod) 450 548 { 451 549 QColor overColor; 452 550 QRect overArea; 453 551 454 552 int breakin = 1; 455 553 QRect area = data->m_drawArea; 456 area.translate(m_Area.x(), m_Area.y()); 554 area.translate(m_Area.x(), m_Area.y()); // Adjust within parent 457 555 QColor fillColor; 458 556 459 557 if (m_drawCategoryColors && data->m_categoryColor.isValid()) … … void MythUIGuideGrid::drawBackground(MythPainter *p, UIGTCon *data, int alphaMod 461 559 else 462 560 fillColor = calcColor(m_solidColor, m_categoryAlpha); 463 561 562 // These calculations are in the parents local coordinates 464 563 if (m_verticalLayout) 465 564 { 466 565 if (m_progPastCol && area.top() < m_progPastCol) … … void MythUIGuideGrid::drawBackground(MythPainter *p, UIGTCon *data, int alphaMod 521 620 area.setHeight(2); 522 621 523 622 static const QPen nopen(Qt::NoPen); 623 area.translate(xoffset, yoffset); // Convert to global coordinates 524 624 p->DrawRect(area, QBrush(fillColor), nopen, alphaMod); 525 625 526 if (overArea.width() > 0) 626 if (overArea.width() > 0) { 627 overArea.translate(xoffset, yoffset); // Convert to global coordinates 527 628 p->DrawRect(overArea, QBrush(overColor), nopen, alphaMod); 629 } 528 630 } 529 631 530 void MythUIGuideGrid::drawText(MythPainter *p, UIGTCon *data, int alphaMod) 632 /** \fn MythUIGuideGrid::drawText(MythPainter *, int, int, UIGTCon *, int) 633 * \brief Draws text strings for a GuideGrid item. 634 * 635 * This function is responsible for drawing the text onto an entry in 636 * the GuideGrid. It is smart enough to leave space for the guide 637 * item continuation arrow to be drawn. 638 * 639 * \param p A pointer to the MythPainter structure that 640 * will be used to render this object onto the screen. 641 * \param xoffset The X offset of the parent. Used to convert local 642 * coordinates to global coordinates. 643 * \param yoffset The Y offset of the parent. Used to convert local 644 * coordinates to global coordinates. 645 * \param data A pointer to the GuideGrid object to be drawn. 646 * \param alphaMod The alpha (transparency) value for this widget. 647 */ 648 void MythUIGuideGrid::drawText(MythPainter *p, int xoffset, int yoffset, UIGTCon *data, int alphaMod) 531 649 { 532 650 QString msg = data->m_title; 533 651 … … void MythUIGuideGrid::drawText(MythPainter *p, UIGTCon *data, int alphaMod) 535 653 msg += QString(" (%1)").arg(data->m_category); 536 654 537 655 QRect area = data->m_drawArea; 538 area.translate(m_Area.x(), m_Area.y()); 656 area.translate(m_Area.x(), m_Area.y()); // Adjust within parent 657 area.translate(xoffset, yoffset); // Convert to global coordinates 539 658 area.adjust(m_textOffset.x(), m_textOffset.y(), 540 659 -m_textOffset.x(), -m_textOffset.y()); 541 660 -
mythtv/libs/libmythui/mythuiguidegrid.h
diff --git a/mythtv/libs/libmythui/mythuiguidegrid.h b/mythtv/libs/libmythui/mythuiguidegrid.h index 8b50877..7e1d0b8 100644
a b class MUI_PUBLIC MythUIGuideGrid : public MythUIType 93 93 int m_recStat; 94 94 }; 95 95 96 void drawBackground(MythPainter *p, UIGTCon *data, int alpaMod); 97 void drawBox(MythPainter *p, UIGTCon *data, const QColor &color, int alpaMod); 98 void drawText(MythPainter *p, UIGTCon *data, int alpaMod); 99 void drawRecType(MythPainter *p, UIGTCon *data, int alpaMod); 100 void drawCurrent(MythPainter *p, UIGTCon *data, int alpaMod); 96 void drawBackground(MythPainter *p, int xoffset, int yoffset, 97 UIGTCon *data, int alpaMod); 98 void drawBox(MythPainter *p, int xoffset, int yoffset, UIGTCon *data, 99 const QColor &color, int alpaMod); 100 void drawText(MythPainter *p, int xoffset, int yoffset, UIGTCon *data, 101 int alpaMod); 102 void drawRecDecoration(MythPainter *p, int xoffset, int yoffset, 103 UIGTCon *data, int alpaMod); 104 void drawCurrent(MythPainter *p, int xoffset, int yoffset, UIGTCon *data, 105 int alpaMod); 101 106 102 107 QColor calcColor(const QColor &color, int alpha); 103 108