void BScrollView::SetTarget(BView *target) { if (fTarget == target) return; if (fTarget != NULL) { fTarget->TargetedByScrollView(NULL); RemoveChild(fTarget); // we are not supposed to delete the view } fTarget = target; if (fHorizontalScrollBar != NULL) fHorizontalScrollBar->SetTarget(target); if (fVerticalScrollBar != NULL) fVerticalScrollBar->SetTarget(target); if (target != NULL) { target->MoveTo(BorderSize(fBorder), BorderSize(fBorder)); target->TargetedByScrollView(this); AddChild(target, ChildAt(0)); // This way, we are making sure that the target will // be added top most in the list (which is important // for unarchiving) } }
void BScrollView::AttachedToWindow() { BView::AttachedToWindow(); if ((fHorizontalScrollBar == NULL && fVerticalScrollBar == NULL) || (fHorizontalScrollBar != NULL && fVerticalScrollBar != NULL)) return; // If we have only one bar, we need to check if we are in the // bottom right edge of a window with the B_DOCUMENT_LOOK to // adjust the size of the bar to acknowledge the resize knob. BRect bounds = ConvertToScreen(Bounds()); BRect windowBounds = Window()->Frame(); if (bounds.right - BorderSize(fBorder) != windowBounds.right || bounds.bottom - BorderSize(fBorder) != windowBounds.bottom) return; if (fHorizontalScrollBar) fHorizontalScrollBar->ResizeBy(-B_V_SCROLL_BAR_WIDTH, 0); else if (fVerticalScrollBar) fVerticalScrollBar->ResizeBy(0, -B_H_SCROLL_BAR_HEIGHT); }
void BScrollView::SetBorder(border_style border) { if (fBorder == border) return; float offset = BorderSize(fBorder) - BorderSize(border); float resize = 2 * offset; float horizontalGap = 0, verticalGap = 0; float change = 0; if (border == B_NO_BORDER || fBorder == B_NO_BORDER) { if (fHorizontalScrollBar != NULL) verticalGap = border != B_NO_BORDER ? 1 : -1; if (fVerticalScrollBar != NULL) horizontalGap = border != B_NO_BORDER ? 1 : -1; change = border != B_NO_BORDER ? -1 : 1; if (fHorizontalScrollBar == NULL || fVerticalScrollBar == NULL) change *= 2; } fBorder = border; int32 savedResizingMode = 0; if (fTarget != NULL) { savedResizingMode = fTarget->ResizingMode(); fTarget->SetResizingMode(B_FOLLOW_NONE); } MoveBy(offset, offset); ResizeBy(-resize - horizontalGap, -resize - verticalGap); if (fTarget != NULL) { fTarget->MoveBy(-offset, -offset); fTarget->SetResizingMode(savedResizingMode); } if (fHorizontalScrollBar != NULL) { fHorizontalScrollBar->MoveBy(-offset - verticalGap, offset + verticalGap); fHorizontalScrollBar->ResizeBy(resize + horizontalGap - change, 0); } if (fVerticalScrollBar != NULL) { fVerticalScrollBar->MoveBy(offset + horizontalGap, -offset - horizontalGap); fVerticalScrollBar->ResizeBy(0, resize + verticalGap - change); } SetFlags(ModifyFlags(Flags(), border)); }
void SplitPanel::dividerDragMouseDragged(MouseEventDetails* const e) { UInt32 AxisIndex(0); if(getOrientation() != SplitPanel::HORIZONTAL_ORIENTATION ) AxisIndex = 1; if(e->getButton() == MouseEventDetails::BUTTON1) { Pnt2f temp = ViewportToComponent(e->getLocation(), this, e->getViewport()); if (getDividerPosition() <= 1.0) { if (temp[AxisIndex] >= 0) // this ensures it stays as a percentage position { Pnt2f TopLeft, BottomRight; getInsideBorderBounds(TopLeft, BottomRight); Vec2f BorderSize(BottomRight - TopLeft); setDividerPosition((Real32)temp[AxisIndex]/(Real32)BorderSize[AxisIndex]); } } else { if (temp[AxisIndex] > 1) // this ensures it stays absolute position { setDividerPosition(temp[AxisIndex]); } } //updateLayout(); } }
BScrollView::BScrollView(const char *name, BView *target, uint32 resizingMode, uint32 flags, bool horizontal, bool vertical, border_style border) : BView(CalcFrame(target, horizontal, vertical, border), name, ModifyFlags(flags, border), resizingMode), fTarget(target), fHorizontalScrollBar(NULL), fVerticalScrollBar(NULL), fBorder(border), fHighlighted(false) { fTarget->TargetedByScrollView(this); fTarget->MoveTo(B_ORIGIN); if (border != B_NO_BORDER) fTarget->MoveBy(BorderSize(border), BorderSize(border)); AddChild(fTarget); BRect frame = fTarget->Frame(); if (horizontal) { BRect rect = frame; rect.top = rect.bottom + 1; rect.bottom += B_H_SCROLL_BAR_HEIGHT + 1; if (border != B_NO_BORDER || vertical) rect.right++; if (border != B_NO_BORDER) rect.left--; fHorizontalScrollBar = new BScrollBar(rect, "_HSB_", fTarget, 0, 1000, B_HORIZONTAL); AddChild(fHorizontalScrollBar); } if (vertical) { BRect rect = frame; rect.left = rect.right + 1; rect.right += B_V_SCROLL_BAR_WIDTH + 1; if (border != B_NO_BORDER || horizontal) rect.bottom++; if (border != B_NO_BORDER) rect.top--; fVerticalScrollBar = new BScrollBar(rect, "_VSB_", fTarget, 0, 1000, B_VERTICAL); AddChild(fVerticalScrollBar); } fPreviousWidth = uint16(Bounds().Width()); fPreviousHeight = uint16(Bounds().Height()); }
void BScrollView::FrameResized(float width, float height) { BView::FrameResized(width, height); if (fBorder == B_NO_BORDER) return; // changes in width BRect bounds = Bounds(); float border = BorderSize(fBorder) - 1; if (bounds.Width() > fPreviousWidth) { // invalidate the region between the old and the new right border BRect rect = bounds; rect.left += fPreviousWidth - border; rect.right--; Invalidate(rect); } else if (bounds.Width() < fPreviousWidth) { // invalidate the region of the new right border BRect rect = bounds; rect.left = rect.right - border; Invalidate(rect); } // changes in height if (bounds.Height() > fPreviousHeight) { // invalidate the region between the old and the new bottom border BRect rect = bounds; rect.top += fPreviousHeight - border; rect.bottom--; Invalidate(rect); } else if (bounds.Height() < fPreviousHeight) { // invalidate the region of the new bottom border BRect rect = bounds; rect.top = rect.bottom - border; Invalidate(rect); } fPreviousWidth = uint16(bounds.Width()); fPreviousHeight = uint16(bounds.Height()); }
void CSettingsGroup::GetPreferredSize(float *width, float *height) { float h=0, rowh=0, w=0; for(int32 i=0 ; i<CountChildren() ; i++) { float childWidth, childHeight; ChildAt(i)->GetPreferredSize(&childWidth, &childHeight); w = MAX(w, childWidth); rowh = MAX(rowh, childHeight); if((i%numColumns) == 0) h += rowh+dist; } if(width) *width = numColumns*(w+dist)+dist; if(height) *height = h+dist+LabelHeight()+BorderSize(); }
BRect BScrollView::CalcFrame(BView *target, bool horizontal, bool vertical, border_style border) { BRect frame = target != NULL ? frame = target->Frame() : BRect(0, 0, 80, 80); if (vertical) frame.right += B_V_SCROLL_BAR_WIDTH; if (horizontal) frame.bottom += B_H_SCROLL_BAR_HEIGHT; float borderSize = BorderSize(border); frame.InsetBy(-borderSize, -borderSize); if (borderSize == 0) { if (vertical) frame.right++; if (horizontal) frame.bottom++; } return frame; }
bool CDocCommands::DoCommand(LPCTSTR rstrCommand, LPCTSTR strValue) { CString strCommand = rstrCommand; strCommand.MakeUpper(); CString strSubCommand = strValue; strSubCommand.MakeUpper(); int iValue = _ttoi(strValue); if (!m_DocWindow.m_hWnd) return (strCommand == "CLOSE" ? true : false); bool bOK = false; // Commands from the main dialog if (strCommand == "STARTOVER") bOK = StartOver(); else if (strCommand == "ZOOMIN") bOK = ZoomIn(); else if (strCommand == "ZOOMOUT") bOK = ZoomOut(); else if (strCommand == "ZOOMFULL") bOK = ZoomFull(); // Commands from the File Operations tab else if (strCommand == "FILETAB") bOK = FileTab(strSubCommand); // Commands from the Crop tab else if (strCommand == "CROPTAB") bOK = CropTab(iValue); // Commands from the Resize tab else if (strCommand == "RESIZETAB") bOK = ResizeTab(iValue, NULL); else if (strCommand == "RESIZEAPPLY") bOK = ResizeTab(EDIT_APPLY, strValue); // Commands from the Flip & Rotate tab else if (strCommand == "FLIPROTATETAB") bOK = FlipRotateTab(iValue); else if (strCommand == "FLIPROTATETABSUBCOMMAND") bOK = FlipRotateTabSubCommand(strSubCommand); // Commands from the Recolor Area Fill tab else if (strCommand == "RECOLORTAB") bOK = RecolorTab(iValue); else if (strCommand == "RECOLORTABSUBCOMMAND") bOK = RecolorTabSubCommand(strSubCommand); else if (strCommand == "SETPRIMARYCOLOR") m_DocWindow.m_ToolSettings.m_PrimaryColor = iValue; else if (strCommand == "SETSECONDARYCOLOR") m_DocWindow.m_ToolSettings.m_SecondaryColor = iValue; else if (strCommand == "TOLERANCE") m_DocWindow.m_ToolSettings.m_nTolerance = iValue; // Commands from the Special Effects tab else if (strCommand == "EFFECTSTAB") bOK = EffectsTab(iValue); else if (strCommand == "EFFECTSTABSUBCOMMAND") bOK = EffectsTabSubCommand(strSubCommand); // Commands from the Contrast & Brightness tab else if (strCommand == "CONTRASTBRIGHTNESSTAB") bOK = ContrastBrightnessTab(iValue); else if (strCommand == "AUTOCORRECT") bOK = AutoCorrect(); // Commands from the Hue & Saturation tab else if (strCommand == "COLORSTAB") bOK = ColorsTab(iValue); else if (strCommand == "MAKEGRAY") bOK = MakeGray(); else if (strCommand == "INVERT") return Invert(); // Commands from the Red Eye Removal tab else if (strCommand == "REDEYETAB") bOK = RedEyeTab(iValue); // Commands from the Frames & Borders tab else if (strCommand == "BORDERSTAB") bOK = BordersTab(iValue); else if (strCommand == "BORDERIMAGE") bOK = BorderImageMerge(strValue); else if (strCommand == "BORDERTYPE") bOK = BorderType(strValue); else if (strCommand == "BORDERSIZE") bOK = BorderSize(iValue); else if (strCommand == "BORDERSOFTNESS") bOK = SetBorderSoftness(iValue); else if (strCommand == "BORDERSTRETCH") bOK = SetBorderStretch(!!iValue); else CMessageBox::Message(String("'%s' is not implemented.", strCommand)); return bOK; }
void SplitPanel::updateLayout(void) { Pnt2f TopLeft, BottomRight; getInsideBorderBounds(TopLeft, BottomRight); Vec2f BorderSize(BottomRight - TopLeft); UInt32 AxisIndex(0); if(getOrientation() != SplitPanel::HORIZONTAL_ORIENTATION ) AxisIndex = 1; Vec2f minSize(0,0); Vec2f maxSize(0,0); Vec2f divSize(0,0); Pnt2f minPos(0,0); Pnt2f maxPos(0,0); Pnt2f divPos(0,0); if (getDividerPosition() < 0.0) setDividerPosition(0.5); if (getMinDividerPosition() < 0.0) setMinDividerPosition(0.0); if (getMaxDividerPosition() < 0.0) setMaxDividerPosition(1.0); UInt32 dividerPosition(getDividerPosition()); if (getDividerPosition() <= 1.0) dividerPosition = BorderSize[AxisIndex] * getDividerPosition(); // check the divider's min and max if (getMinDividerPosition() <= 1.0) { if (dividerPosition < getMinDividerPosition() * BorderSize[AxisIndex]) dividerPosition = getMinDividerPosition() * BorderSize[AxisIndex]; } else { if (dividerPosition < getMinDividerPosition()) dividerPosition = getMinDividerPosition(); } if (getMaxDividerPosition() <= 1.0) { if (dividerPosition > getMaxDividerPosition() * BorderSize[AxisIndex]) dividerPosition = getMaxDividerPosition() * BorderSize[AxisIndex]; } else { if (dividerPosition > getMaxDividerPosition()) dividerPosition = getMaxDividerPosition(); } // set the minimum component's size minSize[AxisIndex] = dividerPosition - getDividerSize()/2; // check its min and max if (getMinComponent() != NULL) { if (minSize[AxisIndex] < getMinComponent()->getMinSize()[AxisIndex]) { dividerPosition -= getMinComponent()->getMinSize()[AxisIndex] - minSize[AxisIndex]; minSize[AxisIndex] = getMinComponent()->getMinSize()[AxisIndex]; } if (minSize[AxisIndex] > getMinComponent()->getMaxSize()[AxisIndex]) { dividerPosition += minSize[AxisIndex] - getMinComponent()->getMaxSize()[AxisIndex]; minSize[AxisIndex] = getMinComponent()->getMaxSize()[AxisIndex]; } } // set the maximum component's size maxSize[AxisIndex] = BorderSize[AxisIndex] - minSize[AxisIndex] - getDividerSize(); // check its min and max if (getMaxComponent() != NULL) { if (maxSize[AxisIndex] < getMaxComponent()->getMinSize()[AxisIndex]) { dividerPosition -= getMaxComponent()->getMinSize()[AxisIndex] - maxSize[AxisIndex]; minSize[AxisIndex] -= getMaxComponent()->getMinSize()[AxisIndex] - maxSize[AxisIndex]; maxSize[AxisIndex] = getMaxComponent()->getMinSize()[AxisIndex]; } if (maxSize[AxisIndex] > getMaxComponent()->getMaxSize()[AxisIndex]) { dividerPosition += maxSize[AxisIndex] - getMaxComponent()->getMaxSize()[AxisIndex]; minSize[AxisIndex] += maxSize[AxisIndex] - getMaxComponent()->getMaxSize()[AxisIndex]; maxSize[AxisIndex] = getMaxComponent()->getMaxSize()[AxisIndex]; } } // set the minor axis' size and max's position minSize[(AxisIndex+1)%2] = maxSize[(AxisIndex+1)%2] = BorderSize[(AxisIndex+1)%2]; maxPos[AxisIndex] = minSize[AxisIndex] + getDividerSize(); // set the divider's size and position divSize[AxisIndex] = getDividerSize(); divSize[(AxisIndex+1)%2] = BorderSize[(AxisIndex+1)%2]; divPos[AxisIndex] = dividerPosition - getDividerSize()/2; // set the components to the right size and positions if (getMinComponent() != NULL) { if(getMinComponent()->getSize() != minSize) { getMinComponent()->setSize(minSize); } if(getMinComponent()->getPosition() != minPos) { getMinComponent()->setPosition(minPos); } } if (getMaxComponent() != NULL) { if(getMaxComponent()->getSize() != maxSize) { getMaxComponent()->setSize(maxSize); } if(getMaxComponent()->getPosition() != maxPos) { getMaxComponent()->setPosition(maxPos); } } if (getDividerDrawObject() != NULL) { if(getDividerDrawObject()->getSize() != divSize) { getDividerDrawObject()->setSize(divSize); } if(getDividerDrawObject()->getPosition() != divPos) { getDividerDrawObject()->setPosition(divPos); } } }
SimpleTensor<T> non_linear_filter(const SimpleTensor<T> &src, NonLinearFilterFunction function, unsigned int mask_size, MatrixPattern pattern, const uint8_t *mask, BorderMode border_mode, uint8_t constant_border_value) { SimpleTensor<T> dst(src.shape(), src.data_type()); ARM_COMPUTE_ERROR_ON(pattern == MatrixPattern::OTHER && mask == nullptr); ARM_COMPUTE_UNUSED(pattern); using intermediate_type = typename common_promoted_signed_type<T>::intermediate_type; const int sq_mask_size = mask_size * mask_size; const int half_mask_size = mask_size / 2; std::vector<intermediate_type> vals(sq_mask_size); intermediate_type current_value = 0; const ValidRegion valid_region = shape_to_valid_region(src.shape(), border_mode == BorderMode::UNDEFINED, BorderSize(half_mask_size)); for(int element_idx = 0, count = 0, index = 0; element_idx < src.num_elements(); ++element_idx, count = 0, index = 0) { Coordinates id = index2coord(src.shape(), element_idx); if(is_in_valid_region(valid_region, id)) { int idx = id.x(); int idy = id.y(); for(int y = idy - half_mask_size; y <= idy + half_mask_size; ++y) { for(int x = idx - half_mask_size; x <= idx + half_mask_size; ++x, ++index) { id.set(0, x); id.set(1, y); current_value = tensor_elem_at(src, id, border_mode, constant_border_value); if(mask[index] == 255) { vals[count] = static_cast<intermediate_type>(current_value); ++count; } } } std::sort(vals.begin(), vals.begin() + count); ARM_COMPUTE_ERROR_ON(count == 0); switch(function) { case NonLinearFilterFunction::MIN: dst[element_idx] = saturate_cast<T>(vals[0]); break; case NonLinearFilterFunction::MAX: dst[element_idx] = saturate_cast<T>(vals[count - 1]); break; case NonLinearFilterFunction::MEDIAN: dst[element_idx] = saturate_cast<T>(vals[count / 2]); break; default: ARM_COMPUTE_ERROR("Unsupported NonLinearFilter function."); } } } return dst; }
const BorderSize getFrameSize() const { return BorderSize (0); }
const BorderSize DocumentWindow::getBorderThickness() { return BorderSize ((isFullScreen() || isUsingNativeTitleBar()) ? 0 : (resizableBorder != 0 ? 4 : 1)); }
const PaddingSize src_padding = calculator.required_padding(); validate(src.info()->padding(), src_padding); validate(dst.info()->padding(), dst_padding); } template <typename T> using CLConvolutionFixture = ConvolutionSquareValidationFixture<CLTensor, CLAccessor, CLConvolution5x5, T>; FIXTURE_DATA_TEST_CASE(RunSmall, CLConvolutionFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::U8)), datasets::BorderModes()), framework::dataset::make("filter_size", { 5 }))) { // Validate output validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2))); } FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::U8)), datasets::BorderModes()), framework::dataset::make("filter_size", { 5 }))) { // Validate output validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2))); } TEST_SUITE_END() /* Custom Convolution 5x5 */ TEST_SUITE(CustomConvolution7x7) DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)), datasets::BorderModes()),