Beispiel #1
0
	void menu_item_widget::paint_non_client(graphics_context& aGraphicsContext) const
	{
		if (iMenu.has_selected_item() && iMenu.selected_item() == (iMenu.find_item(iMenuItem)))
		{
			bool openSubMenu = (iMenuItem.type() == i_menu_item::SubMenu && iMenuItem.sub_menu().is_open());
			colour background;
			if (openSubMenu && iMenu.type() == i_menu::MenuBar)
			{
				background = app::instance().current_style().colour().dark() ?
					app::instance().current_style().colour().darker(0x40) :
					app::instance().current_style().colour().lighter(0x40);
				if (background.similar_intensity(app::instance().current_style().colour(), 0.05))
				{
					background = app::instance().current_style().selection_colour();
					background.set_alpha(0x80);
				}
			}
			else
			{
				background = background_colour().light() ? background_colour().darker(0x40) : background_colour().lighter(0x40);
				background.set_alpha(0x80);
			}
			aGraphicsContext.fill_rect(client_rect(), background);
		}
	}
Beispiel #2
0
	void toolbar_button::paint(graphics_context& aGraphicsContext) const
	{
		if (!iAction.is_separator())
			push_button::paint(aGraphicsContext);
		else
		{
			scoped_units su(*this, aGraphicsContext, UnitsPixels);
			rect line = client_rect();
			line.deflate(0, std::floor(client_rect().height() / 6.0));
			line.cx = 1.0;
			colour ink = (has_foreground_colour() ? foreground_colour() : app::instance().current_style().foreground_colour());
			aGraphicsContext.fill_rect(line, ink.darker(0x40));
			++line.x;
			aGraphicsContext.fill_rect(line, ink.lighter(0x40));
		}
	}
	void colour_picker_dialog::colour_selection::paint(graphics_context& aGraphicsContext) const
	{
		framed_widget::paint(aGraphicsContext);
		rect cr = client_rect(false);
		aGraphicsContext.fill_rect(cr, iParent.selected_colour());
		cr.y = cr.cy / 2.0;
		aGraphicsContext.fill_rect(cr, iParent.current_colour());
	}
Beispiel #4
0
	void menu_item_widget::paint(graphics_context& aGraphicsContext) const
	{
		if (iMenuItem.type() != i_menu_item::Action || !iMenuItem.action().is_separator())
		{
			widget::paint(aGraphicsContext);
			if (iMenuItem.type() == i_menu_item::SubMenu && iMenu.type() == i_menu::Popup)
			{
				bool openSubMenu = (iMenuItem.type() == i_menu_item::SubMenu && iMenuItem.sub_menu().is_open());
				colour ink = openSubMenu ? app::instance().current_style().selection_colour()
					: background_colour().light() ? background_colour().darker(0x80) : background_colour().lighter(0x80);
				if (iSubMenuArrow == boost::none || iSubMenuArrow->first != ink)
				{
					const uint8_t sArrowImagePattern[9][6]
					{
						{ 0, 0, 0, 0, 0, 0 },
						{ 0, 1, 0, 0, 0, 0 },
						{ 0, 1, 1, 0, 0, 0 },
						{ 0, 1, 1, 1, 0, 0 },
						{ 0, 1, 1, 1, 1, 0 },
						{ 0, 1, 1, 1, 0, 0 },
						{ 0, 1, 1, 0, 0, 0 },
						{ 0, 1, 0, 0, 0, 0 },
						{ 0, 0, 0, 0, 0, 0 },
					};
					iSubMenuArrow = std::make_pair(ink, image{ "neogfx::menu_item_widget::" + ink.to_string(), sArrowImagePattern, { { 0, colour{} },{ 1, ink } } });
				}
				rect rect = client_rect(false);
				aGraphicsContext.draw_texture(
					point{ rect.right() - iGap + std::floor((iGap - iSubMenuArrow->second.extents().cx) / 2.0), std::floor((rect.height() - iSubMenuArrow->second.extents().cy) / 2.0) },
					iSubMenuArrow->second);
			}
		}
		else
		{
			scoped_units su(*this, aGraphicsContext, UnitsPixels);
			rect line = client_rect(false);
			++line.y;
			line.cy = 1.0;
			line.x += (iIconSize + iGap * 2.0);
			line.cx -= (iIconSize + iGap * 3.0);
			colour ink = background_colour().light() ? background_colour().darker(0x60) : background_colour().lighter(0x60);
			ink.set_alpha(0x80);
			aGraphicsContext.fill_rect(line, ink);
		}
	}
Beispiel #5
0
	void button::mouse_button_released(mouse_button aButton, const point& aPosition)
	{
		bool wasCapturing = capturing();
		widget::mouse_button_released(aButton, aPosition);
		if (wasCapturing && client_rect().contains(aPosition))
		{
			if (aButton == mouse_button::Left)
			{
				destroyed_flag destroyed(*this);
				handle_clicked();
				if (!destroyed)
					released.trigger();
			}
		}
	}
Beispiel #6
0
void wxRibbonMetroArtProvider::DrawMinimisedPanel(
                        wxDC& dc,
                        wxRibbonPanel* wnd,
                        const wxRect& rect,
                        wxBitmap& bitmap)
{
    DrawPartialPageBackground(dc, wnd, rect, false);

    wxRect true_rect(rect);
    // RemovePanelPadding(&true_rect);
	
	wxRect client_rect(true_rect);
	client_rect.width -= 2;
	client_rect.y++;
	client_rect.height -= 2;
	
	if(wnd->GetExpandedPanel() != NULL)
    {
		dc.SetPen(m_button_bar_active_border_pen);
		dc.SetBrush (m_button_bar_active_background_colour);
		dc.DrawRectangle(client_rect);
    }
    else if(wnd->IsHovered())
    {
		dc.SetPen(m_button_bar_hover_border_pen);
		dc.SetBrush (m_panel_active_background_colour);
		dc.DrawRectangle(client_rect);
    }
	else {
		dc.SetPen(m_button_bar_hover_border_pen);
		dc.SetBrush (m_button_bar_hover_background_colour);
		dc.DrawRectangle(client_rect);		
	}

    wxRect preview;
    DrawMinimisedPanelCommon(dc, wnd, true_rect, &preview);
    dc.SetBrush(m_panel_active_background_colour);
    dc.SetPen(m_button_bar_hover_border_pen);
	dc.DrawRectangle(preview);

    if(bitmap.IsOk())
    {
        dc.DrawBitmap(bitmap, preview.x + (preview.width - bitmap.GetWidth()) / 2,
            preview.y + (preview.height - 7 - bitmap.GetHeight()) / 2, true);
    }

    DrawPanelBorder(dc, true_rect, m_panel_border_pen, m_panel_border_gradient_pen);
}
	void colour_picker_dialog::x_picker::paint(graphics_context& aGraphicsContext) const
	{
		framed_widget::paint(aGraphicsContext);
		scoped_units su(*this, UnitsPixels);
		rect cr = client_rect(false);
		for (uint32_t x = 0; x < cr.height(); ++x)
		{
			double nx = x / (cr.height() - 1.0);
			rect line{ cr.top_left() + point{ 0.0, cr.height() - x - 1.0 }, size{ cr.width(), 1.0 } };
			if (iParent.mode() == ModeHSV)
			{
				hsv_colour hsvColour{ nx * 359.0, 1.0, 1.0 };
				aGraphicsContext.fill_rect(line, hsvColour.to_rgb());
			}
		}
	}
// virtual
void LLPreviewTexture::reshape(S32 width, S32 height, BOOL called_from_parent)
{
	LLPreview::reshape(width, height, called_from_parent);

	LLRect dim_rect;
	LLView *pView = findChildView( "dimensions" );
	
	if( pView )
		dim_rect = pView->getRect();

	S32 horiz_pad = 2 * (LLPANEL_BORDER_WIDTH + PREVIEW_PAD) + PREVIEW_RESIZE_HANDLE_SIZE;

	// add space for dimensions and aspect ratio
	S32 info_height = dim_rect.mTop + CLIENT_RECT_VPAD;

	LLRect client_rect(horiz_pad, getRect().getHeight(), getRect().getWidth() - horiz_pad, 0);
	client_rect.mTop -= (PREVIEW_HEADER_SIZE + CLIENT_RECT_VPAD);
	client_rect.mBottom += PREVIEW_BORDER + CLIENT_RECT_VPAD + info_height ;

	S32 client_width = client_rect.getWidth();
	S32 client_height = client_rect.getHeight();

	if (mAspectRatio > 0.f)
	{
		if(mAspectRatio > 1.f)
		{
			client_height = llceil((F32)client_width / mAspectRatio);
			if(client_height > client_rect.getHeight())
			{
				client_height = client_rect.getHeight();
				client_width = llceil((F32)client_height * mAspectRatio);
			}
		}
		else//mAspectRatio < 1.f
		{
			client_width = llceil((F32)client_height * mAspectRatio);
			if(client_width > client_rect.getWidth())
			{
				client_width = client_rect.getWidth();
				client_height = llceil((F32)client_width / mAspectRatio);
			}
		}
	}

	mClientRect.setLeftTopAndSize(client_rect.getCenterX() - (client_width / 2), client_rect.getCenterY() +  (client_height / 2), client_width, client_height);

}
	void colour_picker_dialog::yz_picker::paint(graphics_context& aGraphicsContext) const
	{
		framed_widget::paint(aGraphicsContext);
		rect cr = client_rect(false);
		for (uint32_t y = 0; y < cr.width(); ++y)
		{
			for (uint32_t z = 0; z < cr.height(); ++z)
			{
				double ny = y / (cr.width() - 1.0);
				double nz = z / (cr.height() - 1.0);
				if (iParent.mode() == ModeHSV)
				{
					hsv_colour hsvColour = iParent.selected_colour().to_hsv();
					hsvColour.set_saturation(ny);
					hsvColour.set_value(nz);
					aGraphicsContext.draw_pixel(cr.top_left() + point{ static_cast<coordinate>(y), cr.height() - z - 1.0 }, hsvColour.to_rgb());
				}
			}
		}
	}
void CL_Window_Silver::on_resize(int old_width, int old_height)
{
	CL_Rect client_rect(3, 24, window->get_width() - 3, window->get_height() - 3);
	window->get_client_area()->set_position(client_rect);

	int xpos = window->get_width() - 20;

	if(button_close)
	{
		CL_Rect close_rect(xpos, 3, xpos + 17, 20);
		button_close->set_position(close_rect);
		xpos -= 18;
	}

	if(button_maximize)
	{
		CL_Rect close_rect(xpos, 3, xpos + 17, 20);
		button_maximize->set_position(close_rect);
		xpos -= 18;
	}

	if(button_minimize)
	{
		CL_Rect close_rect(xpos, 3, xpos + 17, 20);
		button_minimize->set_position(close_rect);
		xpos -= 18;
	}

	if(button_help)
	{
		CL_Rect close_rect(xpos, 3, xpos + 17, 20);
		button_help->set_position(close_rect);
	}

	CL_Rect move_rect(0, 0, window->get_width(), titlebar_height);
	move_handler->set_position(move_rect);
	
	CL_Rect resize_rect(window->get_width() - 3, window->get_height() - 3, window->get_width(), window->get_height());
	resize_handler->set_position(resize_rect);
}
Beispiel #11
0
	void image_widget::paint(graphics_context& aGraphicsContext) const
	{
		if (iTexture.is_empty())
			return;
		scoped_units su(*this, UnitsPixels);
		rect placementRect(point{}, iTexture.extents());
		if (iAspectRatio == aspect_ratio::Stretch)
		{
			placementRect.cx = client_rect().width();
			placementRect.cy = client_rect().height();
		}
		else if (placementRect.width() >= placementRect.height())
		{
			switch (iAspectRatio)
			{
			case aspect_ratio::Ignore:
				if (placementRect.width() > client_rect().width())
					placementRect.cx = client_rect().width();
				if (placementRect.height() > client_rect().height())
					placementRect.cy = client_rect().height();
				break;
			case aspect_ratio::Keep:
				if (placementRect.width() > client_rect().width())
				{
					placementRect.cx = client_rect().width();
					placementRect.cy = placementRect.cx * iTexture.extents().cy / iTexture.extents().cx;
				}
				if (placementRect.height() > client_rect().height())
				{
					placementRect.cy = client_rect().height();
					placementRect.cx = placementRect.cy * iTexture.extents().cx / iTexture.extents().cy;
				}
				break;
			case aspect_ratio::KeepExpanding:
				if (placementRect.height() > client_rect().height())
				{
					placementRect.cy = client_rect().height();
					placementRect.cx = placementRect.cy * iTexture.extents().cx / iTexture.extents().cy;
				}
				break;
			}
		}
		else
		{
			switch (iAspectRatio)
			{
			case aspect_ratio::Ignore:
				if (placementRect.width() > client_rect().width())
					placementRect.cx = client_rect().width();
				if (placementRect.height() > client_rect().height())
					placementRect.cy = client_rect().height();
				break;
			case aspect_ratio::Keep:
				if (placementRect.height() > client_rect().height())
				{
					placementRect.cy = client_rect().height();
					placementRect.cx = placementRect.cy * iTexture.extents().cx / iTexture.extents().cy;
				}
				if (placementRect.width() > client_rect().width())
				{
					placementRect.cx = client_rect().width();
					placementRect.cy = placementRect.cx * iTexture.extents().cy / iTexture.extents().cx;
				}
				break;
			case aspect_ratio::KeepExpanding:
				if (placementRect.width() > client_rect().width())
				{
					placementRect.cx = client_rect().width();
					placementRect.cy = placementRect.cx * iTexture.extents().cy / iTexture.extents().cx;
				}
				break;
			}
		}
		switch (iPlacement)
		{
		case cardinal_placement::NorthWest:
			placementRect.position() = point{};
			break;
		case cardinal_placement::North:
			placementRect.position() = point{ std::floor((client_rect().width() - placementRect.cx) / 2.0), 0.0 };
			break;
		case cardinal_placement::NorthEast:
			placementRect.position() = point{ client_rect().width() - placementRect.width(), 0.0 };
			break;
		case cardinal_placement::West:
			placementRect.position() = point{ 0.0, std::floor((client_rect().height() - placementRect.cy) / 2.0) };
			break;
		case cardinal_placement::Centre:
			placementRect.position() = point{ std::floor((client_rect().width() - placementRect.cx) / 2.0), std::floor((client_rect().height() - placementRect.cy) / 2.0) };
			break;
		case cardinal_placement::East:
			placementRect.position() = point{ client_rect().width() - placementRect.width(), std::floor((client_rect().height() - placementRect.cy) / 2.0) };
			break;
		case cardinal_placement::SouthWest:
			placementRect.position() = point{ 0.0, client_rect().height() - placementRect.height() };
			break;
		case cardinal_placement::South:
			placementRect.position() = point{ std::floor((client_rect().width() - placementRect.cx) / 2.0), client_rect().height() - placementRect.height() };
			break;
		case cardinal_placement::SouthEast:
			placementRect.position() = point{ client_rect().width() - placementRect.width(), client_rect().height() - placementRect.height() };
			break;
		}
		if (effectively_disabled())
			aGraphicsContext.set_monochrome(true);
		aGraphicsContext.draw_texture(placementRect, iTexture, effectively_disabled() ? colour(0xFF, 0xFF, 0xFF, 0x80) : optional_colour());
		aGraphicsContext.set_monochrome(false);
	}
	void colour_picker_dialog::colour_box::paint(graphics_context& aGraphicsContext) const
	{
		framed_widget::paint(aGraphicsContext);
		aGraphicsContext.fill_rect(client_rect(false), iColour);
	}
Beispiel #13
0
	rect slider_impl::bar_box() const
	{
		rect result = client_rect(false);
		result.deflate(size{ std::ceil(result.height() / 2.5) });
		return result;
	}
Beispiel #14
0
void widget::repaint(void)
{
    repaint(client_rect());
}
// virtual
void LLPreviewTexture::reshape(S32 width, S32 height, BOOL called_from_parent)
{
	LLPreview::reshape(width, height, called_from_parent);

	LLRect dim_rect;
	// Ansariel: Need the rect of the dimensions_panel
	//LLView *pView = findChildView( "dimensions" );
	LLView *pView = findChildView( "dimensions_panel" );
	
	if( pView )
		dim_rect = pView->getRect();

	S32 horiz_pad = 2 * (LLPANEL_BORDER_WIDTH + PREVIEW_PAD) + PREVIEW_RESIZE_HANDLE_SIZE;

	// add space for dimensions and aspect ratio
	S32 info_height = dim_rect.mTop + CLIENT_RECT_VPAD;

	LLRect client_rect(horiz_pad, getRect().getHeight(), getRect().getWidth() - horiz_pad, 0);
	client_rect.mTop -= (PREVIEW_HEADER_SIZE + CLIENT_RECT_VPAD);

	// <FS:Techwolf Lupindo> texture comment metadata reader
	// 1 additional line: uploader and date time
	if (findChild<LLTextEditor>("uploader_date_time"))
	{
		if (mImage && (mImage->mComment.find("a") != mImage->mComment.end() || mImage->mComment.find("z") != mImage->mComment.end()))
		{
			client_rect.mTop -= (getChild<LLTextEditor>("uploader_date_time")->getTextBoundingRect().getHeight() + CLIENT_RECT_VPAD);
		}
	}
	else if (findChild<LLLineEditor>("uploader"))
	{
		// AnsaStorm skin
		client_rect.mTop -= 3 * (PREVIEW_LINE_HEIGHT + CLIENT_RECT_VPAD);
	}
	// </FS:Techwolf Lupindo>


	client_rect.mBottom += PREVIEW_BORDER + CLIENT_RECT_VPAD + info_height ;

	S32 client_width = client_rect.getWidth();
	S32 client_height = client_rect.getHeight();

	if (mAspectRatio > 0.f)
	{
		if(mAspectRatio > 1.f)
		{
			client_height = llceil((F32)client_width / mAspectRatio);
			if(client_height > client_rect.getHeight())
			{
				client_height = client_rect.getHeight();
				client_width = llceil((F32)client_height * mAspectRatio);
			}
		}
		else//mAspectRatio < 1.f
		{
			client_width = llceil((F32)client_height * mAspectRatio);
			if(client_width > client_rect.getWidth())
			{
				client_width = client_rect.getWidth();
				client_height = llceil((F32)client_width / mAspectRatio);
			}
		}
	}

	mClientRect.setLeftTopAndSize(client_rect.getCenterX() - (client_width / 2), client_rect.getCenterY() +  (client_height / 2), client_width, client_height);

}
Beispiel #16
0
	rect table_view::item_display_rect() const
	{
		return rect(
			point(0.0, column_header().visible() ? column_header().extents().cy : 0.0),
			size(std::min(client_rect().width(), column_header().total_width()), client_rect().height() - (column_header().visible() ? column_header().extents().cy : 0.0)));
	}